]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
Conditionalize SigMatch performance counters.
authorKen Steele <ken@tilera.com>
Fri, 7 Nov 2014 17:46:46 +0000 (12:46 -0500)
committerVictor Julien <victor@inliniac.net>
Thu, 15 Jan 2015 10:52:26 +0000 (11:52 +0100)
Only include the counters when PROFILING.

src/detect-engine.c
src/detect.c
src/detect.h

index 63de6d6a58d56239f8cb8ab43bf29f17e2e5641e..f2247b5d6b86fd59ee7eccc0a233ec2181a607b2 100644 (file)
@@ -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;
index 46a66f31f67144f1b848c9c21cc06bbb7cc29294..99779083141575435f1daf73b53eda6c56ad8ca0 100644 (file)
@@ -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;
index c3485a9f7040df228b93185480270ea18b3d6b66..2ed8b5a3c0235ddd0536bda4b88919860a7b36b6 100644 (file)
@@ -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;