profiling: add sample-rate yaml option

Add option "profiling.sample-rate":

  # Run profiling for every xth packet. The default is 1, which means we
  # profile every packet. If set to 1000, one packet is profiled for every
  # 1000 received.
  #sample-rate: 1000

This allows for configuration of the sample rate.
pull/808/merge
Victor Julien 12 years ago
parent 2c3a92a1c9
commit 8a735a9b90

@ -96,6 +96,9 @@ char *profiling_packets_file_name;
char *profiling_csv_file_name;
const char *profiling_packets_file_mode = "a";
static int rate = 1;
static SC_ATOMIC_DECL_AND_INIT(uint64_t, samples);
/**
* Used as a check so we don't double enter a profiling run.
*/
@ -123,6 +126,16 @@ SCProfilingInit(void)
{
ConfNode *conf;
intmax_t rate_v = 0;
(void)ConfGetInt("profiling.sample-rate", &rate_v);
if (rate_v > 0 && rate_v < INT_MAX) {
rate = (int)rate_v;
if (rate != 1)
SCLogInfo("profiling runs for every %dth packet", rate);
else
SCLogInfo("profiling runs for every packet");
}
conf = ConfGetNode("profiling.packets");
if (conf != NULL) {
if (ConfNodeChildValueIsTrue(conf, "enabled")) {
@ -843,9 +856,6 @@ void SCProfilingAddPacket(Packet *p) {
pthread_mutex_unlock(&packet_profile_lock);
}
static int rate = 1;
static SC_ATOMIC_DECL_AND_INIT(uint64_t, samples);
PktProfiling *SCProfilePacketStart(void) {
uint64_t sample = SC_ATOMIC_ADD(samples, 1);
if (sample % rate == 0)

@ -1218,6 +1218,10 @@ app-layer:
# the --enable-profiling configure flag.
#
profiling:
# Run profiling for every xth packet. The default is 1, which means we
# profile every packet. If set to 1000, one packet is profiled for every
# 1000 received.
#sample-rate: 1000
# rule profiling
rules:

Loading…
Cancel
Save