Skip to content
This repository was archived by the owner on Jul 9, 2025. It is now read-only.

Commit db91a5e

Browse files
committed
Bug 1955406 - Check for significant reuse after purging each chunk r=jstutte
Differential Revision: https://phabricator.services.mozilla.com/D243401
1 parent aa6f027 commit db91a5e

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

memory/build/mozjemalloc.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6145,14 +6145,14 @@ purge_result_t ArenaCollection::MayPurgeSteps(
61456145
// arenas.
61466146
MOZ_ASSERT(IsOnMainThreadWeak());
61476147

6148+
uint64_t now = GetTimestampNS();
6149+
uint64_t reuseGraceNS = (uint64_t)aReuseGraceMS * 1000 * 1000;
61486150
arena_t* found = nullptr;
61496151
{
61506152
MutexAutoLock lock(mPurgeListLock);
61516153
if (mOutstandingPurges.isEmpty()) {
61526154
return purge_result_t::Done;
61536155
}
6154-
uint64_t now = GetTimestampNS();
6155-
uint64_t reuseGraceNS = (uint64_t)aReuseGraceMS * 1000 * 1000;
61566156
for (arena_t& arena : mOutstandingPurges) {
61576157
if (now - arena.mLastSignificantReuseNS >= reuseGraceNS) {
61586158
found = &arena;
@@ -6176,8 +6176,10 @@ purge_result_t ArenaCollection::MayPurgeSteps(
61766176
arena_t::PurgeResult pr;
61776177
do {
61786178
pr = found->Purge(PurgeIfThreshold);
6179-
} while (pr == arena_t::PurgeResult::Continue && aKeepGoing &&
6180-
(*aKeepGoing)());
6179+
now = GetTimestampNS();
6180+
} while (pr == arena_t::PurgeResult::Continue &&
6181+
(now - found->mLastSignificantReuseNS >= reuseGraceNS) &&
6182+
aKeepGoing && (*aKeepGoing)());
61816183

61826184
if (pr == arena_t::PurgeResult::Continue) {
61836185
// If there's more work to do we re-insert the arena into the purge queue.

0 commit comments

Comments
 (0)