Skip to content

Commit

Permalink
Revert "profiling/rules: reduce sync logic scope"
Browse files Browse the repository at this point in the history
This reverts commit b591813.
  • Loading branch information
Corey Thomas committed Nov 14, 2023
1 parent b6cd66f commit 3edc64f
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 10 deletions.
2 changes: 2 additions & 0 deletions src/counters.c
Original file line number Diff line number Diff line change
Expand Up @@ -512,6 +512,7 @@ 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 @@ -532,6 +533,7 @@ 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: 0 additions & 9 deletions src/detect.c
Original file line number Diff line number Diff line change
Expand Up @@ -1794,15 +1794,6 @@ 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: 0 additions & 1 deletion src/detect.h
Original file line number Diff line number Diff line change
Expand Up @@ -1232,7 +1232,6 @@ 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: 8 additions & 0 deletions src/flow-worker.c
Original file line number Diff line number Diff line change
Expand Up @@ -685,6 +685,14 @@ 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: 3 additions & 0 deletions src/threadvars.h
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,9 @@ 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 3edc64f

Please sign in to comment.