Skip to content

Commit 1f3a03e

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

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/stats.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,11 +86,16 @@ 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);
89+
90+
int64_t prev_current = mi_atomic_addi64_relaxed(&stat->current, src->current);
91+
9092
// peak scores do really not work across threads .. we just add them
91-
mi_atomic_void_addi64_relaxed( &stat->peak, &src->peak);
93+
//mi_atomic_void_addi64_relaxed( &stat->peak, &src->peak);
9294
// or, take the max?
9395
// mi_atomic_maxi64_relaxed(&stat->peak, src->peak);
96+
97+
// global current plus thread peak approximates new global peak
98+
mi_atomic_maxi64_relaxed(&stat->peak, prev_current + src->peak);
9499
}
95100

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

0 commit comments

Comments
 (0)