suricata
util-profiling.h File Reference
#include "util-cpu.h"
#include "detect.h"
#include "util-profiling-locks.h"
Include dependency graph for util-profiling.h:

Go to the source code of this file.

Macros

#define KEYWORD_PROFILING_SET_LIST(ctx, list)
 
#define KEYWORD_PROFILING_START
 
#define KEYWORD_PROFILING_END(ctx, type, m)
 
#define PACKET_PROFILING_START(p)
 
#define PACKET_PROFILING_RESTART(p)
 
#define PACKET_PROFILING_END(p)
 
#define PACKET_PROFILING_RESET_LOCKS
 
#define PACKET_PROFILING_COPY_LOCKS(p, id)
 
#define PACKET_PROFILING_TMM_START(p, id)
 
#define PACKET_PROFILING_TMM_END(p, id)
 
#define FLOWWORKER_PROFILING_START(p, id)
 
#define FLOWWORKER_PROFILING_END(p, id)
 
#define PACKET_PROFILING_RESET(p)
 
#define PACKET_PROFILING_APP_START(dp, id)
 
#define PACKET_PROFILING_APP_END(dp)
 
#define PACKET_PROFILING_APP_PD_START(dp)
 
#define PACKET_PROFILING_APP_PD_END(dp)
 
#define PACKET_PROFILING_APP_RESET(dp)
 
#define PACKET_PROFILING_APP_STORE(dp, p)
 
#define PACKET_PROFILING_DETECT_START(p, id)
 
#define PACKET_PROFILING_DETECT_END(p, id)
 
#define PACKET_PROFILING_LOGGER_START(p, id)
 
#define PACKET_PROFILING_LOGGER_END(p, id)
 
#define SGH_PROFILING_RECORD(det_ctx, sgh)
 
#define PREFILTER_PROFILING_START(det_ctx)
 
#define PREFILTER_PROFILING_END(ctx, profile_id)
 
#define PREFILTER_PROFILING_ADD_BYTES(det_ctx, bytes)
 
#define RULE_PROFILING_START(p)
 
#define RULE_PROFILING_END(a, b, c, p)
 

Functions

void SCProfilingPrintPacketProfile (Packet *)
 
void SCProfilingAddPacket (Packet *)
 
PktProfilingSCProfilePacketStart (void)
 
void SCProfilingKeywordsGlobalInit (void)
 
void SCProfilingKeywordDestroyCtx (DetectEngineCtx *)
 
void SCProfilingKeywordInitCounters (DetectEngineCtx *)
 Register the keyword profiling counters.
 
void SCProfilingKeywordUpdateCounter (DetectEngineThreadCtx *det_ctx, int id, uint64_t ticks, int match)
 Update a rule counter.
 
void SCProfilingKeywordThreadSetup (struct SCProfileKeywordDetectCtx_ *, DetectEngineThreadCtx *)
 
void SCProfilingKeywordThreadCleanup (DetectEngineThreadCtx *)
 
void SCProfilingPrefilterGlobalInit (void)
 
void SCProfilingPrefilterDestroyCtx (DetectEngineCtx *)
 
void SCProfilingPrefilterInitCounters (DetectEngineCtx *)
 Register the prefilter profiling counters.
 
void SCProfilingPrefilterUpdateCounter (DetectEngineThreadCtx *det_ctx, int id, uint64_t ticks, uint64_t bytes, uint64_t bytes_called)
 Update a rule counter.
 
void SCProfilingPrefilterThreadSetup (struct SCProfilePrefilterDetectCtx_ *, DetectEngineThreadCtx *)
 
void SCProfilingPrefilterThreadCleanup (DetectEngineThreadCtx *)
 
void SCProfilingSghsGlobalInit (void)
 
void SCProfilingSghDestroyCtx (DetectEngineCtx *)
 
void SCProfilingSghInitCounters (DetectEngineCtx *)
 Register the keyword profiling counters.
 
void SCProfilingSghUpdateCounter (DetectEngineThreadCtx *det_ctx, const SigGroupHead *sgh)
 Update a rule counter.
 
void SCProfilingSghThreadSetup (struct SCProfileSghDetectCtx_ *, DetectEngineThreadCtx *)
 
void SCProfilingSghThreadCleanup (DetectEngineThreadCtx *)
 
void SCProfilingInit (void)
 Initialize profiling.
 
void SCProfilingDestroy (void)
 Free resources used by profiling.
 
void SCProfilingRegisterTests (void)
 
void SCProfilingDump (void)
 

Variables

int profiling_rules_enabled
 
int profiling_packets_enabled
 
int profiling_sghs_enabled
 
int profiling_keyword_enabled
 
thread_local int profiling_keyword_entered
 
int profiling_prefilter_enabled
 
thread_local int profiling_prefilter_entered
 

Detailed Description

Author
Endace Technology Limited.
Victor Julien victo.nosp@m.r@in.nosp@m.linia.nosp@m.c.ne.nosp@m.t

Definition in file util-profiling.h.

Macro Definition Documentation

◆ FLOWWORKER_PROFILING_END

#define FLOWWORKER_PROFILING_END (   p,
  id 
)
Value:
if (profiling_packets_enabled && (p)->profile != NULL) { \
if ((id) < PROFILE_FLOWWORKER_SIZE) { \
(p)->profile->flowworker[(id)].ticks_end = UtilCpuGetTicks(); \
} \
}
@ PROFILE_FLOWWORKER_SIZE
Definition flow-worker.h:29
uint64_t UtilCpuGetTicks(void)
Definition util-cpu.c:161
int profiling_packets_enabled

Definition at line 154 of file util-profiling.h.

◆ FLOWWORKER_PROFILING_START

#define FLOWWORKER_PROFILING_START (   p,
  id 
)
Value:
if (profiling_packets_enabled && (p)->profile != NULL) { \
if ((id) < PROFILE_FLOWWORKER_SIZE) { \
(p)->profile->flowworker[(id)].ticks_start = UtilCpuGetTicks();\
} \
}

Definition at line 147 of file util-profiling.h.

◆ KEYWORD_PROFILING_END

#define KEYWORD_PROFILING_END (   ctx,
  type,
  m 
)
Value:
profile_keyword_end_ = UtilCpuGetTicks(); \
SCProfilingKeywordUpdateCounter((ctx),(type),(profile_keyword_end_ - profile_keyword_start_),(m)); \
}
uint16_t type
SCMutex m
Definition flow-hash.h:6
struct Thresholds ctx
thread_local int profiling_keyword_entered
int profiling_keyword_enabled

Definition at line 64 of file util-profiling.h.

◆ KEYWORD_PROFILING_SET_LIST

#define KEYWORD_PROFILING_SET_LIST (   ctx,
  list 
)
Value:
{ \
(ctx)->keyword_perf_list = (list); \
}

Definition at line 46 of file util-profiling.h.

◆ KEYWORD_PROFILING_START

#define KEYWORD_PROFILING_START
Value:
uint64_t profile_keyword_start_ = 0; \
uint64_t profile_keyword_end_ = 0; \
SCLogError("Re-entered profiling, exiting."); \
abort(); \
} \
profile_keyword_start_ = UtilCpuGetTicks(); \
}

Definition at line 50 of file util-profiling.h.

◆ PACKET_PROFILING_APP_END

#define PACKET_PROFILING_APP_END (   dp)
Value:
(dp)->ticks_end = UtilCpuGetTicks(); \
if ((dp)->ticks_start != 0 && (dp)->ticks_start < ((dp)->ticks_end)) { \
(dp)->ticks_spent = ((dp)->ticks_end - (dp)->ticks_start); \
} \
}

Definition at line 173 of file util-profiling.h.

◆ PACKET_PROFILING_APP_PD_END

#define PACKET_PROFILING_APP_PD_END (   dp)
Value:
(dp)->proto_detect_ticks_end = UtilCpuGetTicks(); \
if ((dp)->proto_detect_ticks_start != 0 && (dp)->proto_detect_ticks_start < ((dp)->proto_detect_ticks_end)) { \
(dp)->proto_detect_ticks_spent = \
((dp)->proto_detect_ticks_end - (dp)->proto_detect_ticks_start); \
} \
}

Definition at line 186 of file util-profiling.h.

◆ PACKET_PROFILING_APP_PD_START

#define PACKET_PROFILING_APP_PD_START (   dp)
Value:
(dp)->proto_detect_ticks_start = UtilCpuGetTicks(); \
}

Definition at line 181 of file util-profiling.h.

◆ PACKET_PROFILING_APP_RESET

#define PACKET_PROFILING_APP_RESET (   dp)
Value:
(dp)->ticks_start = 0; \
(dp)->ticks_end = 0; \
(dp)->ticks_spent = 0; \
(dp)->alproto = 0; \
(dp)->proto_detect_ticks_start = 0; \
(dp)->proto_detect_ticks_end = 0; \
(dp)->proto_detect_ticks_spent = 0; \
}

Definition at line 195 of file util-profiling.h.

◆ PACKET_PROFILING_APP_START

#define PACKET_PROFILING_APP_START (   dp,
  id 
)
Value:
(dp)->ticks_start = UtilCpuGetTicks(); \
(dp)->alproto = (id); \
}

Definition at line 167 of file util-profiling.h.

◆ PACKET_PROFILING_APP_STORE

#define PACKET_PROFILING_APP_STORE (   dp,
 
)
Value:
if (profiling_packets_enabled && (p)->profile != NULL) { \
if ((dp)->alproto < g_alproto_max) { \
(p)->profile->app[(dp)->alproto].ticks_spent += (dp)->ticks_spent; \
(p)->profile->proto_detect += (dp)->proto_detect_ticks_spent; \
} \
}
AppProto g_alproto_max

Definition at line 206 of file util-profiling.h.

◆ PACKET_PROFILING_COPY_LOCKS

#define PACKET_PROFILING_COPY_LOCKS (   p,
  id 
)

Definition at line 128 of file util-profiling.h.

◆ PACKET_PROFILING_DETECT_END

#define PACKET_PROFILING_DETECT_END (   p,
  id 
)
Value:
if (profiling_packets_enabled && (p)->profile != NULL) { \
if ((id) < PROF_DETECT_SIZE) { \
(p)->profile->detect[(id)].ticks_end = UtilCpuGetTicks();\
if ((p)->profile->detect[(id)].ticks_start != 0 && \
(p)->profile->detect[(id)].ticks_start < (p)->profile->detect[(id)].ticks_end) { \
(p)->profile->detect[(id)].ticks_spent += \
((p)->profile->detect[(id)].ticks_end - (p)->profile->detect[(id)].ticks_start); \
} \
} \
}
@ PROF_DETECT_SIZE

Definition at line 221 of file util-profiling.h.

◆ PACKET_PROFILING_DETECT_START

#define PACKET_PROFILING_DETECT_START (   p,
  id 
)
Value:
if (profiling_packets_enabled && (p)->profile != NULL) { \
if ((id) < PROF_DETECT_SIZE) { \
(p)->profile->detect[(id)].ticks_start = UtilCpuGetTicks(); \
} \
}

Definition at line 214 of file util-profiling.h.

◆ PACKET_PROFILING_END

#define PACKET_PROFILING_END (   p)
Value:
if (profiling_packets_enabled && (p)->profile != NULL) { \
(p)->profile->ticks_end = UtilCpuGetTicks(); \
SCProfilingAddPacket((p)); \
}

Definition at line 86 of file util-profiling.h.

◆ PACKET_PROFILING_LOGGER_END

#define PACKET_PROFILING_LOGGER_END (   p,
  id 
)
Value:
if (profiling_packets_enabled && (p)->profile != NULL) { \
if ((id) < LOGGER_SIZE) { \
(p)->profile->logger[(id)].ticks_end = UtilCpuGetTicks();\
if ((p)->profile->logger[(id)].ticks_start != 0 && \
(p)->profile->logger[(id)].ticks_start < (p)->profile->logger[(id)].ticks_end) { \
(p)->profile->logger[(id)].ticks_spent += \
((p)->profile->logger[(id)].ticks_end - (p)->profile->logger[(id)].ticks_start); \
} \
} \
}
@ LOGGER_SIZE

Definition at line 240 of file util-profiling.h.

◆ PACKET_PROFILING_LOGGER_START

#define PACKET_PROFILING_LOGGER_START (   p,
  id 
)
Value:
if (profiling_packets_enabled && (p)->profile != NULL) { \
if ((id) < LOGGER_SIZE) { \
(p)->profile->logger[(id)].ticks_start = UtilCpuGetTicks(); \
} \
}

Definition at line 233 of file util-profiling.h.

◆ PACKET_PROFILING_RESET

#define PACKET_PROFILING_RESET (   p)
Value:
if (profiling_packets_enabled && (p)->profile != NULL) { \
SCFree((p)->profile); \
(p)->profile = NULL; \
}

Definition at line 161 of file util-profiling.h.

◆ PACKET_PROFILING_RESET_LOCKS

#define PACKET_PROFILING_RESET_LOCKS

Definition at line 127 of file util-profiling.h.

◆ PACKET_PROFILING_RESTART

#define PACKET_PROFILING_RESTART (   p)
Value:
if ((p)->profile != NULL) \
(p)->profile->ticks_start = UtilCpuGetTicks(); \
}

Definition at line 80 of file util-profiling.h.

◆ PACKET_PROFILING_START

#define PACKET_PROFILING_START (   p)
Value:
(p)->profile = SCProfilePacketStart(); \
if ((p)->profile != NULL) \
(p)->profile->ticks_start = UtilCpuGetTicks(); \
}
uint64_t ticks_start
Definition decode.h:367
PktProfiling * SCProfilePacketStart(void)

Definition at line 73 of file util-profiling.h.

◆ PACKET_PROFILING_TMM_END

#define PACKET_PROFILING_TMM_END (   p,
  id 
)
Value:
if (profiling_packets_enabled && (p)->profile != NULL) { \
if ((id) < TMM_SIZE) { \
PACKET_PROFILING_COPY_LOCKS((p), (id)); \
(p)->profile->tmm[(id)].ticks_end = UtilCpuGetTicks(); \
} \
}
@ TMM_SIZE

Definition at line 139 of file util-profiling.h.

◆ PACKET_PROFILING_TMM_START

#define PACKET_PROFILING_TMM_START (   p,
  id 
)
Value:
if (profiling_packets_enabled && (p)->profile != NULL) { \
if ((id) < TMM_SIZE) { \
(p)->profile->tmm[(id)].ticks_start = UtilCpuGetTicks();\
} \
}
#define PACKET_PROFILING_RESET_LOCKS

Definition at line 131 of file util-profiling.h.

◆ PREFILTER_PROFILING_ADD_BYTES

#define PREFILTER_PROFILING_ADD_BYTES (   det_ctx,
  bytes 
)
Value:
(det_ctx)->prefilter_bytes += (bytes); \
(det_ctx)->prefilter_bytes_called++

Definition at line 286 of file util-profiling.h.

◆ PREFILTER_PROFILING_END

#define PREFILTER_PROFILING_END (   ctx,
  profile_id 
)
Value:
profile_prefilter_end_ = UtilCpuGetTicks(); \
if (profile_prefilter_end_ > profile_prefilter_start_) \
SCProfilingPrefilterUpdateCounter((ctx), (profile_id), \
(profile_prefilter_end_ - profile_prefilter_start_), (ctx)->prefilter_bytes, \
(ctx)->prefilter_bytes_called); \
}
int profiling_prefilter_enabled
thread_local int profiling_prefilter_entered

Definition at line 276 of file util-profiling.h.

◆ PREFILTER_PROFILING_START

#define PREFILTER_PROFILING_START (   det_ctx)
Value:
(det_ctx)->prefilter_bytes = 0; \
(det_ctx)->prefilter_bytes_called = 0; \
uint64_t profile_prefilter_start_ = 0; \
uint64_t profile_prefilter_end_ = 0; \
SCLogError("Re-entered profiling, exiting."); \
abort(); \
} \
profile_prefilter_start_ = UtilCpuGetTicks(); \
}

Definition at line 260 of file util-profiling.h.

◆ RULE_PROFILING_END

#define RULE_PROFILING_END (   a,
  b,
  c,
 
)

Definition at line 422 of file util-profiling.h.

◆ RULE_PROFILING_START

#define RULE_PROFILING_START (   p)

Definition at line 421 of file util-profiling.h.

◆ SGH_PROFILING_RECORD

#define SGH_PROFILING_RECORD (   det_ctx,
  sgh 
)
Value:
SCProfilingSghUpdateCounter((det_ctx), (sgh)); \
}
int profiling_sghs_enabled

Definition at line 252 of file util-profiling.h.

Function Documentation

◆ SCProfilePacketStart()

PktProfiling * SCProfilePacketStart ( void  )

Definition at line 1198 of file util-profiling.c.

References g_alproto_max, SC_ATOMIC_ADD, and SCCalloc.

◆ SCProfilingAddPacket()

◆ SCProfilingDestroy()

void SCProfilingDestroy ( void  )

Free resources used by profiling.

Definition at line 276 of file util-profiling.c.

References LockRecordFreeHash(), packet_profile_app_data4, packet_profile_app_data6, profiling_packets_enabled, and SCFree.

Referenced by PostRunDeinit().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SCProfilingDump()

void SCProfilingDump ( void  )

Definition at line 311 of file util-profiling.c.

References SCLogPerf, and SCProfilingDumpPacketStats().

Referenced by PostRunDeinit().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SCProfilingInit()

◆ SCProfilingKeywordDestroyCtx()

void SCProfilingKeywordDestroyCtx ( DetectEngineCtx de_ctx)

◆ SCProfilingKeywordInitCounters()

void SCProfilingKeywordInitCounters ( DetectEngineCtx de_ctx)

Register the keyword profiling counters.

Parameters
de_ctxThe active DetectEngineCtx, used to get at the loaded rules.

Definition at line 365 of file util-profiling-keywords.c.

References DetectEngineCtx_::buffer_type_id, BUG_ON, SCProfileKeywordDetectCtx_::data, de_ctx, DETECT_TBLSIZE, DetectEngineCtx_::profile_keyword_ctx, DetectEngineCtx_::profile_keyword_ctx_per_list, profiling_keyword_enabled, SCCalloc, and SCLogPerf.

Referenced by SigGroupBuild().

Here is the caller graph for this function:

◆ SCProfilingKeywordsGlobalInit()

void SCProfilingKeywordsGlobalInit ( void  )

Definition at line 61 of file util-profiling-keywords.c.

References PathIsAbsolute(), profiling_keyword_enabled, SCConfGetNode(), SCConfigGetLogDirectory(), SCConfNodeChildValueIsTrue(), SCConfNodeLookupChildValue(), SCConfValIsTrue(), and strlcpy().

Referenced by PreRunInit().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SCProfilingKeywordThreadCleanup()

◆ SCProfilingKeywordThreadSetup()

◆ SCProfilingKeywordUpdateCounter()

void SCProfilingKeywordUpdateCounter ( DetectEngineThreadCtx det_ctx,
int  id,
uint64_t  ticks,
int  match 
)

◆ SCProfilingPrefilterDestroyCtx()

void SCProfilingPrefilterDestroyCtx ( DetectEngineCtx de_ctx)

Definition at line 236 of file util-profiling-prefilter.c.

References de_ctx, and DetectEngineCtx_::profile_prefilter_ctx.

Referenced by DetectEngineCtxFree().

Here is the caller graph for this function:

◆ SCProfilingPrefilterGlobalInit()

void SCProfilingPrefilterGlobalInit ( void  )

Definition at line 61 of file util-profiling-prefilter.c.

References PathIsAbsolute(), profiling_prefilter_enabled, SCConfGetNode(), SCConfigGetLogDirectory(), SCConfNodeChildValueIsTrue(), SCConfNodeLookupChildValue(), SCConfValIsTrue(), and strlcpy().

Referenced by PreRunInit().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SCProfilingPrefilterInitCounters()

void SCProfilingPrefilterInitCounters ( DetectEngineCtx de_ctx)

Register the prefilter profiling counters.

Parameters
de_ctxThe active DetectEngineCtx, used to get at the loaded rules.

Definition at line 300 of file util-profiling-prefilter.c.

References BUG_ON, ctx, SCProfilePrefilterDetectCtx_::data, de_ctx, HashListTableGetListData, HashListTableGetListHead(), HashListTableGetListNext, SCProfilePrefilterData_::name, DetectEngineCtx_::prefilter_hash_table, DetectEngineCtx_::prefilter_id, DetectEngineCtx_::profile_prefilter_ctx, profiling_prefilter_enabled, SCCalloc, SCLogDebug, SCLogPerf, and SCProfilePrefilterDetectCtx_::size.

Referenced by SigGroupBuild().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SCProfilingPrefilterThreadCleanup()

◆ SCProfilingPrefilterThreadSetup()

void SCProfilingPrefilterThreadSetup ( struct SCProfilePrefilterDetectCtx_ ctx,
DetectEngineThreadCtx det_ctx 
)

◆ SCProfilingPrefilterUpdateCounter()

void SCProfilingPrefilterUpdateCounter ( DetectEngineThreadCtx det_ctx,
int  id,
uint64_t  ticks,
uint64_t  bytes,
uint64_t  bytes_called 
)

◆ SCProfilingPrintPacketProfile()

◆ SCProfilingRegisterTests()

void SCProfilingRegisterTests ( void  )

Definition at line 1408 of file util-profiling.c.

References UtRegisterTest().

Here is the call graph for this function:

◆ SCProfilingSghDestroyCtx()

void SCProfilingSghDestroyCtx ( DetectEngineCtx de_ctx)

Definition at line 285 of file util-profiling-rulegroups.c.

References de_ctx, and DetectEngineCtx_::profile_sgh_ctx.

Referenced by DetectEngineCtxFree().

Here is the caller graph for this function:

◆ SCProfilingSghInitCounters()

void SCProfilingSghInitCounters ( DetectEngineCtx de_ctx)

Register the keyword profiling counters.

Parameters
de_ctxThe active DetectEngineCtx, used to get at the loaded rules.

Definition at line 348 of file util-profiling-rulegroups.c.

References BUG_ON, SCProfileSghDetectCtx_::cnt, SCProfileSghDetectCtx_::data, de_ctx, DetectEngineCtx_::profile_sgh_ctx, profiling_sghs_enabled, SCCalloc, SCLogPerf, and DetectEngineCtx_::sgh_array_cnt.

Referenced by SigPrepareStage4().

Here is the caller graph for this function:

◆ SCProfilingSghsGlobalInit()

void SCProfilingSghsGlobalInit ( void  )

Definition at line 61 of file util-profiling-rulegroups.c.

References PathIsAbsolute(), profiling_sghs_enabled, SCConfGetNode(), SCConfigGetLogDirectory(), SCConfNodeChildValueIsTrue(), SCConfNodeLookupChildValue(), SCConfValIsTrue(), and strlcpy().

Referenced by PreRunInit().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SCProfilingSghThreadCleanup()

◆ SCProfilingSghThreadSetup()

void SCProfilingSghThreadSetup ( struct SCProfileSghDetectCtx_ ctx,
DetectEngineThreadCtx det_ctx 
)

◆ SCProfilingSghUpdateCounter()

Variable Documentation

◆ profiling_keyword_enabled

int profiling_keyword_enabled
extern

◆ profiling_keyword_entered

thread_local int profiling_keyword_entered
extern

Definition at line 57 of file util-profiling-keywords.c.

◆ profiling_packets_enabled

int profiling_packets_enabled
extern

◆ profiling_prefilter_enabled

int profiling_prefilter_enabled
extern

◆ profiling_prefilter_entered

thread_local int profiling_prefilter_entered
extern

Definition at line 57 of file util-profiling-prefilter.c.

◆ profiling_rules_enabled

int profiling_rules_enabled
extern

◆ profiling_sghs_enabled

int profiling_sghs_enabled
extern