From: Victor Julien Date: Fri, 26 May 2023 10:16:04 +0000 (+0200) Subject: flow/recycler: stats micro optimization X-Git-Tag: suricata-7.0.0-rc2~109 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3803cbd0e5fd013b9c9c012f557e075e4ebc417f;p=thirdparty%2Fsuricata.git flow/recycler: stats micro optimization Don't update stat from loop as it's not read until after the loop. --- 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);