Respect hpa_min_purge_interval_ms option

Currently, hugepages aware allocator backend works together with classic
one as a fallback for not yet supported allocations. When background
threads are enabled wake up time for classic interfere with hpa as there
were no checks inside hpa purging logic to check if we are not purging too
frequently. If background thread is running and `hpa_should_purge`
returns true, then we will purge, even if we purged less than
hpa_min_purge_interval_ms ago.
This commit is contained in:
Dmitry Ilvokhin 2024-05-31 06:35:48 -07:00 committed by Qi Wang
parent 90c627edb7
commit 91a6d230db
2 changed files with 48 additions and 14 deletions

View file

@ -378,6 +378,16 @@ static bool
hpa_try_purge(tsdn_t *tsdn, hpa_shard_t *shard) {
malloc_mutex_assert_owner(tsdn, &shard->mtx);
/*
* Make sure we respect purge interval setting and don't purge
* too frequently.
*/
uint64_t since_last_purge_ms = shard->central->hooks.ms_since(
&shard->last_purge);
if (since_last_purge_ms < shard->opts.min_purge_interval_ms) {
return false;
}
hpdata_t *to_purge = psset_pick_purge(&shard->psset);
if (to_purge == NULL) {
return false;