fix statistics accounting of huge pages
This commit is contained in:
parent
ff9f29660b
commit
28d4ec4c5a
10
src/alloc.c
10
src/alloc.c
@ -192,7 +192,15 @@ static mi_decl_noinline void _mi_free_block_mt(mi_page_t* page, mi_block_t* bloc
|
|||||||
page->free = block;
|
page->free = block;
|
||||||
page->used--;
|
page->used--;
|
||||||
page->is_zero = false;
|
page->is_zero = false;
|
||||||
_mi_segment_page_free(page,true,&heap->tld->segments);
|
mi_assert(page->used == 0);
|
||||||
|
mi_tld_t* tld = heap->tld;
|
||||||
|
if (page->block_size > MI_HUGE_OBJ_SIZE_MAX) {
|
||||||
|
_mi_stat_decrease(&tld->stats.giant, page->block_size);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
_mi_stat_decrease(&tld->stats.huge, page->block_size);
|
||||||
|
}
|
||||||
|
_mi_segment_page_free(page,true,&tld->segments);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -370,6 +370,7 @@ void _mi_page_free(mi_page_t* page, mi_page_queue_t* pq, bool force) {
|
|||||||
mi_page_set_has_aligned(page, false);
|
mi_page_set_has_aligned(page, false);
|
||||||
|
|
||||||
// account for huge pages here
|
// account for huge pages here
|
||||||
|
// (note: no longer necessary as huge pages are always abandoned)
|
||||||
if (page->block_size > MI_LARGE_OBJ_SIZE_MAX) {
|
if (page->block_size > MI_LARGE_OBJ_SIZE_MAX) {
|
||||||
if (page->block_size > MI_HUGE_OBJ_SIZE_MAX) {
|
if (page->block_size > MI_HUGE_OBJ_SIZE_MAX) {
|
||||||
_mi_stat_decrease(&page->heap->tld->stats.giant, page->block_size);
|
_mi_stat_decrease(&page->heap->tld->stats.giant, page->block_size);
|
||||||
|
@ -158,6 +158,7 @@ int main(int argc, char** argv) {
|
|||||||
//printf("(reserve huge: %i\n)", res);
|
//printf("(reserve huge: %i\n)", res);
|
||||||
|
|
||||||
//bench_start_program();
|
//bench_start_program();
|
||||||
|
mi_stats_reset();
|
||||||
memset((void*)transfer, 0, TRANSFERS*sizeof(void*));
|
memset((void*)transfer, 0, TRANSFERS*sizeof(void*));
|
||||||
run_os_threads(THREADS);
|
run_os_threads(THREADS);
|
||||||
for (int i = 0; i < TRANSFERS; i++) {
|
for (int i = 0; i < TRANSFERS; i++) {
|
||||||
@ -165,7 +166,6 @@ int main(int argc, char** argv) {
|
|||||||
}
|
}
|
||||||
#ifndef NDEBUG
|
#ifndef NDEBUG
|
||||||
mi_collect(false);
|
mi_collect(false);
|
||||||
mi_collect(true);
|
|
||||||
#endif
|
#endif
|
||||||
mi_stats_print(NULL);
|
mi_stats_print(NULL);
|
||||||
//bench_end_program();
|
//bench_end_program();
|
||||||
@ -191,6 +191,11 @@ static void run_os_threads(size_t nthreads) {
|
|||||||
for (size_t i = 0; i < nthreads; i++) {
|
for (size_t i = 0; i < nthreads; i++) {
|
||||||
WaitForSingleObject(thandles[i], INFINITE);
|
WaitForSingleObject(thandles[i], INFINITE);
|
||||||
}
|
}
|
||||||
|
for (size_t i = 0; i < nthreads; i++) {
|
||||||
|
CloseHandle(thandles[i]);
|
||||||
|
}
|
||||||
|
free(tids);
|
||||||
|
free(thandles);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void* atomic_exchange_ptr(volatile void** p, void* newval) {
|
static void* atomic_exchange_ptr(volatile void** p, void* newval) {
|
||||||
|
Loading…
Reference in New Issue
Block a user