only delay eager commit after the first thread

This commit is contained in:
daan 2022-02-04 16:10:51 -08:00
parent 0dd5a2e0a5
commit fb418831df

View file

@ -578,11 +578,11 @@ static void mi_segment_perhaps_decommit(mi_segment_t* segment, uint8_t* p, size_
else if (segment->decommit_expire <= now) {
// previous decommit mask already expired
// mi_segment_delayed_decommit(segment, true, stats);
segment->decommit_expire = now + (mi_option_get(mi_option_decommit_delay) / 8); // wait a tiny bit longer in case there is a series of free's
segment->decommit_expire = now + mi_option_get(mi_option_decommit_extend_delay); // (mi_option_get(mi_option_decommit_delay) / 8); // wait a tiny bit longer in case there is a series of free's
}
else {
// previous decommit mask is not yet expired, increase the expiration by a bit.
segment->decommit_expire += (mi_option_get(mi_option_decommit_delay) / 8);
segment->decommit_expire += mi_option_get(mi_option_decommit_extend_delay);
}
}
}
@ -809,7 +809,7 @@ static mi_segment_t* mi_segment_init(mi_segment_t* segment, size_t required, mi_
// Commit eagerly only if not the first N lazy segments (to reduce impact of many threads that allocate just a little)
const bool eager_delay = (!_mi_os_has_overcommit() && // never delay on overcommit systems
_mi_current_thread_count() > 2 && // do not delay for the first N threads
_mi_current_thread_count() > 1 && // do not delay for the first N threads
tld->count < (size_t)mi_option_get(mi_option_eager_commit_delay));
const bool eager = !eager_delay && mi_option_is_enabled(mi_option_eager_commit);
bool commit = eager || (required > 0);