merge from dev

This commit is contained in:
Daan Leijen 2025-03-01 18:05:46 -08:00
commit 96fb9fa812
2 changed files with 14 additions and 11 deletions

View file

@ -94,16 +94,17 @@ void __mi_stat_adjust_decrease(mi_stat_count_t* stat, size_t amount) {
// must be thread safe as it is called from stats_merge
static void mi_stat_add(mi_stat_count_t* stat, const mi_stat_count_t* src) {
if (stat==src) return;
if (src->total==0) return;
mi_atomic_addi64_relaxed( &stat->total, src->total);
mi_atomic_addi64_relaxed( &stat->current, src->current);
if (src->total!=0) { mi_atomic_addi64_relaxed(&stat->total, src->total); }
if (src->current!=0) { mi_atomic_addi64_relaxed(&stat->current, src->current); }
// peak scores do really not work across threads ... we use conservative max
mi_atomic_maxi64_relaxed( &stat->peak, src->peak); // or: mi_atomic_addi64_relaxed( &stat->peak, src->peak);
if (src->peak > stat->peak) {
mi_atomic_maxi64_relaxed(&stat->peak, src->peak); // or: mi_atomic_addi64_relaxed( &stat->peak, src->peak);
}
}
static void mi_stat_counter_add(mi_stat_counter_t* stat, const mi_stat_counter_t* src) {
if (stat==src) return;
mi_atomic_addi64_relaxed( &stat->total, src->total);
if (src->total!=0) { mi_atomic_addi64_relaxed(&stat->total, src->total); }
}
// must be thread safe as it is called from stats_merge
@ -143,9 +144,9 @@ static void mi_stats_add(mi_stats_t* stats, const mi_stats_t* src) {
mi_stat_counter_add(&stats->pages_unabandon_busy_wait, &src->pages_unabandon_busy_wait);
#if MI_STAT>1
for (size_t i = 0; i <= MI_BIN_HUGE; i++) {
if (src->normal_bins[i].total > 0) {
// if (src->normal_bins[i].total != 0 && src->normal_bins[i].current != 0) {
mi_stat_add(&stats->normal_bins[i], &src->normal_bins[i]);
}
//}
}
#endif
}

View file

@ -322,9 +322,6 @@ int main(int argc, char** argv) {
// mi_option_set(mi_option_purge_delay,-1);
mi_option_set(mi_option_page_reclaim_on_free, 0);
#endif
#ifndef USE_STD_MALLOC
mi_stats_reset();
#endif
// > mimalloc-test-stress [THREADS] [SCALE] [ITER]
if (argc >= 2) {
@ -346,6 +343,11 @@ int main(int argc, char** argv) {
allow_large_objects = true;
}
printf("Using %d threads with a %d%% load-per-thread and %d iterations %s\n", THREADS, SCALE, ITER, (allow_large_objects ? "(allow large objects)" : ""));
#if !defined(NDEBUG) && !defined(USE_STD_MALLOC)
mi_stats_reset();
#endif
//mi_reserve_os_memory(1024*1024*1024ULL, false, true);
//int res = mi_reserve_huge_os_pages(4,1);
//printf("(reserve huge: %i\n)", res);