mirror of
https://github.com/microsoft/mimalloc.git
synced 2025-05-06 15:29:31 +03:00
nicer debug output
This commit is contained in:
parent
b53ac835f1
commit
e43eb1f191
3 changed files with 15 additions and 12 deletions
|
@ -276,7 +276,7 @@ mi_decl_export int mi_reserve_huge_os_pages_at(size_t pages, int numa_node, size
|
||||||
mi_decl_export int mi_reserve_os_memory(size_t size, bool commit, bool allow_large) mi_attr_noexcept;
|
mi_decl_export int mi_reserve_os_memory(size_t size, bool commit, bool allow_large) mi_attr_noexcept;
|
||||||
mi_decl_export bool mi_manage_os_memory(void* start, size_t size, bool is_committed, bool is_large, bool is_zero, int numa_node) mi_attr_noexcept;
|
mi_decl_export bool mi_manage_os_memory(void* start, size_t size, bool is_committed, bool is_large, bool is_zero, int numa_node) mi_attr_noexcept;
|
||||||
|
|
||||||
mi_decl_export void mi_debug_show_arenas(bool show_inuse, bool show_abandoned, bool show_purge) mi_attr_noexcept;
|
mi_decl_export void mi_debug_show_arenas(bool show_inuse, bool show_committed, bool show_pages) mi_attr_noexcept;
|
||||||
|
|
||||||
// Experimental: heaps associated with specific memory arena's
|
// Experimental: heaps associated with specific memory arena's
|
||||||
typedef int mi_arena_id_t;
|
typedef int mi_arena_id_t;
|
||||||
|
|
23
src/arena.c
23
src/arena.c
|
@ -1212,7 +1212,7 @@ static size_t mi_debug_show_page_bfield(mi_bfield_t field, char* buf, mi_arena_t
|
||||||
char c = 'p';
|
char c = 'p';
|
||||||
if (mi_page_is_abandoned_mapped(page)) { c = 'a'; }
|
if (mi_page_is_abandoned_mapped(page)) { c = 'a'; }
|
||||||
else if (mi_page_is_abandoned(page)) { c = 'f'; }
|
else if (mi_page_is_abandoned(page)) { c = 'f'; }
|
||||||
bit_of_page = (long)page->memid.mem.arena.slice_count - 1;
|
bit_of_page = (long)page->memid.mem.arena.slice_count;
|
||||||
buf[bit] = c;
|
buf[bit] = c;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -1265,13 +1265,12 @@ static size_t mi_debug_show_bitmap(const char* header, size_t slice_count, mi_bi
|
||||||
return bit_set_count;
|
return bit_set_count;
|
||||||
}
|
}
|
||||||
|
|
||||||
void mi_debug_show_arenas(bool show_inuse, bool show_abandoned, bool show_purge) mi_attr_noexcept {
|
void mi_debug_show_arenas(bool show_inuse, bool show_committed, bool show_pages) mi_attr_noexcept {
|
||||||
MI_UNUSED(show_abandoned);
|
|
||||||
size_t max_arenas = mi_arena_get_count();
|
size_t max_arenas = mi_arena_get_count();
|
||||||
size_t free_total = 0;
|
size_t free_total = 0;
|
||||||
size_t slice_total = 0;
|
size_t slice_total = 0;
|
||||||
//size_t abandoned_total = 0;
|
//size_t abandoned_total = 0;
|
||||||
size_t purge_total = 0;
|
size_t page_total = 0;
|
||||||
for (size_t i = 0; i < max_arenas; i++) {
|
for (size_t i = 0; i < max_arenas; i++) {
|
||||||
mi_arena_t* arena = mi_atomic_load_ptr_acquire(mi_arena_t, &mi_arenas[i]);
|
mi_arena_t* arena = mi_atomic_load_ptr_acquire(mi_arena_t, &mi_arenas[i]);
|
||||||
if (arena == NULL) break;
|
if (arena == NULL) break;
|
||||||
|
@ -1280,16 +1279,20 @@ void mi_debug_show_arenas(bool show_inuse, bool show_abandoned, bool show_purge)
|
||||||
if (show_inuse) {
|
if (show_inuse) {
|
||||||
free_total += mi_debug_show_bitmap("in-use slices", arena->slice_count, arena->slices_free, true, NULL);
|
free_total += mi_debug_show_bitmap("in-use slices", arena->slice_count, arena->slices_free, true, NULL);
|
||||||
}
|
}
|
||||||
mi_debug_show_bitmap("committed slices", arena->slice_count, arena->slices_committed, false, NULL);
|
if (show_committed) {
|
||||||
// todo: abandoned slices
|
mi_debug_show_bitmap("committed slices", arena->slice_count, arena->slices_committed, false, NULL);
|
||||||
if (show_purge) {
|
}
|
||||||
purge_total += mi_debug_show_bitmap("purgeable slices", arena->slice_count, arena->slices_purge, false, NULL);
|
// todo: abandoned slices
|
||||||
|
//if (show_purge) {
|
||||||
|
// purge_total += mi_debug_show_bitmap("purgeable slices", arena->slice_count, arena->slices_purge, false, NULL);
|
||||||
|
//}
|
||||||
|
if (show_pages) {
|
||||||
|
page_total += mi_debug_show_bitmap("pages (p=page, a=abandoned, f=full-abandoned, i=info, m=meta)", arena->slice_count, arena->pages, false, arena);
|
||||||
}
|
}
|
||||||
mi_debug_show_bitmap("pages (p=page, a=abandoned, f=full-abandoned, i=info, m=meta)", arena->slice_count, arena->pages, false, arena);
|
|
||||||
}
|
}
|
||||||
if (show_inuse) _mi_output_message("total inuse slices : %zu\n", slice_total - free_total);
|
if (show_inuse) _mi_output_message("total inuse slices : %zu\n", slice_total - free_total);
|
||||||
// if (show_abandoned) _mi_verbose_message("total abandoned slices: %zu\n", abandoned_total);
|
// if (show_abandoned) _mi_verbose_message("total abandoned slices: %zu\n", abandoned_total);
|
||||||
if (show_purge) _mi_output_message("total purgeable slices: %zu\n", purge_total);
|
if (show_pages) _mi_output_message("total pages in areanas: %zu\n", page_total);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1220,7 +1220,7 @@ mi_decl_nodiscard bool mi_bitmap_try_find_and_clearN_(mi_bitmap_t* bitmap, size_
|
||||||
typedef struct mi_claim_fun_data_s {
|
typedef struct mi_claim_fun_data_s {
|
||||||
mi_arena_t* arena;
|
mi_arena_t* arena;
|
||||||
mi_subproc_t* subproc;
|
mi_subproc_t* subproc;
|
||||||
int heap_tag;
|
mi_heaptag_t heap_tag;
|
||||||
} mi_claim_fun_data_t;
|
} mi_claim_fun_data_t;
|
||||||
|
|
||||||
static bool mi_bitmap_try_find_and_claim_visit(mi_bitmap_t* bitmap, size_t chunk_idx, size_t n, size_t* pidx, void* arg1, void* arg2)
|
static bool mi_bitmap_try_find_and_claim_visit(mi_bitmap_t* bitmap, size_t chunk_idx, size_t n, size_t* pidx, void* arg1, void* arg2)
|
||||||
|
|
Loading…
Add table
Reference in a new issue