From 7e842879c2cc374a1ea439ff395343fb645d78b4 Mon Sep 17 00:00:00 2001 From: Qi Wang Date: Thu, 24 Apr 2025 20:21:53 -0700 Subject: [PATCH] Avoid forced purging during thread-arena migration when bg thd is on. --- src/jemalloc.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/jemalloc.c b/src/jemalloc.c index d7b46d6c..9451df77 100644 --- a/src/jemalloc.c +++ b/src/jemalloc.c @@ -494,8 +494,12 @@ arena_migrate(tsd_t *tsd, arena_t *oldarena, arena_t *newarena) { arena_nthreads_inc(newarena, false); tsd_arena_set(tsd, newarena); - if (arena_nthreads_get(oldarena, false) == 0) { - /* Purge if the old arena has no associated threads anymore. */ + if (arena_nthreads_get(oldarena, false) == 0 && + !background_thread_enabled()) { + /* + * Purge if the old arena has no associated threads anymore and + * no background threads. + */ arena_decay(tsd_tsdn(tsd), oldarena, /* is_background_thread */ false, /* all */ true); }