mirror of
https://github.com/microsoft/mimalloc.git
synced 2025-05-08 00:09:31 +03:00
merge from dev
This commit is contained in:
commit
30dfe97f5b
3 changed files with 26 additions and 18 deletions
|
@ -89,10 +89,11 @@ bool _mi_getenv(const char* name, char* result, size_t result_size);
|
||||||
// "options.c"
|
// "options.c"
|
||||||
void _mi_fputs(mi_output_fun* out, void* arg, const char* prefix, const char* message);
|
void _mi_fputs(mi_output_fun* out, void* arg, const char* prefix, const char* message);
|
||||||
void _mi_fprintf(mi_output_fun* out, void* arg, const char* fmt, ...);
|
void _mi_fprintf(mi_output_fun* out, void* arg, const char* fmt, ...);
|
||||||
|
void _mi_raw_message(const char* fmt, ...);
|
||||||
|
void _mi_message(const char* fmt, ...);
|
||||||
void _mi_warning_message(const char* fmt, ...);
|
void _mi_warning_message(const char* fmt, ...);
|
||||||
void _mi_verbose_message(const char* fmt, ...);
|
void _mi_verbose_message(const char* fmt, ...);
|
||||||
void _mi_trace_message(const char* fmt, ...);
|
void _mi_trace_message(const char* fmt, ...);
|
||||||
void _mi_output_message(const char* fmt, ...);
|
|
||||||
void _mi_options_init(void);
|
void _mi_options_init(void);
|
||||||
long _mi_option_get_fast(mi_option_t option);
|
long _mi_option_get_fast(mi_option_t option);
|
||||||
void _mi_error_message(int err, const char* fmt, ...);
|
void _mi_error_message(int err, const char* fmt, ...);
|
||||||
|
|
16
src/arena.c
16
src/arena.c
|
@ -1376,7 +1376,7 @@ static size_t mi_debug_show_page_bfield(mi_bfield_t field, char* buf, size_t* k,
|
||||||
}
|
}
|
||||||
|
|
||||||
static size_t mi_debug_show_chunks(const char* header1, const char* header2, const char* header3, size_t slice_count, size_t chunk_count, mi_bchunk_t* chunks, _Atomic(uint8_t)* chunk_bins, bool invert, mi_arena_t* arena, bool narrow) {
|
static size_t mi_debug_show_chunks(const char* header1, const char* header2, const char* header3, size_t slice_count, size_t chunk_count, mi_bchunk_t* chunks, _Atomic(uint8_t)* chunk_bins, bool invert, mi_arena_t* arena, bool narrow) {
|
||||||
_mi_output_message("\x1B[37m%s%s%s (use/commit: \x1B[31m0 - 25%%\x1B[33m - 50%%\x1B[36m - 75%%\x1B[32m - 100%%\x1B[0m)\n", header1, header2, header3);
|
_mi_raw_message("\x1B[37m%s%s%s (use/commit: \x1B[31m0 - 25%%\x1B[33m - 50%%\x1B[36m - 75%%\x1B[32m - 100%%\x1B[0m)\n", header1, header2, header3);
|
||||||
const size_t fields_per_line = (narrow ? 2 : 4);
|
const size_t fields_per_line = (narrow ? 2 : 4);
|
||||||
size_t bit_count = 0;
|
size_t bit_count = 0;
|
||||||
size_t bit_set_count = 0;
|
size_t bit_set_count = 0;
|
||||||
|
@ -1407,7 +1407,7 @@ static size_t mi_debug_show_chunks(const char* header1, const char* header2, con
|
||||||
for (size_t j = 0; j < MI_BCHUNK_FIELDS; j++) {
|
for (size_t j = 0; j < MI_BCHUNK_FIELDS; j++) {
|
||||||
if (j > 0 && (j % fields_per_line) == 0) {
|
if (j > 0 && (j % fields_per_line) == 0) {
|
||||||
// buf[k++] = '\n'; _mi_memset(buf+k,' ',7); k += 7;
|
// buf[k++] = '\n'; _mi_memset(buf+k,' ',7); k += 7;
|
||||||
_mi_output_message(" %s\n\x1B[37m", buf);
|
_mi_raw_message(" %s\n\x1B[37m", buf);
|
||||||
_mi_memzero(buf, sizeof(buf));
|
_mi_memzero(buf, sizeof(buf));
|
||||||
_mi_memset(buf, ' ', 5); k = 5;
|
_mi_memset(buf, ' ', 5); k = 5;
|
||||||
}
|
}
|
||||||
|
@ -1426,9 +1426,9 @@ static size_t mi_debug_show_chunks(const char* header1, const char* header2, con
|
||||||
}
|
}
|
||||||
bit_count += MI_BFIELD_BITS;
|
bit_count += MI_BFIELD_BITS;
|
||||||
}
|
}
|
||||||
_mi_output_message(" %s\n\x1B[37m", buf);
|
_mi_raw_message(" %s\n\x1B[37m", buf);
|
||||||
}
|
}
|
||||||
_mi_output_message("\x1B[0m total ('x'): %zu\n", bit_set_count);
|
_mi_raw_message("\x1B[0m total ('x'): %zu\n", bit_set_count);
|
||||||
return bit_set_count;
|
return bit_set_count;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1448,7 +1448,7 @@ static void mi_debug_show_arenas_ex(bool show_pages, bool narrow) mi_attr_noexce
|
||||||
if (arena == NULL) break;
|
if (arena == NULL) break;
|
||||||
mi_assert(arena->subproc == subproc);
|
mi_assert(arena->subproc == subproc);
|
||||||
// slice_total += arena->slice_count;
|
// slice_total += arena->slice_count;
|
||||||
_mi_output_message("arena %zu at %p: %zu slices (%zu MiB)%s, subproc: %p\n", i, arena, arena->slice_count, mi_size_of_slices(arena->slice_count)/MI_MiB, (arena->memid.is_pinned ? ", pinned" : ""), arena->subproc);
|
_mi_raw_message("arena %zu at %p: %zu slices (%zu MiB)%s, subproc: %p\n", i, arena, arena->slice_count, mi_size_of_slices(arena->slice_count)/MI_MiB, (arena->memid.is_pinned ? ", pinned" : ""), arena->subproc);
|
||||||
//if (show_inuse) {
|
//if (show_inuse) {
|
||||||
// free_total += mi_debug_show_bbitmap("in-use slices", arena->slice_count, arena->slices_free, true, NULL);
|
// free_total += mi_debug_show_bbitmap("in-use slices", arena->slice_count, arena->slices_free, true, NULL);
|
||||||
//}
|
//}
|
||||||
|
@ -1466,9 +1466,9 @@ static void mi_debug_show_arenas_ex(bool show_pages, bool narrow) mi_attr_noexce
|
||||||
page_total += mi_debug_show_bitmap_binned(header1, header2, header3, arena->slice_count, arena->pages, arena->slices_free->chunk_bins, false, arena, narrow);
|
page_total += mi_debug_show_bitmap_binned(header1, header2, header3, arena->slice_count, arena->pages, arena->slices_free->chunk_bins, false, arena, narrow);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// if (show_inuse) _mi_output_message("total inuse slices : %zu\n", slice_total - free_total);
|
// if (show_inuse) _mi_raw_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_raw_message("total abandoned slices: %zu\n", abandoned_total);
|
||||||
if (show_pages) _mi_output_message("total pages in arenas: %zu\n", page_total);
|
if (show_pages) _mi_raw_message("total pages in arenas: %zu\n", page_total);
|
||||||
}
|
}
|
||||||
|
|
||||||
void mi_debug_show_arenas(void) mi_attr_noexcept {
|
void mi_debug_show_arenas(void) mi_attr_noexcept {
|
||||||
|
|
|
@ -202,7 +202,7 @@ void _mi_options_init(void) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
mi_options_print();
|
if (!mi_option_is_enabled(mi_option_verbose)) { mi_options_print(); }
|
||||||
}
|
}
|
||||||
|
|
||||||
#define mi_stringifyx(str) #str // and stringify
|
#define mi_stringifyx(str) #str // and stringify
|
||||||
|
@ -214,7 +214,7 @@ void mi_options_print(void) mi_attr_noexcept
|
||||||
const int vermajor = MI_MALLOC_VERSION/100;
|
const int vermajor = MI_MALLOC_VERSION/100;
|
||||||
const int verminor = (MI_MALLOC_VERSION%100)/10;
|
const int verminor = (MI_MALLOC_VERSION%100)/10;
|
||||||
const int verpatch = (MI_MALLOC_VERSION%10);
|
const int verpatch = (MI_MALLOC_VERSION%10);
|
||||||
_mi_verbose_message("v%i.%i.%i%s%s (built on %s, %s)\n", vermajor, verminor, verpatch,
|
_mi_message("v%i.%i.%i%s%s (built on %s, %s)\n", vermajor, verminor, verpatch,
|
||||||
#if defined(MI_CMAKE_BUILD_TYPE)
|
#if defined(MI_CMAKE_BUILD_TYPE)
|
||||||
", " mi_stringify(MI_CMAKE_BUILD_TYPE)
|
", " mi_stringify(MI_CMAKE_BUILD_TYPE)
|
||||||
#else
|
#else
|
||||||
|
@ -233,18 +233,18 @@ void mi_options_print(void) mi_attr_noexcept
|
||||||
mi_option_t option = (mi_option_t)i;
|
mi_option_t option = (mi_option_t)i;
|
||||||
long l = mi_option_get(option); MI_UNUSED(l); // possibly initialize
|
long l = mi_option_get(option); MI_UNUSED(l); // possibly initialize
|
||||||
mi_option_desc_t* desc = &options[option];
|
mi_option_desc_t* desc = &options[option];
|
||||||
_mi_verbose_message("option '%s': %ld %s\n", desc->name, desc->value, (mi_option_has_size_in_kib(option) ? "KiB" : ""));
|
_mi_message("option '%s': %ld %s\n", desc->name, desc->value, (mi_option_has_size_in_kib(option) ? "KiB" : ""));
|
||||||
}
|
}
|
||||||
|
|
||||||
// show build configuration
|
// show build configuration
|
||||||
_mi_verbose_message("debug level : %d\n", MI_DEBUG );
|
_mi_message("debug level : %d\n", MI_DEBUG );
|
||||||
_mi_verbose_message("secure level: %d\n", MI_SECURE );
|
_mi_message("secure level: %d\n", MI_SECURE );
|
||||||
_mi_verbose_message("mem tracking: %s\n", MI_TRACK_TOOL);
|
_mi_message("mem tracking: %s\n", MI_TRACK_TOOL);
|
||||||
#if MI_GUARDED
|
#if MI_GUARDED
|
||||||
_mi_verbose_message("guarded build: %s\n", mi_option_get(mi_option_guarded_sample_rate) != 0 ? "enabled" : "disabled");
|
_mi_message("guarded build: %s\n", mi_option_get(mi_option_guarded_sample_rate) != 0 ? "enabled" : "disabled");
|
||||||
#endif
|
#endif
|
||||||
#if MI_TSAN
|
#if MI_TSAN
|
||||||
_mi_verbose_message("thread santizer enabled\n");
|
_mi_message("thread santizer enabled\n");
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -495,13 +495,20 @@ static void mi_vfprintf_thread(mi_output_fun* out, void* arg, const char* prefix
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void _mi_output_message(const char* fmt, ...) {
|
void _mi_raw_message(const char* fmt, ...) {
|
||||||
va_list args;
|
va_list args;
|
||||||
va_start(args, fmt);
|
va_start(args, fmt);
|
||||||
mi_vfprintf(NULL, NULL, NULL, fmt, args);
|
mi_vfprintf(NULL, NULL, NULL, fmt, args);
|
||||||
va_end(args);
|
va_end(args);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void _mi_message(const char* fmt, ...) {
|
||||||
|
va_list args;
|
||||||
|
va_start(args, fmt);
|
||||||
|
mi_vfprintf_thread(NULL, NULL, "mimalloc: ", fmt, args);
|
||||||
|
va_end(args);
|
||||||
|
}
|
||||||
|
|
||||||
void _mi_trace_message(const char* fmt, ...) {
|
void _mi_trace_message(const char* fmt, ...) {
|
||||||
if (mi_option_get(mi_option_verbose) <= 1) return; // only with verbose level 2 or higher
|
if (mi_option_get(mi_option_verbose) <= 1) return; // only with verbose level 2 or higher
|
||||||
va_list args;
|
va_list args;
|
||||||
|
|
Loading…
Add table
Reference in a new issue