From 3803cbd0e5fd013b9c9c012f557e075e4ebc417f Mon Sep 17 00:00:00 2001 From: Victor Julien Date: Fri, 26 May 2023 12:16:04 +0200 Subject: [PATCH] flow/recycler: stats micro optimization Don't update stat from loop as it's not read until after the loop. --- src/flow-manager.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/flow-manager.c b/src/flow-manager.c index 4edde6a229..f809286ac4 100644 --- a/src/flow-manager.c +++ b/src/flow-manager.c @@ -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);