Skip to content

Commit b0675c7

Browse files
committed
add comment for pr #1112
1 parent 7ec2de9 commit b0675c7

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

src/stats.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -86,10 +86,14 @@ 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-
90-
int64_t prev_current = mi_atomic_addi64_relaxed(&stat->current, src->current);
91-
92-
// global current plus thread peak approximates new global peak
89+
const int64_t prev_current = mi_atomic_addi64_relaxed(&stat->current, src->current);
90+
91+
// Global current plus thread peak approximates new global peak
92+
// note: peak scores do really not work across threads.
93+
// we used to just add them together but that often overestimates in practice.
94+
// similarly, max does not seem to work well. The current approach
95+
// by Artem Kharytoniuk (@artem-lunarg) seems to work better, see PR#1112
96+
// for a longer description.
9397
mi_atomic_maxi64_relaxed(&stat->peak, prev_current + src->peak);
9498
}
9599

0 commit comments

Comments
 (0)