Skip to content

Commit

Permalink
DEBUG statements for Mac and Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
inashivb committed Jun 11, 2024
1 parent 79bdd0a commit 00bf0d2
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/util-thash.c
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,11 @@ static int THashInitConfig(THashTableContext *ctx, const char *cnf_prefix)
HRLOCK_INIT(&ctx->array[i]);
}
(void)SC_ATOMIC_ADD(ctx->memuse, (ctx->config.hash_size * sizeof(THashHashRow)));
SCLogNotice("memuse: %" PRIu64, SC_ATOMIC_GET(ctx->memuse));
SCLogNotice("config->data_size: %u, thash_data_size: %" PRIu64, (ctx)->config.data_size,
(uint64_t)THASH_DATA_SIZE(ctx));
SCLogNotice("sizeof(THashHashRow): %lu", sizeof(THashHashRow));
SCLogNotice("memcap: %" PRIu64, ctx->config.memcap);

/* pre allocate prealloc */
for (i = 0; i < ctx->config.prealloc; i++) {
Expand Down Expand Up @@ -330,6 +335,7 @@ THashTableContext *THashInit(const char *cnf_prefix, size_t data_size,
ctx->config.memcap = reset_memcap ? UINT64_MAX : THASH_DEFAULT_MEMCAP;
}
#endif
SCLogNotice("memcap: %" PRIu64, ctx->config.memcap);
ctx->config.prealloc = THASH_DEFAULT_PREALLOC;

SC_ATOMIC_INIT(ctx->counter);
Expand Down Expand Up @@ -381,6 +387,7 @@ void THashShutdown(THashTableContext *ctx)
}
(void) SC_ATOMIC_SUB(ctx->memuse, ctx->config.hash_size * sizeof(THashHashRow));
THashDataQueueDestroy(&ctx->spare_q);
SCLogNotice("FINAL memuse: %" PRIu64, SC_ATOMIC_GET(ctx->memuse));
DEBUG_VALIDATE_BUG_ON(SC_ATOMIC_GET(ctx->memuse) != 0);
SCFree(ctx);
}
Expand Down Expand Up @@ -589,6 +596,13 @@ static THashData *THashDataGetNew(THashTableContext *ctx, void *data)
/* data is initialized (recycled) but *unlocked* */
/* the recycled data was THashData and again does not include
* the size of current data to be added */
SCLogNotice("memuse: %" PRIu64, SC_ATOMIC_GET(ctx->memuse));
SCLogNotice("config->data_size: %u, thash_data_size: %" PRIu64, (ctx)->config.data_size,
(uint64_t)THASH_DATA_SIZE(ctx));
SCLogNotice("sizeof(THashHashRow): %lu", sizeof(THashHashRow));
SCLogNotice("data_size: %u", data_size);
SCLogNotice("memuse + data_size: %" PRIu64, SC_ATOMIC_GET(ctx->memuse) + data_size);
SCLogNotice("memcap: %" PRIu64, ctx->config.memcap);
if (data_size > 0) {
/* Since it is prealloc'd data, it already has THashData in its memuse */
(void)SC_ATOMIC_ADD(ctx->memuse, data_size);
Expand All @@ -602,6 +616,7 @@ static THashData *THashDataGetNew(THashTableContext *ctx, void *data)
}
}

SCLogNotice("memuse: %" PRIu64, SC_ATOMIC_GET(ctx->memuse));
// setup the data
BUG_ON(ctx->config.DataSet(h->data, data) != 0);
(void) SC_ATOMIC_ADD(ctx->counter, 1);
Expand Down

0 comments on commit 00bf0d2

Please sign in to comment.