42 #define MIN(a, b) (((a) < (b)) ? (a) : (b))
45 #define DEFAULT_LOG_FILENAME "profile.log"
46 #define DEFAULT_LOG_MODE_APPEND "yes"
48 static pthread_mutex_t packet_profile_lock;
49 static FILE *packet_profile_csv_fp = NULL;
61 #ifdef PROFILE_LOCKING
100 static int profiling_packets_csv_enabled = 0;
101 static int profiling_packets_output_to_file = 0;
102 static char *profiling_file_name;
103 static char profiling_packets_file_name[PATH_MAX];
104 static char *profiling_csv_file_name;
105 static const char *profiling_packets_file_mode =
"a";
118 static void PrintCSVHeader(
void);
120 static void FormatNumber(uint64_t num,
char *
str,
size_t size)
123 snprintf(
str, size,
"%"PRIu64, num);
124 else if (num < 1000000UL)
125 snprintf(
str, size,
"%3.1fk", (
float)num/1000UL);
126 else if (num < 1000000000UL)
127 snprintf(
str, size,
"%3.1fm", (
float)num/1000000UL);
129 snprintf(
str, size,
"%3.1fb", (
float)num/1000000000UL);
143 (void)
ConfGetInt(
"profiling.sample-rate", &rate_v);
144 if (rate_v > 0 && rate_v < INT_MAX) {
147 SCLogInfo(
"profiling runs for every %dth packet", rate);
149 SCLogInfo(
"profiling runs for every packet");
157 if (pthread_mutex_init(&packet_profile_lock, NULL) != 0) {
158 FatalError(
"Failed to initialize packet profiling mutex.");
175 if (filename != NULL) {
177 strlcpy(profiling_packets_file_name, filename,
178 sizeof(profiling_packets_file_name));
181 snprintf(profiling_packets_file_name,
sizeof(profiling_packets_file_name),
182 "%s/%s", log_dir, filename);
187 profiling_packets_file_mode =
"a";
189 profiling_packets_file_mode =
"w";
192 profiling_packets_output_to_file = 1;
200 if (filename == NULL) {
201 filename =
"packet_profile.csv";
204 profiling_csv_file_name =
SCStrdup(filename);
205 if (
unlikely(profiling_csv_file_name == NULL)) {
209 profiling_csv_file_name =
SCMalloc(PATH_MAX);
210 if (
unlikely(profiling_csv_file_name == NULL)) {
215 snprintf(profiling_csv_file_name, PATH_MAX,
"%s/%s", log_dir, filename);
218 packet_profile_csv_fp = fopen(profiling_csv_file_name,
"w");
219 if (packet_profile_csv_fp == NULL) {
220 SCFree(profiling_csv_file_name);
221 profiling_csv_file_name = NULL;
227 profiling_packets_csv_enabled = 1;
235 #ifndef PROFILE_LOCKING
237 "lock profiling not compiled in. Add --enable-profiling-locks to configure.");
244 if (filename != NULL) {
276 pthread_mutex_destroy(&packet_profile_lock);
279 if (profiling_packets_csv_enabled) {
280 if (packet_profile_csv_fp != NULL)
281 fclose(packet_profile_csv_fp);
282 packet_profile_csv_fp = NULL;
285 if (profiling_csv_file_name != NULL)
286 SCFree(profiling_csv_file_name);
287 profiling_csv_file_name = NULL;
289 if (profiling_file_name != NULL)
290 SCFree(profiling_file_name);
291 profiling_file_name = NULL;
293 #ifdef PROFILE_LOCKING
302 SCLogPerf(
"Done dumping profiling data.");
305 static void DumpFlowWorkerIP(FILE *fp,
int ipv, uint64_t total)
312 for (
int p = 0; p < 257; p++) {
318 FormatNumber(pd->
tot, totalstr,
sizeof(totalstr));
319 double percent = (
long double)pd->
tot /
320 (
long double)total * 100;
322 fprintf(fp,
"%-20s IPv%d %3d %12"PRIu64
" %12"PRIu64
" %12"PRIu64
" %12"PRIu64
" %12s %-6.2f\n",
324 pd->
min, pd->
max, (uint64_t)(pd->
tot / pd->
cnt), totalstr, percent);
329 static void DumpFlowWorker(FILE *fp)
336 for (
int p = 0; p < 257; p++) {
344 fprintf(fp,
"\n%-20s %-6s %-5s %-12s %-12s %-12s %-12s\n",
345 "Flow Worker",
"IP ver",
"Proto",
"cnt",
"min",
"max",
"avg");
346 fprintf(fp,
"%-20s %-6s %-5s %-12s %-12s %-12s %-12s\n",
347 "--------------------",
"------",
"-----",
"----------",
"------------",
"------------",
"-----------");
348 DumpFlowWorkerIP(fp, 4, total);
349 DumpFlowWorkerIP(fp, 6, total);
350 fprintf(fp,
"Note: %s includes app-layer for TCP\n",
363 if (profiling_packets_output_to_file == 1) {
364 fp = fopen(profiling_packets_file_name, profiling_packets_file_mode);
367 SCLogError(
"failed to open %s: %s", profiling_packets_file_name, strerror(errno));
374 fprintf(fp,
"\n\nPacket profile dump:\n");
376 fprintf(fp,
"\n%-6s %-5s %-12s %-12s %-12s %-12s %-12s %-3s\n",
377 "IP ver",
"Proto",
"cnt",
"min",
"max",
"avg",
"tot",
"%%");
378 fprintf(fp,
"%-6s %-5s %-12s %-12s %-12s %-12s %-12s %-3s\n",
379 "------",
"-----",
"----------",
"------------",
"------------",
"-----------",
"-----------",
"---");
381 for (
int i = 0; i < 257; i++) {
388 for (
int i = 0; i < 257; i++) {
394 FormatNumber(pd->
tot, totalstr,
sizeof(totalstr));
395 double percent = (
long double)pd->
tot /
396 (
long double)total * 100;
398 fprintf(fp,
" IPv4 %3d %12"PRIu64
" %12"PRIu64
" %12"PRIu64
" %12"PRIu64
" %12s %6.2f\n", i, pd->
cnt,
399 pd->
min, pd->
max, (uint64_t)(pd->
tot / pd->
cnt), totalstr, percent);
402 for (
int i = 0; i < 257; i++) {
408 FormatNumber(pd->
tot, totalstr,
sizeof(totalstr));
409 double percent = (
long double)pd->
tot /
410 (
long double)total * 100;
412 fprintf(fp,
" IPv6 %3d %12"PRIu64
" %12"PRIu64
" %12"PRIu64
" %12"PRIu64
" %12s %6.2f\n", i, pd->
cnt,
413 pd->
min, pd->
max, (uint64_t)(pd->
tot / pd->
cnt), totalstr, percent);
415 fprintf(fp,
"Note: Protocol 256 tracks pseudo/tunnel packets.\n");
417 fprintf(fp,
"\nPer Thread module stats:\n");
419 fprintf(fp,
"\n%-24s %-6s %-5s %-12s %-12s %-12s %-12s %-12s %-3s",
420 "Thread Module",
"IP ver",
"Proto",
"cnt",
"min",
"max",
"avg",
"tot",
"%%");
421 #ifdef PROFILE_LOCKING
422 fprintf(fp,
" %-10s %-10s %-12s %-12s %-10s %-10s %-12s %-12s\n",
423 "locks",
"ticks",
"cont.",
"cont.avg",
"slocks",
"sticks",
"scont.",
"scont.avg");
427 fprintf(fp,
"%-24s %-6s %-5s %-12s %-12s %-12s %-12s %-12s %-3s",
428 "------------------------",
"------",
"-----",
"----------",
"------------",
"------------",
"-----------",
"-----------",
"---");
429 #ifdef PROFILE_LOCKING
430 fprintf(fp,
" %-10s %-10s %-12s %-12s %-10s %-10s %-12s %-12s\n",
431 "--------",
"--------",
"----------",
"-----------",
"--------",
"--------",
"------------",
"-----------");
440 for (
int p = 0; p < 257; p++) {
453 for (
int p = 0; p < 257; p++) {
459 FormatNumber(pd->
tot, totalstr,
sizeof(totalstr));
460 double percent = (
long double)pd->
tot /
461 (
long double)total * 100;
463 fprintf(fp,
"%-24s IPv4 %3d %12"PRIu64
" %12"PRIu64
" %12"PRIu64
" %12"PRIu64
" %12s %6.2f",
465 #ifdef PROFILE_LOCKING
466 fprintf(fp,
" %10.2f %12"PRIu64
" %12"PRIu64
" %10.2f %10.2f %12"PRIu64
" %12"PRIu64
" %10.2f\n",
467 (
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);
478 for (
int p = 0; p < 257; p++) {
484 FormatNumber(pd->
tot, totalstr,
sizeof(totalstr));
485 double percent = (
long double)pd->
tot /
486 (
long double)total * 100;
488 fprintf(fp,
"%-24s IPv6 %3d %12"PRIu64
" %12"PRIu64
" %12"PRIu64
" %12"PRIu64
" %12s %6.2f\n",
495 fprintf(fp,
"\nPer App layer parser stats:\n");
497 fprintf(fp,
"\n%-20s %-6s %-5s %-12s %-12s %-12s %-12s\n",
498 "App Layer",
"IP ver",
"Proto",
"cnt",
"min",
"max",
"avg");
499 fprintf(fp,
"%-20s %-6s %-5s %-12s %-12s %-12s %-12s\n",
500 "--------------------",
"------",
"-----",
"----------",
"------------",
"------------",
"-----------");
504 for (
int p = 0; p < 257; p++) {
513 for (
int p = 0; p < 257; p++) {
519 FormatNumber(pd->
tot, totalstr,
sizeof(totalstr));
520 double percent = (
long double)pd->
tot /
521 (
long double)total * 100;
524 "%-20s IPv4 %3d %12" PRIu64
" %12" PRIu64
" %12" PRIu64
525 " %12" PRIu64
" %12s %-6.2f\n",
527 (uint64_t)(pd->
tot / pd->
cnt), totalstr, percent);
532 for (
int p = 0; p < 257; p++) {
538 FormatNumber(pd->
tot, totalstr,
sizeof(totalstr));
539 double percent = (
long double)pd->
tot /
540 (
long double)total * 100;
543 "%-20s IPv6 %3d %12" PRIu64
" %12" PRIu64
" %12" PRIu64
544 " %12" PRIu64
" %12s %-6.2f\n",
546 (uint64_t)(pd->
tot / pd->
cnt), totalstr, percent);
552 for (
int p = 0; p < 257; p++) {
558 FormatNumber(pd->
tot, totalstr,
sizeof(totalstr));
559 fprintf(fp,
"%-20s IPv4 %3d %12"PRIu64
" %12"PRIu64
" %12"PRIu64
" %12"PRIu64
" %12s\n",
560 "Proto detect", p, pd->
cnt, pd->
min, pd->
max, (uint64_t)(pd->
tot / pd->
cnt), totalstr);
563 for (
int p = 0; p < 257; p++) {
569 FormatNumber(pd->
tot, totalstr,
sizeof(totalstr));
570 fprintf(fp,
"%-20s IPv6 %3d %12"PRIu64
" %12"PRIu64
" %12"PRIu64
" %12"PRIu64
" %12s\n",
571 "Proto detect", p, pd->
cnt, pd->
min, pd->
max, (uint64_t)(pd->
tot / pd->
cnt), totalstr);
577 for (
int p = 0; p < 257; p++) {
586 fprintf(fp,
"\n%-24s %-6s %-5s %-12s %-12s %-12s %-12s %-12s %-3s",
587 "Log Thread Module",
"IP ver",
"Proto",
"cnt",
"min",
"max",
"avg",
"tot",
"%%");
588 #ifdef PROFILE_LOCKING
589 fprintf(fp,
" %-10s %-10s %-12s %-12s %-10s %-10s %-12s %-12s\n",
590 "locks",
"ticks",
"cont.",
"cont.avg",
"slocks",
"sticks",
"scont.",
"scont.avg");
594 fprintf(fp,
"%-24s %-6s %-5s %-12s %-12s %-12s %-12s %-12s %-3s",
595 "------------------------",
"------",
"-----",
"----------",
"------------",
"------------",
"-----------",
"-----------",
"---");
596 #ifdef PROFILE_LOCKING
597 fprintf(fp,
" %-10s %-10s %-12s %-12s %-10s %-10s %-12s %-12s\n",
598 "--------",
"--------",
"----------",
"-----------",
"--------",
"--------",
"------------",
"-----------");
607 for (
int p = 0; p < 257; p++) {
620 for (
int p = 0; p < 257; p++) {
626 FormatNumber(pd->
tot, totalstr,
sizeof(totalstr));
627 double percent = (
long double)pd->
tot /
628 (
long double)total * 100;
630 fprintf(fp,
"%-24s IPv4 %3d %12"PRIu64
" %12"PRIu64
" %12"PRIu64
" %12"PRIu64
" %12s %6.2f",
632 #ifdef PROFILE_LOCKING
633 fprintf(fp,
" %10.2f %12"PRIu64
" %12"PRIu64
" %10.2f %10.2f %12"PRIu64
" %12"PRIu64
" %10.2f\n",
634 (
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);
645 for (
int p = 0; p < 257; p++) {
651 FormatNumber(pd->
tot, totalstr,
sizeof(totalstr));
652 double percent = (
long double)pd->
tot /
653 (
long double)total * 100;
655 fprintf(fp,
"%-24s IPv6 %3d %12"PRIu64
" %12"PRIu64
" %12"PRIu64
" %12"PRIu64
" %12s %6.2f\n",
660 fprintf(fp,
"\nLogger/output stats:\n");
664 for (
int p = 0; p < 256; p++) {
672 fprintf(fp,
"\n%-24s %-6s %-5s %-12s %-12s %-12s %-12s %-12s\n",
673 "Logger",
"IP ver",
"Proto",
"cnt",
"min",
"max",
"avg",
"tot");
674 fprintf(fp,
"%-24s %-6s %-5s %-12s %-12s %-12s %-12s %-12s\n",
675 "------------------------",
"------",
"-----",
"----------",
"------------",
"------------",
"-----------",
"-----------");
677 for (
int p = 0; p < 256; p++) {
683 FormatNumber(pd->
tot, totalstr,
sizeof(totalstr));
684 double percent = (
long double)pd->
tot /
685 (
long double)total * 100;
688 "%-24s IPv4 %3d %12" PRIu64
" %12" PRIu64
" %12" PRIu64
689 " %12" PRIu64
" %12s %-6.2f\n",
691 (uint64_t)(pd->
tot / pd->
cnt), totalstr, percent);
695 for (
int p = 0; p < 256; p++) {
701 FormatNumber(pd->
tot, totalstr,
sizeof(totalstr));
702 double percent = (
long double)pd->
tot /
703 (
long double)total * 100;
706 "%-24s IPv6 %3d %12" PRIu64
" %12" PRIu64
" %12" PRIu64
707 " %12" PRIu64
" %12s %-6.2f\n",
709 (uint64_t)(pd->
tot / pd->
cnt), totalstr, percent);
713 fprintf(fp,
"\nGeneral detection engine stats:\n");
717 for (
int p = 0; p < 257; p++) {
725 fprintf(fp,
"\n%-24s %-6s %-5s %-12s %-12s %-12s %-12s %-12s\n",
726 "Detection phase",
"IP ver",
"Proto",
"cnt",
"min",
"max",
"avg",
"tot");
727 fprintf(fp,
"%-24s %-6s %-5s %-12s %-12s %-12s %-12s %-12s\n",
728 "------------------------",
"------",
"-----",
"----------",
"------------",
"------------",
"-----------",
"-----------");
730 for (
int p = 0; p < 257; p++) {
736 FormatNumber(pd->
tot, totalstr,
sizeof(totalstr));
737 double percent = (
long double)pd->
tot /
738 (
long double)total * 100;
740 fprintf(fp,
"%-24s IPv4 %3d %12"PRIu64
" %12"PRIu64
" %12"PRIu64
" %12"PRIu64
" %12s %-6.2f\n",
745 for (
int p = 0; p < 257; p++) {
751 FormatNumber(pd->
tot, totalstr,
sizeof(totalstr));
752 double percent = (
long double)pd->
tot /
753 (
long double)total * 100;
755 fprintf(fp,
"%-24s IPv6 %3d %12"PRIu64
" %12"PRIu64
" %12"PRIu64
" %12"PRIu64
" %12s %-6.2f\n",
762 static void PrintCSVHeader(
void)
764 fprintf(packet_profile_csv_fp,
"pcap_cnt,total,receive,decode,flowworker,");
765 fprintf(packet_profile_csv_fp,
"threading,");
766 fprintf(packet_profile_csv_fp,
"proto detect,");
771 fprintf(packet_profile_csv_fp,
"loggers,");
783 fprintf(packet_profile_csv_fp,
"\n");
788 if (profiling_packets_csv_enabled == 0 || p == NULL ||
789 packet_profile_csv_fp == NULL || p->
profile == NULL) {
793 uint64_t tmm_total = 0;
794 uint64_t receive = 0;
799 fprintf(packet_profile_csv_fp,
"%"PRIu64
",%"PRIu64
",",
802 for (
int i = 0; i <
TMM_SIZE; i++) {
819 tmm_total += tmm_delta;
821 fprintf(packet_profile_csv_fp,
"%"PRIu64
",", receive);
822 fprintf(packet_profile_csv_fp,
"%"PRIu64
",", decode);
825 fprintf(packet_profile_csv_fp,
"%"PRIu64
",", delta - tmm_total);
828 uint64_t app_total = 0;
832 if (p->
proto == IPPROTO_TCP) {
844 ticks_spent -= app_total;
846 ticks_spent = app_total;
849 fprintf(packet_profile_csv_fp,
"%"PRIu64
",", ticks_spent);
853 uint64_t loggers = 0;
858 fprintf(packet_profile_csv_fp,
"%"PRIu64
",", loggers);
864 fprintf(packet_profile_csv_fp,
"%"PRIu64
",", pdt->
ticks_spent);
870 fprintf(packet_profile_csv_fp,
"%"PRIu64
",", pd->
ticks_spent);
873 fprintf(packet_profile_csv_fp,
"\n");
899 static void SCProfilingUpdatePacketDetectRecords(
Packet *p)
906 if (PacketIsIPv4(p)) {
907 SCProfilingUpdatePacketDetectRecord(i, p->
proto, pdt, 4);
909 SCProfilingUpdatePacketDetectRecord(i, p->
proto, pdt, 6);
915 static void SCProfilingUpdatePacketAppPdRecord(uint8_t ipproto, uint32_t ticks_spent,
int ipver)
923 if (pd->
min == 0 || ticks_spent < pd->min) {
924 pd->
min = ticks_spent;
926 if (pd->
max < ticks_spent) {
927 pd->
max = ticks_spent;
930 pd->
tot += ticks_spent;
934 static void SCProfilingUpdatePacketAppRecord(
int alproto, uint8_t ipproto,
PktProfilingAppData *pdt,
int ipver)
957 static void SCProfilingUpdatePacketAppRecords(
Packet *p)
964 if (PacketIsIPv4(p)) {
965 SCProfilingUpdatePacketAppRecord(i, p->
proto, pdt, 4);
967 SCProfilingUpdatePacketAppRecord(i, p->
proto, pdt, 6);
973 if (PacketIsIPv4(p)) {
994 if (pd->
min == 0 || delta < pd->min) {
997 if (pd->
max < delta) {
1001 pd->
tot += (uint64_t)delta;
1004 #ifdef PROFILE_LOCKING
1005 pd->lock += pdt->mutex_lock_cnt;
1006 pd->ticks += pdt->mutex_lock_wait_ticks;
1007 pd->contention += pdt->mutex_lock_contention;
1008 pd->slock += pdt->spin_lock_cnt;
1009 pd->sticks += pdt->spin_lock_wait_ticks;
1010 pd->scontention += pdt->spin_lock_contention;
1014 static void SCProfilingUpdatePacketTmmRecords(
Packet *p)
1024 if (PacketIsIPv4(p)) {
1025 SCProfilingUpdatePacketTmmRecord(i, p->
proto, pdt, 4);
1027 SCProfilingUpdatePacketTmmRecord(i, p->
proto, pdt, 6);
1032 static inline void SCProfilingUpdatePacketGenericRecord(
PktProfilingData *pdt,
1035 if (pdt == NULL || pd == NULL) {
1040 if (pd->
min == 0 || delta < pd->min) {
1043 if (pd->
max < delta) {
1055 for (i = 0; i < size; i++) {
1065 if (PacketIsIPv4(p)) {
1071 SCProfilingUpdatePacketGenericRecord(pdt, store);
1075 static void SCProfilingUpdatePacketLogRecord(
LoggerId id,
1099 static void SCProfilingUpdatePacketLogRecords(
Packet *p)
1105 if (PacketIsIPv4(p)) {
1106 SCProfilingUpdatePacketLogRecord(i, p->
proto, pdt, 4);
1108 SCProfilingUpdatePacketLogRecord(i, p->
proto, pdt, 6);
1116 if (p == NULL || p->
profile == NULL ||
1121 pthread_mutex_lock(&packet_profile_lock);
1124 if (PacketIsIPv4(p)) {
1128 if (pd->
min == 0 || delta < pd->min) {
1131 if (pd->
max < delta) {
1138 if (PacketIsTunnel(p)) {
1141 if (pd->
min == 0 || delta < pd->min) {
1144 if (pd->
max < delta) {
1155 SCProfilingUpdatePacketTmmRecords(p);
1156 SCProfilingUpdatePacketAppRecords(p);
1157 SCProfilingUpdatePacketDetectRecords(p);
1158 SCProfilingUpdatePacketLogRecords(p);
1160 }
else if (PacketIsIPv6(p)) {
1164 if (pd->
min == 0 || delta < pd->min) {
1167 if (pd->
max < delta) {
1174 if (PacketIsTunnel(p)) {
1177 if (pd->
min == 0 || delta < pd->min) {
1180 if (pd->
max < delta) {
1191 SCProfilingUpdatePacketTmmRecords(p);
1192 SCProfilingUpdatePacketAppRecords(p);
1193 SCProfilingUpdatePacketDetectRecords(p);
1194 SCProfilingUpdatePacketLogRecords(p);
1197 if (profiling_packets_csv_enabled)
1201 pthread_mutex_unlock(&packet_profile_lock);
1207 if (sample % rate == 0)
1215 #ifdef PROFILE_LOCKING
1226 if ((sample % rate) == 0) {
1233 #define CASE_CODE(E) case E: return #E
1311 ProfilingGenericTicksTest01(
void)
1313 #define TEST_RUNS 1024
1314 uint64_t ticks_start = 0;
1315 uint64_t ticks_end = 0;
1324 printf(
"malloc(1024) %"PRIu64
"\n", (ticks_end - ticks_start)/
TEST_RUNS);
1331 printf(
"SCFree(1024) %"PRIu64
"\n", (ticks_end - ticks_start)/
TEST_RUNS);
1340 printf(
"SCMutexInit() %"PRIu64
"\n", (ticks_end - ticks_start)/
TEST_RUNS);
1347 printf(
"SCMutexLock() %"PRIu64
"\n", (ticks_end - ticks_start)/
TEST_RUNS);
1354 printf(
"SCMutexUnlock() %"PRIu64
"\n", (ticks_end - ticks_start)/
TEST_RUNS);
1361 printf(
"SCMutexDestroy() %"PRIu64
"\n", (ticks_end - ticks_start)/
TEST_RUNS);
1370 printf(
"SCSpinInit() %"PRIu64
"\n", (ticks_end - ticks_start)/
TEST_RUNS);
1377 printf(
"SCSpinLock() %"PRIu64
"\n", (ticks_end - ticks_start)/
TEST_RUNS);
1384 printf(
"SCSpinUnlock() %"PRIu64
"\n", (ticks_end - ticks_start)/
TEST_RUNS);
1391 printf(
"SCSpinDestroy() %"PRIu64
"\n", (ticks_end - ticks_start)/
TEST_RUNS);
1399 printf(
"SC_ATOMIC_ADD %"PRIu64
"\n", (ticks_end - ticks_start)/
TEST_RUNS);
1406 printf(
"SC_ATOMIC_CAS %"PRIu64
"\n", (ticks_end - ticks_start)/
TEST_RUNS);
1416 UtRegisterTest(
"ProfilingGenericTicksTest01", ProfilingGenericTicksTest01);
1433 static uint64_t rate = 0;
1443 intmax_t rate_v = 0;
1446 (void)
ConfGetInt(
"profiling.sample-rate", &rate_v);
1447 if (rate_v > 0 && rate_v < INT_MAX) {
1448 int literal_rate = (int)rate_v;
1449 for (
int i = literal_rate; i >= 1; i--) {
1451 if ((i & (i - 1)) == 0) {
1457 SCLogInfo(
"profiling runs for every %luth packet", rate + 1);
1459 SCLogInfo(
"profiling runs for every packet");
1480 if ((sample & rate) == 0) {