Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion include/mimalloc/internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,10 @@ typedef struct mi_option_desc_s {
#define MI_UNUSED_RELEASE(x) MI_UNUSED(x)
#endif

#define MI_INIT4(x) x(),x(),x(),x()
#define MI_INIT2(x) x(),x()
#define MI_INIT3(x) MI_INIT2(x),x()
#define MI_INIT4(x) MI_INIT2(x),MI_INIT2(x)
#define MI_INIT6(x) MI_INIT4(x),MI_INIT2(x)
#define MI_INIT8(x) MI_INIT4(x),MI_INIT4(x)
#define MI_INIT16(x) MI_INIT8(x),MI_INIT8(x)
#define MI_INIT32(x) MI_INIT16(x),MI_INIT16(x)
Expand Down
19 changes: 9 additions & 10 deletions src/init.c
Original file line number Diff line number Diff line change
Expand Up @@ -64,23 +64,22 @@ const mi_page_t _mi_page_empty = {
QNULL(MI_LARGE_MAX_OBJ_WSIZE + 1 /* 655360, Huge queue */), \
QNULL(MI_LARGE_MAX_OBJ_WSIZE + 2) /* Full queue */ }

#define MI_STAT_COUNT_NULL() {0,0,0}
#define MI_STAT_COUNT_NULL() {0,0,0}
#define MI_STAT_COUNTER_NULL() {0}

// Empty statistics
#define MI_STATS_NULL \
MI_STAT_COUNT_NULL(), MI_STAT_COUNT_NULL(), MI_STAT_COUNT_NULL(), \
{ 0 }, { 0 }, \
MI_STAT_COUNT_NULL(), MI_STAT_COUNT_NULL(), MI_STAT_COUNT_NULL(), \
MI_STAT_COUNT_NULL(), MI_STAT_COUNT_NULL(), MI_STAT_COUNT_NULL(), \
{ 0 }, { 0 }, { 0 }, { 0 }, \
{ 0 }, { 0 }, { 0 }, { 0 }, \
MI_INIT3(MI_STAT_COUNT_NULL), \
MI_INIT2(MI_STAT_COUNTER_NULL), \
MI_INIT6(MI_STAT_COUNT_NULL), \
MI_INIT8(MI_STAT_COUNTER_NULL), \
\
{ 0 }, { 0 }, { 0 }, { 0 }, { 0 }, { 0 }, \
MI_INIT6(MI_STAT_COUNTER_NULL), \
MI_INIT5(MI_STAT_COUNT_NULL), \
{ 0 }, { 0 }, { 0 }, { 0 }, \
MI_INIT4(MI_STAT_COUNTER_NULL), \
\
{ MI_INIT4(MI_STAT_COUNT_NULL) }, \
{ { 0 }, { 0 }, { 0 }, { 0 } }, \
{ MI_INIT4(MI_STAT_COUNTER_NULL) }, \
\
{ MI_INIT74(MI_STAT_COUNT_NULL) }, \
{ MI_INIT74(MI_STAT_COUNT_NULL) }, \
Expand Down
56 changes: 28 additions & 28 deletions src/stats.c
Original file line number Diff line number Diff line change
Expand Up @@ -192,10 +192,10 @@ static void mi_stat_print_ex(const mi_stat_count_t* stat, const char* msg, int64
mi_print_count(stat->total, unit, out, arg);
}
else {
mi_print_amount(stat->peak, -1, out, arg);
mi_print_amount(stat->total, -1, out, arg);
// mi_print_amount(stat->freed, -1, out, arg);
mi_print_amount(stat->current, -1, out, arg);
mi_print_amount(stat->peak, -unit, out, arg);
mi_print_amount(stat->total, -unit, out, arg);
// mi_print_amount(stat->freed, -unit, out, arg);
mi_print_amount(stat->current, -unit, out, arg);
if (unit == -1) {
_mi_fprintf(out, arg, "%24s", "");
}
Expand All @@ -214,10 +214,10 @@ static void mi_stat_print_ex(const mi_stat_count_t* stat, const char* msg, int64
}
}
else {
mi_print_amount(stat->peak, 1, out, arg);
mi_print_amount(stat->total, 1, out, arg);
mi_print_amount(stat->peak, unit, out, arg);
mi_print_amount(stat->total, unit, out, arg);
_mi_fprintf(out, arg, "%11s", " "); // no freed
mi_print_amount(stat->current, 1, out, arg);
mi_print_amount(stat->current, unit, out, arg);
_mi_fprintf(out, arg, "\n");
}
}
Expand All @@ -235,9 +235,9 @@ static void mi_stat_total_print(const mi_stat_count_t* stat, const char* msg, in
}
#endif

static void mi_stat_counter_print(const mi_stat_counter_t* stat, const char* msg, mi_output_fun* out, void* arg ) {
static void mi_stat_counter_print_ex(const mi_stat_counter_t* stat, const char* msg, const int64_t unit, mi_output_fun* out, void* arg ) {
_mi_fprintf(out, arg, " %-10s:", msg);
mi_print_amount(stat->total, -1, out, arg);
mi_print_amount(stat->total, unit, out, arg);
_mi_fprintf(out, arg, "\n");
}

Expand Down Expand Up @@ -373,12 +373,12 @@ void _mi_stats_print(const char* name, size_t id, mi_stats_t* stats, mi_output_f
// mi_stat_print(&stats->segments_cache, "-cached", -1, out, arg);
mi_stat_print(&stats->pages, "pages", -1, out, arg);
mi_stat_print(&stats->pages_abandoned, "abandoned", -1, out, arg);
mi_stat_counter_print(&stats->pages_reclaim_on_alloc, "reclaima", out, arg);
mi_stat_counter_print(&stats->pages_reclaim_on_free, "reclaimf", out, arg);
mi_stat_counter_print(&stats->pages_reabandon_full, "reabandon", out, arg);
mi_stat_counter_print(&stats->pages_unabandon_busy_wait, "waits", out, arg);
mi_stat_counter_print(&stats->pages_extended, "extended", out, arg);
mi_stat_counter_print(&stats->pages_retire, "retire", out, arg);
mi_stat_counter_print_ex(&stats->pages_reclaim_on_alloc, "reclaima", 0, out, arg);
mi_stat_counter_print_ex(&stats->pages_reclaim_on_free, "reclaimf", 0,out, arg);
mi_stat_counter_print_ex(&stats->pages_reabandon_full, "reabandon", 0, out, arg);
mi_stat_counter_print_ex(&stats->pages_unabandon_busy_wait, "waits", 0, out, arg);
mi_stat_counter_print_ex(&stats->pages_extended, "extended", 0, out, arg);
mi_stat_counter_print_ex(&stats->pages_retire, "retire", 0, out, arg);
mi_stat_average_print(stats->page_searches_count.total, stats->page_searches.total, "searches", out, arg);
_mi_fprintf(out, arg, "\n");
}
Expand All @@ -387,25 +387,25 @@ void _mi_stats_print(const char* name, size_t id, mi_stats_t* stats, mi_output_f
mi_print_header("arenas", out, arg);
mi_stat_print_ex(&stats->reserved, "reserved", 1, out, arg, "");
mi_stat_print_ex(&stats->committed, "committed", 1, out, arg, "");
mi_stat_counter_print(&stats->reset, "reset", out, arg);
mi_stat_counter_print(&stats->purged, "purged", out, arg);

mi_stat_counter_print(&stats->arena_count, "arenas", out, arg);
mi_stat_counter_print(&stats->arena_rollback_count, "rollback", out, arg);
mi_stat_counter_print(&stats->mmap_calls, "mmaps", out, arg);
mi_stat_counter_print(&stats->commit_calls, "commits", out, arg);
mi_stat_counter_print(&stats->reset_calls, "resets", out, arg);
mi_stat_counter_print(&stats->purge_calls, "purges", out, arg);
mi_stat_counter_print(&stats->malloc_guarded_count, "guarded", out, arg);
mi_stat_print_ex(&stats->heaps, "heaps", -1, out, arg, "");
mi_stat_counter_print_ex(&stats->reset, "reset", 1, out, arg);
mi_stat_counter_print_ex(&stats->purged, "purged", 1, out, arg);

mi_stat_counter_print_ex(&stats->arena_count, "arenas", 0, out, arg);
mi_stat_counter_print_ex(&stats->arena_rollback_count, "rollback", 0, out, arg);
mi_stat_counter_print_ex(&stats->mmap_calls, "mmaps", 0, out, arg);
mi_stat_counter_print_ex(&stats->commit_calls, "commits", 0, out, arg);
mi_stat_counter_print_ex(&stats->reset_calls, "resets", 0, out, arg);
mi_stat_counter_print_ex(&stats->purge_calls, "purges", 0, out, arg);
mi_stat_counter_print_ex(&stats->malloc_guarded_count, "guarded", 0, out, arg);
mi_stat_print_ex(&stats->heaps, "heaps", 0, out, arg, "");
_mi_fprintf(out, arg, "\n");

mi_print_header("process", out, arg);
mi_stat_print_ex(&stats->threads, "threads", -1, out, arg, "");
mi_stat_print_ex(&stats->threads, "threads", 0, out, arg, "");
_mi_fprintf(out, arg, " %-10s: %5i\n", "numa nodes", _mi_os_numa_node_count());
mi_process_info_print_out(out, arg);
_mi_fprintf(out, arg, "\n");
}
_mi_fprintf(out, arg, "\n");
}


Expand Down