Skip to content

Commit d09f72e

Browse files
committed
new approximation for merged peak stats
1 parent 189b0ac commit d09f72e

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/stats.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -86,11 +86,11 @@ void _mi_stat_adjust_decrease(mi_stat_count_t* stat, size_t amount) {
8686
static void mi_stat_count_add_mt(mi_stat_count_t* stat, const mi_stat_count_t* src) {
8787
if (stat==src) return;
8888
mi_atomic_void_addi64_relaxed(&stat->total, &src->total);
89-
mi_atomic_void_addi64_relaxed(&stat->current, &src->current);
90-
// peak scores do really not work across threads .. we just add them
91-
mi_atomic_void_addi64_relaxed( &stat->peak, &src->peak);
92-
// or, take the max?
93-
// mi_atomic_maxi64_relaxed(&stat->peak, src->peak);
89+
90+
int64_t prev_current = mi_atomic_addi64_relaxed(&stat->current, src->current);
91+
92+
// global current plus thread peak approximates new global peak
93+
mi_atomic_maxi64_relaxed(&stat->peak, prev_current + src->peak);
9494
}
9595

9696
static void mi_stat_counter_add_mt(mi_stat_counter_t* stat, const mi_stat_counter_t* src) {

0 commit comments

Comments
 (0)