Skip to content

New approximation for merged peak stats #1112

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions src/stats.c
Original file line number Diff line number Diff line change
Expand Up @@ -86,11 +86,16 @@ void _mi_stat_adjust_decrease(mi_stat_count_t* stat, size_t amount) {
static void mi_stat_count_add_mt(mi_stat_count_t* stat, const mi_stat_count_t* src) {
if (stat==src) return;
mi_atomic_void_addi64_relaxed(&stat->total, &src->total);
mi_atomic_void_addi64_relaxed(&stat->current, &src->current);

int64_t prev_current = mi_atomic_addi64_relaxed(&stat->current, src->current);

// peak scores do really not work across threads .. we just add them
mi_atomic_void_addi64_relaxed( &stat->peak, &src->peak);
//mi_atomic_void_addi64_relaxed( &stat->peak, &src->peak);
// or, take the max?
// mi_atomic_maxi64_relaxed(&stat->peak, src->peak);

// global current plus thread peak approximates new global peak
mi_atomic_maxi64_relaxed(&stat->peak, prev_current + src->peak);
}

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