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.");
163 FatalError(
"Failed to allocate packet_profile_app_data4");
167 FatalError(
"Failed to allocate packet_profile_app_data6");
178 if (filename != NULL) {
180 strlcpy(profiling_packets_file_name, filename,
181 sizeof(profiling_packets_file_name));
184 snprintf(profiling_packets_file_name,
sizeof(profiling_packets_file_name),
185 "%s/%s", log_dir, filename);
190 profiling_packets_file_mode =
"a";
192 profiling_packets_file_mode =
"w";
195 profiling_packets_output_to_file = 1;
203 if (filename == NULL) {
204 filename =
"packet_profile.csv";
207 profiling_csv_file_name =
SCStrdup(filename);
208 if (
unlikely(profiling_csv_file_name == NULL)) {
212 profiling_csv_file_name =
SCMalloc(PATH_MAX);
213 if (
unlikely(profiling_csv_file_name == NULL)) {
218 snprintf(profiling_csv_file_name, PATH_MAX,
"%s/%s", log_dir, filename);
221 packet_profile_csv_fp = fopen(profiling_csv_file_name,
"w");
222 if (packet_profile_csv_fp == NULL) {
223 SCFree(profiling_csv_file_name);
224 profiling_csv_file_name = NULL;
230 profiling_packets_csv_enabled = 1;
238 #ifndef PROFILE_LOCKING
240 "lock profiling not compiled in. Add --enable-profiling-locks to configure.");
247 if (filename != NULL) {
288 pthread_mutex_destroy(&packet_profile_lock);
291 if (profiling_packets_csv_enabled) {
292 if (packet_profile_csv_fp != NULL)
293 fclose(packet_profile_csv_fp);
294 packet_profile_csv_fp = NULL;
297 if (profiling_csv_file_name != NULL)
298 SCFree(profiling_csv_file_name);
299 profiling_csv_file_name = NULL;
301 if (profiling_file_name != NULL)
302 SCFree(profiling_file_name);
303 profiling_file_name = NULL;
305 #ifdef PROFILE_LOCKING
314 SCLogPerf(
"Done dumping profiling data.");
317 static void DumpFlowWorkerIP(FILE *fp,
int ipv, uint64_t total)
324 for (
int p = 0; p < 257; p++) {
330 FormatNumber(pd->
tot, totalstr,
sizeof(totalstr));
331 double percent = (
long double)pd->
tot /
332 (
long double)total * 100;
334 fprintf(fp,
"%-20s IPv%d %3d %12"PRIu64
" %12"PRIu64
" %12"PRIu64
" %12"PRIu64
" %12s %-6.2f\n",
336 pd->
min, pd->
max, (uint64_t)(pd->
tot / pd->
cnt), totalstr, percent);
341 static void DumpFlowWorker(FILE *fp)
348 for (
int p = 0; p < 257; p++) {
356 fprintf(fp,
"\n%-20s %-6s %-5s %-12s %-12s %-12s %-12s\n",
357 "Flow Worker",
"IP ver",
"Proto",
"cnt",
"min",
"max",
"avg");
358 fprintf(fp,
"%-20s %-6s %-5s %-12s %-12s %-12s %-12s\n",
359 "--------------------",
"------",
"-----",
"----------",
"------------",
"------------",
"-----------");
360 DumpFlowWorkerIP(fp, 4, total);
361 DumpFlowWorkerIP(fp, 6, total);
362 fprintf(fp,
"Note: %s includes app-layer for TCP\n",
375 if (profiling_packets_output_to_file == 1) {
376 fp = fopen(profiling_packets_file_name, profiling_packets_file_mode);
379 SCLogError(
"failed to open %s: %s", profiling_packets_file_name, strerror(errno));
386 fprintf(fp,
"\n\nPacket profile dump:\n");
388 fprintf(fp,
"\n%-6s %-5s %-12s %-12s %-12s %-12s %-12s %-3s\n",
389 "IP ver",
"Proto",
"cnt",
"min",
"max",
"avg",
"tot",
"%%");
390 fprintf(fp,
"%-6s %-5s %-12s %-12s %-12s %-12s %-12s %-3s\n",
391 "------",
"-----",
"----------",
"------------",
"------------",
"-----------",
"-----------",
"---");
393 for (
int i = 0; i < 257; i++) {
400 for (
int i = 0; i < 257; i++) {
406 FormatNumber(pd->
tot, totalstr,
sizeof(totalstr));
407 double percent = (
long double)pd->
tot /
408 (
long double)total * 100;
410 fprintf(fp,
" IPv4 %3d %12"PRIu64
" %12"PRIu64
" %12"PRIu64
" %12"PRIu64
" %12s %6.2f\n", i, pd->
cnt,
411 pd->
min, pd->
max, (uint64_t)(pd->
tot / pd->
cnt), totalstr, percent);
414 for (
int i = 0; i < 257; i++) {
420 FormatNumber(pd->
tot, totalstr,
sizeof(totalstr));
421 double percent = (
long double)pd->
tot /
422 (
long double)total * 100;
424 fprintf(fp,
" IPv6 %3d %12"PRIu64
" %12"PRIu64
" %12"PRIu64
" %12"PRIu64
" %12s %6.2f\n", i, pd->
cnt,
425 pd->
min, pd->
max, (uint64_t)(pd->
tot / pd->
cnt), totalstr, percent);
427 fprintf(fp,
"Note: Protocol 256 tracks pseudo/tunnel packets.\n");
429 fprintf(fp,
"\nPer Thread module stats:\n");
431 fprintf(fp,
"\n%-24s %-6s %-5s %-12s %-12s %-12s %-12s %-12s %-3s",
432 "Thread Module",
"IP ver",
"Proto",
"cnt",
"min",
"max",
"avg",
"tot",
"%%");
433 #ifdef PROFILE_LOCKING
434 fprintf(fp,
" %-10s %-10s %-12s %-12s %-10s %-10s %-12s %-12s\n",
435 "locks",
"ticks",
"cont.",
"cont.avg",
"slocks",
"sticks",
"scont.",
"scont.avg");
439 fprintf(fp,
"%-24s %-6s %-5s %-12s %-12s %-12s %-12s %-12s %-3s",
440 "------------------------",
"------",
"-----",
"----------",
"------------",
"------------",
"-----------",
"-----------",
"---");
441 #ifdef PROFILE_LOCKING
442 fprintf(fp,
" %-10s %-10s %-12s %-12s %-10s %-10s %-12s %-12s\n",
443 "--------",
"--------",
"----------",
"-----------",
"--------",
"--------",
"------------",
"-----------");
449 for (
int p = 0; p < 257; p++) {
459 for (
int p = 0; p < 257; p++) {
465 FormatNumber(pd->
tot, totalstr,
sizeof(totalstr));
466 double percent = (
long double)pd->
tot /
467 (
long double)total * 100;
469 fprintf(fp,
"%-24s IPv4 %3d %12"PRIu64
" %12"PRIu64
" %12"PRIu64
" %12"PRIu64
" %12s %6.2f",
471 #ifdef PROFILE_LOCKING
472 fprintf(fp,
" %10.2f %12"PRIu64
" %12"PRIu64
" %10.2f %10.2f %12"PRIu64
" %12"PRIu64
" %10.2f\n",
473 (
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);
481 for (
int p = 0; p < 257; p++) {
487 FormatNumber(pd->
tot, totalstr,
sizeof(totalstr));
488 double percent = (
long double)pd->
tot /
489 (
long double)total * 100;
491 fprintf(fp,
"%-24s IPv6 %3d %12"PRIu64
" %12"PRIu64
" %12"PRIu64
" %12"PRIu64
" %12s %6.2f\n",
498 fprintf(fp,
"\nPer App layer parser stats:\n");
500 fprintf(fp,
"\n%-20s %-6s %-5s %-12s %-12s %-12s %-12s\n",
501 "App Layer",
"IP ver",
"Proto",
"cnt",
"min",
"max",
"avg");
502 fprintf(fp,
"%-20s %-6s %-5s %-12s %-12s %-12s %-12s\n",
503 "--------------------",
"------",
"-----",
"----------",
"------------",
"------------",
"-----------");
507 for (
int p = 0; p < 257; p++) {
516 for (
int p = 0; p < 257; p++) {
522 FormatNumber(pd->
tot, totalstr,
sizeof(totalstr));
523 double percent = (
long double)pd->
tot /
524 (
long double)total * 100;
527 "%-20s IPv4 %3d %12" PRIu64
" %12" PRIu64
" %12" PRIu64
528 " %12" PRIu64
" %12s %-6.2f\n",
530 (uint64_t)(pd->
tot / pd->
cnt), totalstr, percent);
535 for (
int p = 0; p < 257; p++) {
541 FormatNumber(pd->
tot, totalstr,
sizeof(totalstr));
542 double percent = (
long double)pd->
tot /
543 (
long double)total * 100;
546 "%-20s IPv6 %3d %12" PRIu64
" %12" PRIu64
" %12" PRIu64
547 " %12" PRIu64
" %12s %-6.2f\n",
549 (uint64_t)(pd->
tot / pd->
cnt), totalstr, percent);
555 for (
int p = 0; p < 257; p++) {
561 FormatNumber(pd->
tot, totalstr,
sizeof(totalstr));
562 fprintf(fp,
"%-20s IPv4 %3d %12"PRIu64
" %12"PRIu64
" %12"PRIu64
" %12"PRIu64
" %12s\n",
563 "Proto detect", p, pd->
cnt, pd->
min, pd->
max, (uint64_t)(pd->
tot / pd->
cnt), totalstr);
566 for (
int p = 0; p < 257; p++) {
572 FormatNumber(pd->
tot, totalstr,
sizeof(totalstr));
573 fprintf(fp,
"%-20s IPv6 %3d %12"PRIu64
" %12"PRIu64
" %12"PRIu64
" %12"PRIu64
" %12s\n",
574 "Proto detect", p, pd->
cnt, pd->
min, pd->
max, (uint64_t)(pd->
tot / pd->
cnt), totalstr);
580 for (
int p = 0; p < 257; p++) {
589 fprintf(fp,
"\n%-24s %-6s %-5s %-12s %-12s %-12s %-12s %-12s %-3s",
590 "Log Thread Module",
"IP ver",
"Proto",
"cnt",
"min",
"max",
"avg",
"tot",
"%%");
591 #ifdef PROFILE_LOCKING
592 fprintf(fp,
" %-10s %-10s %-12s %-12s %-10s %-10s %-12s %-12s\n",
593 "locks",
"ticks",
"cont.",
"cont.avg",
"slocks",
"sticks",
"scont.",
"scont.avg");
597 fprintf(fp,
"%-24s %-6s %-5s %-12s %-12s %-12s %-12s %-12s %-3s",
598 "------------------------",
"------",
"-----",
"----------",
"------------",
"------------",
"-----------",
"-----------",
"---");
599 #ifdef PROFILE_LOCKING
600 fprintf(fp,
" %-10s %-10s %-12s %-12s %-10s %-10s %-12s %-12s\n",
601 "--------",
"--------",
"----------",
"-----------",
"--------",
"--------",
"------------",
"-----------");
607 for (
int p = 0; p < 257; p++) {
617 for (
int p = 0; p < 257; p++) {
623 FormatNumber(pd->
tot, totalstr,
sizeof(totalstr));
624 double percent = (
long double)pd->
tot /
625 (
long double)total * 100;
627 fprintf(fp,
"%-24s IPv4 %3d %12"PRIu64
" %12"PRIu64
" %12"PRIu64
" %12"PRIu64
" %12s %6.2f",
629 #ifdef PROFILE_LOCKING
630 fprintf(fp,
" %10.2f %12"PRIu64
" %12"PRIu64
" %10.2f %10.2f %12"PRIu64
" %12"PRIu64
" %10.2f\n",
631 (
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);
639 for (
int p = 0; p < 257; p++) {
645 FormatNumber(pd->
tot, totalstr,
sizeof(totalstr));
646 double percent = (
long double)pd->
tot /
647 (
long double)total * 100;
649 fprintf(fp,
"%-24s IPv6 %3d %12"PRIu64
" %12"PRIu64
" %12"PRIu64
" %12"PRIu64
" %12s %6.2f\n",
654 fprintf(fp,
"\nLogger/output stats:\n");
658 for (
int p = 0; p < 256; p++) {
666 fprintf(fp,
"\n%-24s %-6s %-5s %-12s %-12s %-12s %-12s %-12s\n",
667 "Logger",
"IP ver",
"Proto",
"cnt",
"min",
"max",
"avg",
"tot");
668 fprintf(fp,
"%-24s %-6s %-5s %-12s %-12s %-12s %-12s %-12s\n",
669 "------------------------",
"------",
"-----",
"----------",
"------------",
"------------",
"-----------",
"-----------");
671 for (
int p = 0; p < 256; p++) {
677 FormatNumber(pd->
tot, totalstr,
sizeof(totalstr));
678 double percent = (
long double)pd->
tot /
679 (
long double)total * 100;
682 "%-24s IPv4 %3d %12" PRIu64
" %12" PRIu64
" %12" PRIu64
683 " %12" PRIu64
" %12s %-6.2f\n",
685 (uint64_t)(pd->
tot / pd->
cnt), totalstr, percent);
689 for (
int p = 0; p < 256; p++) {
695 FormatNumber(pd->
tot, totalstr,
sizeof(totalstr));
696 double percent = (
long double)pd->
tot /
697 (
long double)total * 100;
700 "%-24s IPv6 %3d %12" PRIu64
" %12" PRIu64
" %12" PRIu64
701 " %12" PRIu64
" %12s %-6.2f\n",
703 (uint64_t)(pd->
tot / pd->
cnt), totalstr, percent);
707 fprintf(fp,
"\nGeneral detection engine stats:\n");
711 for (
int p = 0; p < 257; p++) {
719 fprintf(fp,
"\n%-24s %-6s %-5s %-12s %-12s %-12s %-12s %-12s\n",
720 "Detection phase",
"IP ver",
"Proto",
"cnt",
"min",
"max",
"avg",
"tot");
721 fprintf(fp,
"%-24s %-6s %-5s %-12s %-12s %-12s %-12s %-12s\n",
722 "------------------------",
"------",
"-----",
"----------",
"------------",
"------------",
"-----------",
"-----------");
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 IPv4 %3d %12"PRIu64
" %12"PRIu64
" %12"PRIu64
" %12"PRIu64
" %12s %-6.2f\n",
739 for (
int p = 0; p < 257; p++) {
745 FormatNumber(pd->
tot, totalstr,
sizeof(totalstr));
746 double percent = (
long double)pd->
tot /
747 (
long double)total * 100;
749 fprintf(fp,
"%-24s IPv6 %3d %12"PRIu64
" %12"PRIu64
" %12"PRIu64
" %12"PRIu64
" %12s %-6.2f\n",
756 static void PrintCSVHeader(
void)
758 fprintf(packet_profile_csv_fp,
"pcap_cnt,total,receive,decode,flowworker,");
759 fprintf(packet_profile_csv_fp,
"threading,");
760 fprintf(packet_profile_csv_fp,
"proto detect,");
765 fprintf(packet_profile_csv_fp,
"loggers,");
777 fprintf(packet_profile_csv_fp,
"\n");
782 if (profiling_packets_csv_enabled == 0 || p == NULL ||
783 packet_profile_csv_fp == NULL || p->
profile == NULL) {
787 uint64_t tmm_total = 0;
788 uint64_t receive = 0;
793 fprintf(packet_profile_csv_fp,
"%"PRIu64
",%"PRIu64
",",
796 for (
int i = 0; i <
TMM_SIZE; i++) {
813 tmm_total += tmm_delta;
815 fprintf(packet_profile_csv_fp,
"%"PRIu64
",", receive);
816 fprintf(packet_profile_csv_fp,
"%"PRIu64
",", decode);
819 fprintf(packet_profile_csv_fp,
"%"PRIu64
",", delta - tmm_total);
822 uint64_t app_total = 0;
826 if (p->
proto == IPPROTO_TCP) {
838 ticks_spent -= app_total;
840 ticks_spent = app_total;
843 fprintf(packet_profile_csv_fp,
"%"PRIu64
",", ticks_spent);
847 uint64_t loggers = 0;
852 fprintf(packet_profile_csv_fp,
"%"PRIu64
",", loggers);
858 fprintf(packet_profile_csv_fp,
"%"PRIu64
",", pdt->
ticks_spent);
864 fprintf(packet_profile_csv_fp,
"%"PRIu64
",", pd->
ticks_spent);
867 fprintf(packet_profile_csv_fp,
"\n");
893 static void SCProfilingUpdatePacketDetectRecords(
Packet *p)
900 if (PacketIsIPv4(p)) {
901 SCProfilingUpdatePacketDetectRecord(i, p->
proto, pdt, 4);
903 SCProfilingUpdatePacketDetectRecord(i, p->
proto, pdt, 6);
909 static void SCProfilingUpdatePacketAppPdRecord(uint8_t ipproto, uint32_t ticks_spent,
int ipver)
917 if (pd->
min == 0 || ticks_spent < pd->min) {
918 pd->
min = ticks_spent;
920 if (pd->
max < ticks_spent) {
921 pd->
max = ticks_spent;
924 pd->
tot += ticks_spent;
928 static void SCProfilingUpdatePacketAppRecord(
int alproto, uint8_t ipproto,
PktProfilingAppData *pdt,
int ipver)
951 static void SCProfilingUpdatePacketAppRecords(
Packet *p)
958 if (PacketIsIPv4(p)) {
959 SCProfilingUpdatePacketAppRecord(i, p->
proto, pdt, 4);
961 SCProfilingUpdatePacketAppRecord(i, p->
proto, pdt, 6);
967 if (PacketIsIPv4(p)) {
988 if (pd->
min == 0 || delta < pd->min) {
991 if (pd->
max < delta) {
995 pd->
tot += (uint64_t)delta;
998 #ifdef PROFILE_LOCKING
999 pd->lock += pdt->mutex_lock_cnt;
1000 pd->ticks += pdt->mutex_lock_wait_ticks;
1001 pd->contention += pdt->mutex_lock_contention;
1002 pd->slock += pdt->spin_lock_cnt;
1003 pd->sticks += pdt->spin_lock_wait_ticks;
1004 pd->scontention += pdt->spin_lock_contention;
1008 static void SCProfilingUpdatePacketTmmRecords(
Packet *p)
1018 if (PacketIsIPv4(p)) {
1019 SCProfilingUpdatePacketTmmRecord(i, p->
proto, pdt, 4);
1021 SCProfilingUpdatePacketTmmRecord(i, p->
proto, pdt, 6);
1026 static inline void SCProfilingUpdatePacketGenericRecord(
PktProfilingData *pdt,
1029 if (pdt == NULL || pd == NULL) {
1034 if (pd->
min == 0 || delta < pd->min) {
1037 if (pd->
max < delta) {
1049 for (i = 0; i < size; i++) {
1059 if (PacketIsIPv4(p)) {
1065 SCProfilingUpdatePacketGenericRecord(pdt, store);
1069 static void SCProfilingUpdatePacketLogRecord(
LoggerId id,
1093 static void SCProfilingUpdatePacketLogRecords(
Packet *p)
1099 if (PacketIsIPv4(p)) {
1100 SCProfilingUpdatePacketLogRecord(i, p->
proto, pdt, 4);
1102 SCProfilingUpdatePacketLogRecord(i, p->
proto, pdt, 6);
1110 if (p == NULL || p->
profile == NULL ||
1115 pthread_mutex_lock(&packet_profile_lock);
1118 if (PacketIsIPv4(p)) {
1122 if (pd->
min == 0 || delta < pd->min) {
1125 if (pd->
max < delta) {
1132 if (PacketIsTunnel(p)) {
1135 if (pd->
min == 0 || delta < pd->min) {
1138 if (pd->
max < delta) {
1149 SCProfilingUpdatePacketTmmRecords(p);
1150 SCProfilingUpdatePacketAppRecords(p);
1151 SCProfilingUpdatePacketDetectRecords(p);
1152 SCProfilingUpdatePacketLogRecords(p);
1154 }
else if (PacketIsIPv6(p)) {
1158 if (pd->
min == 0 || delta < pd->min) {
1161 if (pd->
max < delta) {
1168 if (PacketIsTunnel(p)) {
1171 if (pd->
min == 0 || delta < pd->min) {
1174 if (pd->
max < delta) {
1185 SCProfilingUpdatePacketTmmRecords(p);
1186 SCProfilingUpdatePacketAppRecords(p);
1187 SCProfilingUpdatePacketDetectRecords(p);
1188 SCProfilingUpdatePacketLogRecords(p);
1191 if (profiling_packets_csv_enabled)
1195 pthread_mutex_unlock(&packet_profile_lock);
1201 if (sample % rate == 0)
1209 #ifdef PROFILE_LOCKING
1220 if ((sample % rate) == 0) {
1227 #define CASE_CODE(E) case E: return #E
1306 ProfilingGenericTicksTest01(
void)
1308 #define TEST_RUNS 1024
1309 uint64_t ticks_start = 0;
1310 uint64_t ticks_end = 0;
1319 printf(
"malloc(1024) %"PRIu64
"\n", (ticks_end - ticks_start)/
TEST_RUNS);
1326 printf(
"SCFree(1024) %"PRIu64
"\n", (ticks_end - ticks_start)/
TEST_RUNS);
1335 printf(
"SCMutexInit() %"PRIu64
"\n", (ticks_end - ticks_start)/
TEST_RUNS);
1342 printf(
"SCMutexLock() %"PRIu64
"\n", (ticks_end - ticks_start)/
TEST_RUNS);
1349 printf(
"SCMutexUnlock() %"PRIu64
"\n", (ticks_end - ticks_start)/
TEST_RUNS);
1356 printf(
"SCMutexDestroy() %"PRIu64
"\n", (ticks_end - ticks_start)/
TEST_RUNS);
1365 printf(
"SCSpinInit() %"PRIu64
"\n", (ticks_end - ticks_start)/
TEST_RUNS);
1372 printf(
"SCSpinLock() %"PRIu64
"\n", (ticks_end - ticks_start)/
TEST_RUNS);
1379 printf(
"SCSpinUnlock() %"PRIu64
"\n", (ticks_end - ticks_start)/
TEST_RUNS);
1386 printf(
"SCSpinDestroy() %"PRIu64
"\n", (ticks_end - ticks_start)/
TEST_RUNS);
1394 printf(
"SC_ATOMIC_ADD %"PRIu64
"\n", (ticks_end - ticks_start)/
TEST_RUNS);
1401 printf(
"SC_ATOMIC_CAS %"PRIu64
"\n", (ticks_end - ticks_start)/
TEST_RUNS);
1411 UtRegisterTest(
"ProfilingGenericTicksTest01", ProfilingGenericTicksTest01);
1428 static uint64_t rate = 0;
1438 intmax_t rate_v = 0;
1441 (void)
ConfGetInt(
"profiling.sample-rate", &rate_v);
1442 if (rate_v > 0 && rate_v < INT_MAX) {
1443 int literal_rate = (int)rate_v;
1444 for (
int i = literal_rate; i >= 1; i--) {
1446 if ((i & (i - 1)) == 0) {
1452 SCLogInfo(
"profiling runs for every %luth packet", rate + 1);
1454 SCLogInfo(
"profiling runs for every packet");
1475 if ((sample & rate) == 0) {