@cryptotaxi247 / netdata-1 / commits / b88a35cf8

Refactor UID/GID cache updates in apps plugin aggregation logic (#21864)

Refactor UID/GID cache updates in aggregation logic - Relocate `update_cached_host_users()` and `update_cached_host_groups()` calls outside per-PID loops to optimize and simplify code structure. - Remove redundant updates within conditional blocks.

Stelios Fragkakis committed Mar 3, 2026 at 10:56 UTC b88a35cf8a7781dcbd421a4fcef592d6075c2482
1 file changed +7 -3
src/collectors/apps.plugin/apps_aggregations.c
+7 -3
@@ -198,6 +198,13 @@ void aggregate_processes_to_targets(void) {
198 struct target *w = NULL, *o = NULL;
199 (void)w; (void)o;
200
201 +#if (PROCESSES_HAVE_UID == 1)
202 + update_cached_host_users();
203 +#endif
204 +#if (PROCESSES_HAVE_GID == 1)
205 + update_cached_host_groups();
206 +#endif
207 +
208 // concentrate everything on the targets
209 for(struct pid_stat *p = root_of_pids(); p ; p = p->next) {
210
@@ -217,8 +224,6 @@ void aggregate_processes_to_targets(void) {
224 // user target
225
226 #if (PROCESSES_HAVE_UID == 1)
220 - update_cached_host_users();
221 -
227 o = p->uid_target;
228 if(likely(p->uid_target && p->uid_target->uid == p->uid))
229 w = p->uid_target;
@@ -236,7 +241,6 @@ void aggregate_processes_to_targets(void) {
241 // user group target
242
243 #if (PROCESSES_HAVE_GID == 1)
239 - update_cached_host_users();
244
245 o = p->gid_target;
246 if(likely(p->gid_target && p->gid_target->gid == p->gid))