Skip to content

Commit

Permalink
profiling/rules: reduce sync logic scope
Browse files Browse the repository at this point in the history
Use a simple once a second scheme.
  • Loading branch information
victorjulien committed May 12, 2023
1 parent 694bff1 commit b591813
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 13 deletions.
2 changes: 0 additions & 2 deletions src/counters.c
Expand Up @@ -512,7 +512,6 @@ static void *StatsWakeupThread(void *arg)
/* assuming the assignment of an int to be atomic, and even if it's
* not, it should be okay */
tv->perf_public_ctx.perf_flag = 1;
tv->profile_flag = 1;

if (tv->inq != NULL) {
PacketQueue *q = tv->inq->pq;
Expand All @@ -533,7 +532,6 @@ static void *StatsWakeupThread(void *arg)
/* assuming the assignment of an int to be atomic, and even if it's
* not, it should be okay */
tv->perf_public_ctx.perf_flag = 1;
tv->profile_flag = 1;

tv = tv->next;
}
Expand Down
9 changes: 9 additions & 0 deletions src/detect.c
Expand Up @@ -1792,6 +1792,15 @@ TmEcode Detect(ThreadVars *tv, Packet *p, void *data)
} else {
DetectNoFlow(tv, de_ctx, det_ctx, p);
}

#ifdef PROFILE_RULES
/* aggregate statistics */
if (SCTIME_SECS(p->ts) != det_ctx->rule_perf_last_sync) {
SCProfilingRuleThreatAggregate(det_ctx);
det_ctx->rule_perf_last_sync = SCTIME_SECS(p->ts);
}
#endif

return TM_ECODE_OK;
error:
return TM_ECODE_FAILED;
Expand Down
1 change: 1 addition & 0 deletions src/detect.h
Expand Up @@ -1188,6 +1188,7 @@ typedef struct DetectEngineThreadCtx_ {
#ifdef PROFILE_RULES
struct SCProfileData_ *rule_perf_data;
int rule_perf_data_size;
uint32_t rule_perf_last_sync;
#endif
#ifdef PROFILING
struct SCProfileKeywordData_ *keyword_perf_data;
Expand Down
8 changes: 0 additions & 8 deletions src/flow-worker.c
Expand Up @@ -614,14 +614,6 @@ static TmEcode FlowWorker(ThreadVars *tv, Packet *p, void *data)
/* process local work queue */
FlowWorkerProcessLocalFlows(tv, fw, p);

#ifdef PROFILE_RULES
/* aggregate statistics */
if (tv->profile_flag == 1) {
SCProfilingRuleThreatAggregate((DetectEngineThreadCtx *)detect_thread);
tv->profile_flag = 0;
}
#endif

return TM_ECODE_OK;
}

Expand Down
3 changes: 0 additions & 3 deletions src/threadvars.h
Expand Up @@ -127,9 +127,6 @@ typedef struct ThreadVars_ {
/** public counter store: counter syncs update this */
StatsPublicThreadContext perf_public_ctx;

/** profile sync needed */
uint32_t profile_flag;

/* mutex and condition used by management threads */

SCCtrlMutex *ctrl_mutex;
Expand Down

0 comments on commit b591813

Please sign in to comment.