42 #define MIN(a, b) (((a) < (b)) ? (a) : (b))
45 static pthread_mutex_t packet_profile_lock;
46 static FILE *packet_profile_csv_fp = NULL;
58 #ifdef PROFILE_LOCKING
97 static int profiling_packets_csv_enabled = 0;
98 static int profiling_packets_output_to_file = 0;
99 static char *profiling_file_name;
100 static char profiling_packets_file_name[PATH_MAX];
101 static char *profiling_csv_file_name;
102 static const char *profiling_packets_file_mode =
"a";
115 static void PrintCSVHeader(
void);
117 static void FormatNumber(uint64_t num,
char *
str,
size_t size)
120 snprintf(
str, size,
"%"PRIu64, num);
121 else if (num < 1000000UL)
122 snprintf(
str, size,
"%3.1fk", (
float)num/1000UL);
123 else if (num < 1000000000UL)
124 snprintf(
str, size,
"%3.1fm", (
float)num/1000000UL);
126 snprintf(
str, size,
"%3.1fb", (
float)num/1000000000UL);
140 (void)
ConfGetInt(
"profiling.sample-rate", &rate_v);
141 if (rate_v > 0 && rate_v < INT_MAX) {
144 SCLogInfo(
"profiling runs for every %dth packet", rate);
146 SCLogInfo(
"profiling runs for every packet");
154 if (pthread_mutex_init(&packet_profile_lock, NULL) != 0) {
155 FatalError(
"Failed to initialize packet profiling mutex.");
172 if (filename != NULL) {
174 strlcpy(profiling_packets_file_name, filename,
175 sizeof(profiling_packets_file_name));
178 snprintf(profiling_packets_file_name,
sizeof(profiling_packets_file_name),
179 "%s/%s", log_dir, filename);
184 profiling_packets_file_mode =
"a";
186 profiling_packets_file_mode =
"w";
189 profiling_packets_output_to_file = 1;
197 if (filename == NULL) {
198 filename =
"packet_profile.csv";
201 profiling_csv_file_name =
SCStrdup(filename);
202 if (
unlikely(profiling_csv_file_name == NULL)) {
206 profiling_csv_file_name =
SCMalloc(PATH_MAX);
207 if (
unlikely(profiling_csv_file_name == NULL)) {
212 snprintf(profiling_csv_file_name, PATH_MAX,
"%s/%s", log_dir, filename);
215 packet_profile_csv_fp = fopen(profiling_csv_file_name,
"w");
216 if (packet_profile_csv_fp == NULL) {
217 SCFree(profiling_csv_file_name);
218 profiling_csv_file_name = NULL;
224 profiling_packets_csv_enabled = 1;
232 #ifndef PROFILE_LOCKING
234 "lock profiling not compiled in. Add --enable-profiling-locks to configure.");
241 if (filename != NULL) {
273 pthread_mutex_destroy(&packet_profile_lock);
276 if (profiling_packets_csv_enabled) {
277 if (packet_profile_csv_fp != NULL)
278 fclose(packet_profile_csv_fp);
279 packet_profile_csv_fp = NULL;
282 if (profiling_csv_file_name != NULL)
283 SCFree(profiling_csv_file_name);
284 profiling_csv_file_name = NULL;
286 if (profiling_file_name != NULL)
287 SCFree(profiling_file_name);
288 profiling_file_name = NULL;
290 #ifdef PROFILE_LOCKING
299 SCLogPerf(
"Done dumping profiling data.");
302 static void DumpFlowWorkerIP(FILE *fp,
int ipv, uint64_t total)
309 for (
int p = 0; p < 257; p++) {
315 FormatNumber(pd->
tot, totalstr,
sizeof(totalstr));
316 double percent = (
long double)pd->
tot /
317 (
long double)total * 100;
319 fprintf(fp,
"%-20s IPv%d %3d %12"PRIu64
" %12"PRIu64
" %12"PRIu64
" %12"PRIu64
" %12s %-6.2f\n",
321 pd->
min, pd->
max, (uint64_t)(pd->
tot / pd->
cnt), totalstr, percent);
326 static void DumpFlowWorker(FILE *fp)
333 for (
int p = 0; p < 257; p++) {
341 fprintf(fp,
"\n%-20s %-6s %-5s %-12s %-12s %-12s %-12s\n",
342 "Flow Worker",
"IP ver",
"Proto",
"cnt",
"min",
"max",
"avg");
343 fprintf(fp,
"%-20s %-6s %-5s %-12s %-12s %-12s %-12s\n",
344 "--------------------",
"------",
"-----",
"----------",
"------------",
"------------",
"-----------");
345 DumpFlowWorkerIP(fp, 4, total);
346 DumpFlowWorkerIP(fp, 6, total);
347 fprintf(fp,
"Note: %s includes app-layer for TCP\n",
360 if (profiling_packets_output_to_file == 1) {
361 fp = fopen(profiling_packets_file_name, profiling_packets_file_mode);
364 SCLogError(
"failed to open %s: %s", profiling_packets_file_name, strerror(errno));
371 fprintf(fp,
"\n\nPacket profile dump:\n");
373 fprintf(fp,
"\n%-6s %-5s %-12s %-12s %-12s %-12s %-12s %-3s\n",
374 "IP ver",
"Proto",
"cnt",
"min",
"max",
"avg",
"tot",
"%%");
375 fprintf(fp,
"%-6s %-5s %-12s %-12s %-12s %-12s %-12s %-3s\n",
376 "------",
"-----",
"----------",
"------------",
"------------",
"-----------",
"-----------",
"---");
378 for (
int i = 0; i < 257; i++) {
385 for (
int i = 0; i < 257; i++) {
391 FormatNumber(pd->
tot, totalstr,
sizeof(totalstr));
392 double percent = (
long double)pd->
tot /
393 (
long double)total * 100;
395 fprintf(fp,
" IPv4 %3d %12"PRIu64
" %12"PRIu64
" %12"PRIu64
" %12"PRIu64
" %12s %6.2f\n", i, pd->
cnt,
396 pd->
min, pd->
max, (uint64_t)(pd->
tot / pd->
cnt), totalstr, percent);
399 for (
int i = 0; i < 257; i++) {
405 FormatNumber(pd->
tot, totalstr,
sizeof(totalstr));
406 double percent = (
long double)pd->
tot /
407 (
long double)total * 100;
409 fprintf(fp,
" IPv6 %3d %12"PRIu64
" %12"PRIu64
" %12"PRIu64
" %12"PRIu64
" %12s %6.2f\n", i, pd->
cnt,
410 pd->
min, pd->
max, (uint64_t)(pd->
tot / pd->
cnt), totalstr, percent);
412 fprintf(fp,
"Note: Protocol 256 tracks pseudo/tunnel packets.\n");
414 fprintf(fp,
"\nPer Thread module stats:\n");
416 fprintf(fp,
"\n%-24s %-6s %-5s %-12s %-12s %-12s %-12s %-12s %-3s",
417 "Thread Module",
"IP ver",
"Proto",
"cnt",
"min",
"max",
"avg",
"tot",
"%%");
418 #ifdef PROFILE_LOCKING
419 fprintf(fp,
" %-10s %-10s %-12s %-12s %-10s %-10s %-12s %-12s\n",
420 "locks",
"ticks",
"cont.",
"cont.avg",
"slocks",
"sticks",
"scont.",
"scont.avg");
424 fprintf(fp,
"%-24s %-6s %-5s %-12s %-12s %-12s %-12s %-12s %-3s",
425 "------------------------",
"------",
"-----",
"----------",
"------------",
"------------",
"-----------",
"-----------",
"---");
426 #ifdef PROFILE_LOCKING
427 fprintf(fp,
" %-10s %-10s %-12s %-12s %-10s %-10s %-12s %-12s\n",
428 "--------",
"--------",
"----------",
"-----------",
"--------",
"--------",
"------------",
"-----------");
434 for (
int p = 0; p < 257; p++) {
444 for (
int p = 0; p < 257; p++) {
450 FormatNumber(pd->
tot, totalstr,
sizeof(totalstr));
451 double percent = (
long double)pd->
tot /
452 (
long double)total * 100;
454 fprintf(fp,
"%-24s IPv4 %3d %12"PRIu64
" %12"PRIu64
" %12"PRIu64
" %12"PRIu64
" %12s %6.2f",
456 #ifdef PROFILE_LOCKING
457 fprintf(fp,
" %10.2f %12"PRIu64
" %12"PRIu64
" %10.2f %10.2f %12"PRIu64
" %12"PRIu64
" %10.2f\n",
458 (
float)pd->lock/pd->
cnt, (uint64_t)pd->ticks/pd->
cnt, pd->contention, (
float)pd->contention/pd->
cnt, (
float)pd->slock/pd->
cnt, (uint64_t)pd->sticks/pd->
cnt, pd->scontention, (
float)pd->scontention/pd->
cnt);
466 for (
int p = 0; p < 257; p++) {
472 FormatNumber(pd->
tot, totalstr,
sizeof(totalstr));
473 double percent = (
long double)pd->
tot /
474 (
long double)total * 100;
476 fprintf(fp,
"%-24s IPv6 %3d %12"PRIu64
" %12"PRIu64
" %12"PRIu64
" %12"PRIu64
" %12s %6.2f\n",
483 fprintf(fp,
"\nPer App layer parser stats:\n");
485 fprintf(fp,
"\n%-20s %-6s %-5s %-12s %-12s %-12s %-12s\n",
486 "App Layer",
"IP ver",
"Proto",
"cnt",
"min",
"max",
"avg");
487 fprintf(fp,
"%-20s %-6s %-5s %-12s %-12s %-12s %-12s\n",
488 "--------------------",
"------",
"-----",
"----------",
"------------",
"------------",
"-----------");
492 for (
int p = 0; p < 257; p++) {
501 for (
int p = 0; p < 257; p++) {
507 FormatNumber(pd->
tot, totalstr,
sizeof(totalstr));
508 double percent = (
long double)pd->
tot /
509 (
long double)total * 100;
512 "%-20s IPv4 %3d %12" PRIu64
" %12" PRIu64
" %12" PRIu64
513 " %12" PRIu64
" %12s %-6.2f\n",
515 (uint64_t)(pd->
tot / pd->
cnt), totalstr, percent);
520 for (
int p = 0; p < 257; p++) {
526 FormatNumber(pd->
tot, totalstr,
sizeof(totalstr));
527 double percent = (
long double)pd->
tot /
528 (
long double)total * 100;
531 "%-20s IPv6 %3d %12" PRIu64
" %12" PRIu64
" %12" PRIu64
532 " %12" PRIu64
" %12s %-6.2f\n",
534 (uint64_t)(pd->
tot / pd->
cnt), totalstr, percent);
540 for (
int p = 0; p < 257; p++) {
546 FormatNumber(pd->
tot, totalstr,
sizeof(totalstr));
547 fprintf(fp,
"%-20s IPv4 %3d %12"PRIu64
" %12"PRIu64
" %12"PRIu64
" %12"PRIu64
" %12s\n",
548 "Proto detect", p, pd->
cnt, pd->
min, pd->
max, (uint64_t)(pd->
tot / pd->
cnt), totalstr);
551 for (
int p = 0; p < 257; p++) {
557 FormatNumber(pd->
tot, totalstr,
sizeof(totalstr));
558 fprintf(fp,
"%-20s IPv6 %3d %12"PRIu64
" %12"PRIu64
" %12"PRIu64
" %12"PRIu64
" %12s\n",
559 "Proto detect", p, pd->
cnt, pd->
min, pd->
max, (uint64_t)(pd->
tot / pd->
cnt), totalstr);
565 for (
int p = 0; p < 257; p++) {
574 fprintf(fp,
"\n%-24s %-6s %-5s %-12s %-12s %-12s %-12s %-12s %-3s",
575 "Log Thread Module",
"IP ver",
"Proto",
"cnt",
"min",
"max",
"avg",
"tot",
"%%");
576 #ifdef PROFILE_LOCKING
577 fprintf(fp,
" %-10s %-10s %-12s %-12s %-10s %-10s %-12s %-12s\n",
578 "locks",
"ticks",
"cont.",
"cont.avg",
"slocks",
"sticks",
"scont.",
"scont.avg");
582 fprintf(fp,
"%-24s %-6s %-5s %-12s %-12s %-12s %-12s %-12s %-3s",
583 "------------------------",
"------",
"-----",
"----------",
"------------",
"------------",
"-----------",
"-----------",
"---");
584 #ifdef PROFILE_LOCKING
585 fprintf(fp,
" %-10s %-10s %-12s %-12s %-10s %-10s %-12s %-12s\n",
586 "--------",
"--------",
"----------",
"-----------",
"--------",
"--------",
"------------",
"-----------");
592 for (
int p = 0; p < 257; p++) {
602 for (
int p = 0; p < 257; p++) {
608 FormatNumber(pd->
tot, totalstr,
sizeof(totalstr));
609 double percent = (
long double)pd->
tot /
610 (
long double)total * 100;
612 fprintf(fp,
"%-24s IPv4 %3d %12"PRIu64
" %12"PRIu64
" %12"PRIu64
" %12"PRIu64
" %12s %6.2f",
614 #ifdef PROFILE_LOCKING
615 fprintf(fp,
" %10.2f %12"PRIu64
" %12"PRIu64
" %10.2f %10.2f %12"PRIu64
" %12"PRIu64
" %10.2f\n",
616 (
float)pd->lock/pd->
cnt, (uint64_t)pd->ticks/pd->
cnt, pd->contention, (
float)pd->contention/pd->
cnt, (
float)pd->slock/pd->
cnt, (uint64_t)pd->sticks/pd->
cnt, pd->scontention, (
float)pd->scontention/pd->
cnt);
624 for (
int p = 0; p < 257; p++) {
630 FormatNumber(pd->
tot, totalstr,
sizeof(totalstr));
631 double percent = (
long double)pd->
tot /
632 (
long double)total * 100;
634 fprintf(fp,
"%-24s IPv6 %3d %12"PRIu64
" %12"PRIu64
" %12"PRIu64
" %12"PRIu64
" %12s %6.2f\n",
639 fprintf(fp,
"\nLogger/output stats:\n");
643 for (
int p = 0; p < 256; p++) {
651 fprintf(fp,
"\n%-24s %-6s %-5s %-12s %-12s %-12s %-12s %-12s\n",
652 "Logger",
"IP ver",
"Proto",
"cnt",
"min",
"max",
"avg",
"tot");
653 fprintf(fp,
"%-24s %-6s %-5s %-12s %-12s %-12s %-12s %-12s\n",
654 "------------------------",
"------",
"-----",
"----------",
"------------",
"------------",
"-----------",
"-----------");
656 for (
int p = 0; p < 256; p++) {
662 FormatNumber(pd->
tot, totalstr,
sizeof(totalstr));
663 double percent = (
long double)pd->
tot /
664 (
long double)total * 100;
667 "%-24s IPv4 %3d %12" PRIu64
" %12" PRIu64
" %12" PRIu64
668 " %12" PRIu64
" %12s %-6.2f\n",
670 (uint64_t)(pd->
tot / pd->
cnt), totalstr, percent);
674 for (
int p = 0; p < 256; p++) {
680 FormatNumber(pd->
tot, totalstr,
sizeof(totalstr));
681 double percent = (
long double)pd->
tot /
682 (
long double)total * 100;
685 "%-24s IPv6 %3d %12" PRIu64
" %12" PRIu64
" %12" PRIu64
686 " %12" PRIu64
" %12s %-6.2f\n",
688 (uint64_t)(pd->
tot / pd->
cnt), totalstr, percent);
692 fprintf(fp,
"\nGeneral detection engine stats:\n");
696 for (
int p = 0; p < 257; p++) {
704 fprintf(fp,
"\n%-24s %-6s %-5s %-12s %-12s %-12s %-12s %-12s\n",
705 "Detection phase",
"IP ver",
"Proto",
"cnt",
"min",
"max",
"avg",
"tot");
706 fprintf(fp,
"%-24s %-6s %-5s %-12s %-12s %-12s %-12s %-12s\n",
707 "------------------------",
"------",
"-----",
"----------",
"------------",
"------------",
"-----------",
"-----------");
709 for (
int p = 0; p < 257; p++) {
715 FormatNumber(pd->
tot, totalstr,
sizeof(totalstr));
716 double percent = (
long double)pd->
tot /
717 (
long double)total * 100;
719 fprintf(fp,
"%-24s IPv4 %3d %12"PRIu64
" %12"PRIu64
" %12"PRIu64
" %12"PRIu64
" %12s %-6.2f\n",
724 for (
int p = 0; p < 257; p++) {
730 FormatNumber(pd->
tot, totalstr,
sizeof(totalstr));
731 double percent = (
long double)pd->
tot /
732 (
long double)total * 100;
734 fprintf(fp,
"%-24s IPv6 %3d %12"PRIu64
" %12"PRIu64
" %12"PRIu64
" %12"PRIu64
" %12s %-6.2f\n",
741 static void PrintCSVHeader(
void)
743 fprintf(packet_profile_csv_fp,
"pcap_cnt,total,receive,decode,flowworker,");
744 fprintf(packet_profile_csv_fp,
"threading,");
745 fprintf(packet_profile_csv_fp,
"proto detect,");
750 fprintf(packet_profile_csv_fp,
"loggers,");
762 fprintf(packet_profile_csv_fp,
"\n");
767 if (profiling_packets_csv_enabled == 0 || p == NULL ||
768 packet_profile_csv_fp == NULL || p->
profile == NULL) {
772 uint64_t tmm_total = 0;
773 uint64_t receive = 0;
778 fprintf(packet_profile_csv_fp,
"%"PRIu64
",%"PRIu64
",",
781 for (
int i = 0; i <
TMM_SIZE; i++) {
798 tmm_total += tmm_delta;
800 fprintf(packet_profile_csv_fp,
"%"PRIu64
",", receive);
801 fprintf(packet_profile_csv_fp,
"%"PRIu64
",", decode);
804 fprintf(packet_profile_csv_fp,
"%"PRIu64
",", delta - tmm_total);
807 uint64_t app_total = 0;
811 if (p->
proto == IPPROTO_TCP) {
823 ticks_spent -= app_total;
825 ticks_spent = app_total;
828 fprintf(packet_profile_csv_fp,
"%"PRIu64
",", ticks_spent);
832 uint64_t loggers = 0;
837 fprintf(packet_profile_csv_fp,
"%"PRIu64
",", loggers);
843 fprintf(packet_profile_csv_fp,
"%"PRIu64
",", pdt->
ticks_spent);
849 fprintf(packet_profile_csv_fp,
"%"PRIu64
",", pd->
ticks_spent);
852 fprintf(packet_profile_csv_fp,
"\n");
878 static void SCProfilingUpdatePacketDetectRecords(
Packet *p)
885 if (PacketIsIPv4(p)) {
886 SCProfilingUpdatePacketDetectRecord(i, p->
proto, pdt, 4);
888 SCProfilingUpdatePacketDetectRecord(i, p->
proto, pdt, 6);
894 static void SCProfilingUpdatePacketAppPdRecord(uint8_t ipproto, uint32_t ticks_spent,
int ipver)
902 if (pd->
min == 0 || ticks_spent < pd->min) {
903 pd->
min = ticks_spent;
905 if (pd->
max < ticks_spent) {
906 pd->
max = ticks_spent;
909 pd->
tot += ticks_spent;
913 static void SCProfilingUpdatePacketAppRecord(
int alproto, uint8_t ipproto,
PktProfilingAppData *pdt,
int ipver)
936 static void SCProfilingUpdatePacketAppRecords(
Packet *p)
943 if (PacketIsIPv4(p)) {
944 SCProfilingUpdatePacketAppRecord(i, p->
proto, pdt, 4);
946 SCProfilingUpdatePacketAppRecord(i, p->
proto, pdt, 6);
952 if (PacketIsIPv4(p)) {
973 if (pd->
min == 0 || delta < pd->min) {
976 if (pd->
max < delta) {
980 pd->
tot += (uint64_t)delta;
983 #ifdef PROFILE_LOCKING
984 pd->lock += pdt->mutex_lock_cnt;
985 pd->ticks += pdt->mutex_lock_wait_ticks;
986 pd->contention += pdt->mutex_lock_contention;
987 pd->slock += pdt->spin_lock_cnt;
988 pd->sticks += pdt->spin_lock_wait_ticks;
989 pd->scontention += pdt->spin_lock_contention;
993 static void SCProfilingUpdatePacketTmmRecords(
Packet *p)
1003 if (PacketIsIPv4(p)) {
1004 SCProfilingUpdatePacketTmmRecord(i, p->
proto, pdt, 4);
1006 SCProfilingUpdatePacketTmmRecord(i, p->
proto, pdt, 6);
1011 static inline void SCProfilingUpdatePacketGenericRecord(
PktProfilingData *pdt,
1014 if (pdt == NULL || pd == NULL) {
1019 if (pd->
min == 0 || delta < pd->min) {
1022 if (pd->
max < delta) {
1034 for (i = 0; i < size; i++) {
1044 if (PacketIsIPv4(p)) {
1050 SCProfilingUpdatePacketGenericRecord(pdt, store);
1054 static void SCProfilingUpdatePacketLogRecord(
LoggerId id,
1078 static void SCProfilingUpdatePacketLogRecords(
Packet *p)
1084 if (PacketIsIPv4(p)) {
1085 SCProfilingUpdatePacketLogRecord(i, p->
proto, pdt, 4);
1087 SCProfilingUpdatePacketLogRecord(i, p->
proto, pdt, 6);
1095 if (p == NULL || p->
profile == NULL ||
1100 pthread_mutex_lock(&packet_profile_lock);
1103 if (PacketIsIPv4(p)) {
1107 if (pd->
min == 0 || delta < pd->min) {
1110 if (pd->
max < delta) {
1117 if (PacketIsTunnel(p)) {
1120 if (pd->
min == 0 || delta < pd->min) {
1123 if (pd->
max < delta) {
1134 SCProfilingUpdatePacketTmmRecords(p);
1135 SCProfilingUpdatePacketAppRecords(p);
1136 SCProfilingUpdatePacketDetectRecords(p);
1137 SCProfilingUpdatePacketLogRecords(p);
1139 }
else if (PacketIsIPv6(p)) {
1143 if (pd->
min == 0 || delta < pd->min) {
1146 if (pd->
max < delta) {
1153 if (PacketIsTunnel(p)) {
1156 if (pd->
min == 0 || delta < pd->min) {
1159 if (pd->
max < delta) {
1170 SCProfilingUpdatePacketTmmRecords(p);
1171 SCProfilingUpdatePacketAppRecords(p);
1172 SCProfilingUpdatePacketDetectRecords(p);
1173 SCProfilingUpdatePacketLogRecords(p);
1176 if (profiling_packets_csv_enabled)
1180 pthread_mutex_unlock(&packet_profile_lock);
1186 if (sample % rate == 0)
1194 #ifdef PROFILE_LOCKING
1205 if ((sample % rate) == 0) {
1212 #define CASE_CODE(E) case E: return #E
1291 ProfilingGenericTicksTest01(
void)
1293 #define TEST_RUNS 1024
1294 uint64_t ticks_start = 0;
1295 uint64_t ticks_end = 0;
1304 printf(
"malloc(1024) %"PRIu64
"\n", (ticks_end - ticks_start)/
TEST_RUNS);
1311 printf(
"SCFree(1024) %"PRIu64
"\n", (ticks_end - ticks_start)/
TEST_RUNS);
1320 printf(
"SCMutexInit() %"PRIu64
"\n", (ticks_end - ticks_start)/
TEST_RUNS);
1327 printf(
"SCMutexLock() %"PRIu64
"\n", (ticks_end - ticks_start)/
TEST_RUNS);
1334 printf(
"SCMutexUnlock() %"PRIu64
"\n", (ticks_end - ticks_start)/
TEST_RUNS);
1341 printf(
"SCMutexDestroy() %"PRIu64
"\n", (ticks_end - ticks_start)/
TEST_RUNS);
1350 printf(
"SCSpinInit() %"PRIu64
"\n", (ticks_end - ticks_start)/
TEST_RUNS);
1357 printf(
"SCSpinLock() %"PRIu64
"\n", (ticks_end - ticks_start)/
TEST_RUNS);
1364 printf(
"SCSpinUnlock() %"PRIu64
"\n", (ticks_end - ticks_start)/
TEST_RUNS);
1371 printf(
"SCSpinDestroy() %"PRIu64
"\n", (ticks_end - ticks_start)/
TEST_RUNS);
1379 printf(
"SC_ATOMIC_ADD %"PRIu64
"\n", (ticks_end - ticks_start)/
TEST_RUNS);
1386 printf(
"SC_ATOMIC_CAS %"PRIu64
"\n", (ticks_end - ticks_start)/
TEST_RUNS);
1396 UtRegisterTest(
"ProfilingGenericTicksTest01", ProfilingGenericTicksTest01);
1413 static uint64_t rate = 0;
1423 intmax_t rate_v = 0;
1426 (void)
ConfGetInt(
"profiling.sample-rate", &rate_v);
1427 if (rate_v > 0 && rate_v < INT_MAX) {
1428 int literal_rate = (int)rate_v;
1429 for (
int i = literal_rate; i >= 1; i--) {
1431 if ((i & (i - 1)) == 0) {
1437 SCLogInfo(
"profiling runs for every %luth packet", rate + 1);
1439 SCLogInfo(
"profiling runs for every packet");
1460 if ((sample & rate) == 0) {