Conditionalize SigMatch performance counters.

Only include the counters when PROFILING.
pull/1295/head
Ken Steele 11 years ago committed by Victor Julien
parent 30b7fdcb49
commit 904441327c

@ -1356,12 +1356,14 @@ TmEcode DetectEngineThreadCtxInit(ThreadVars *tv, void *initdata, void **data)
* rules haven't been loaded yet. */
uint16_t counter_alerts = SCPerfTVRegisterCounter("detect.alert", tv,
SC_PERF_TYPE_UINT64, "NULL");
#ifdef PROFILING
uint16_t counter_mpm_list = SCPerfTVRegisterAvgCounter("detect.mpm_list", tv,
SC_PERF_TYPE_UINT64, "NULL");
uint16_t counter_nonmpm_list = SCPerfTVRegisterAvgCounter("detect.nonmpm_list", tv,
SC_PERF_TYPE_UINT64, "NULL");
uint16_t counter_match_list = SCPerfTVRegisterAvgCounter("detect.match_list", tv,
SC_PERF_TYPE_UINT64, "NULL");
#endif
if (de_ctx->delayed_detect == 1 && de_ctx->delayed_detect_initialized == 0) {
*data = NULL;
return TM_ECODE_OK;
@ -1380,9 +1382,11 @@ TmEcode DetectEngineThreadCtxInit(ThreadVars *tv, void *initdata, void **data)
/** alert counter setup */
det_ctx->counter_alerts = counter_alerts;
#ifdef PROFILING
det_ctx->counter_mpm_list = counter_mpm_list;
det_ctx->counter_nonmpm_list = counter_nonmpm_list;
det_ctx->counter_match_list = counter_match_list;
#endif
/* pass thread data back to caller */
*data = (void *)det_ctx;

@ -1334,8 +1334,14 @@ int SigMatchSignatures(ThreadVars *th_v, DetectEngineCtx *de_ctx, DetectEngineTh
PACKET_PROFILING_DETECT_START(p, PROF_DETECT_MPM);
DetectMpmPrefilter(de_ctx, det_ctx, smsg, p, flags, alproto, has_state, &sms_runflags);
PACKET_PROFILING_DETECT_END(p, PROF_DETECT_MPM);
SCPerfCounterAddUI64(det_ctx->counter_mpm_list, th_v->sc_perf_pca, (uint64_t)det_ctx->pmq.rule_id_array_cnt);
SCPerfCounterAddUI64(det_ctx->counter_nonmpm_list, th_v->sc_perf_pca, (uint64_t)det_ctx->sgh->non_mpm_id_cnt);
#ifdef PROFILING
if (th_v) {
SCPerfCounterAddUI64(det_ctx->counter_mpm_list, th_v->sc_perf_pca,
(uint64_t)det_ctx->pmq.rule_id_array_cnt);
SCPerfCounterAddUI64(det_ctx->counter_nonmpm_list, th_v->sc_perf_pca,
(uint64_t)det_ctx->sgh->non_mpm_id_cnt);
}
#endif
PACKET_PROFILING_DETECT_START(p, PROF_DETECT_PREFILTER);
DetectPrefilterMergeSort(de_ctx, det_ctx, det_ctx->sgh);
@ -1345,7 +1351,12 @@ int SigMatchSignatures(ThreadVars *th_v, DetectEngineCtx *de_ctx, DetectEngineTh
/* inspect the sigs against the packet */
/* Prefetch the next signature. */
SigIntId match_cnt = det_ctx->match_array_cnt;
SCPerfCounterAddUI64(det_ctx->counter_match_list, th_v->sc_perf_pca, (uint64_t)match_cnt);
#ifdef PROFILING
if (th_v) {
SCPerfCounterAddUI64(det_ctx->counter_match_list, th_v->sc_perf_pca,
(uint64_t)match_cnt);
}
#endif
Signature **match_array = det_ctx->match_array;
uint32_t sflags, next_sflags = 0;

@ -791,9 +791,11 @@ typedef struct DetectionEngineThreadCtx_ {
/** id for alert counter */
uint16_t counter_alerts;
#ifdef COLLECT_SIGMATCH_LIST_STATS
uint16_t counter_mpm_list;
uint16_t counter_nonmpm_list;
uint16_t counter_match_list;
#endif
/* used to discontinue any more matching */
uint16_t discontinue_matching;

Loading…
Cancel
Save