]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
flow/recycler: stats micro optimization
authorVictor Julien <vjulien@oisf.net>
Fri, 26 May 2023 10:16:04 +0000 (12:16 +0200)
committerVictor Julien <vjulien@oisf.net>
Wed, 31 May 2023 05:57:40 +0000 (07:57 +0200)
Don't update stat from loop as it's not read until after the loop.

src/flow-manager.c

index 4edde6a229ab0e11d5941ba7f5b63924973cb63a..f809286ac4947a2f2e99bce8f3213fa79a150b2f 100644 (file)
@@ -1072,11 +1072,15 @@ static TmEcode FlowRecycler(ThreadVars *th_v, void *thread_data)
         /* Get the time */
         SCLogDebug("ts %" PRIdMAX "", (intmax_t)SCTIME_SECS(TimeGet()));
 
+        uint64_t cnt = 0;
         Flow *f;
         while ((f = FlowQueuePrivateGetFromTop(&list)) != NULL) {
             Recycler(th_v, ftd, f);
-            recycled_cnt++;
-            StatsIncr(th_v, ftd->counter_flows);
+            cnt++;
+        }
+        if (cnt > 0) {
+            recycled_cnt += cnt;
+            StatsAddUI64(th_v, ftd->counter_flows, cnt);
         }
         SC_ATOMIC_SUB(flowrec_busy,1);