From cc374363ecc5b8991cac2c9d0e45a95f9a233c74 Mon Sep 17 00:00:00 2001 From: Christopher Ferris Date: Mon, 18 Mar 2019 15:26:51 -0700 Subject: Remove best fit for extent selection. A jemalloc user reported that the best fit selection is causing them a memory leak. This code has been completely removed from the next release of jemalloc (5.2.0), so remove it since it doesn't have any real benefit. See https://github.com/jemalloc/jemalloc/issues/1454 Running the memory dumps, removing best fit appears to be a win: it is slightly faster and has the same PSS/VA. Bug: 128697497 Test: Ran jemalloc unit tests. Test: Ran memory dumps in 32 bit and 64 bit and observed that the PSS Test: and VA stayed the same, while run time improved slightly. Change-Id: I98a8ddf2cea837c8ade1afd4a998960c253d3932 --- src/extent.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/extent.c b/src/extent.c index 09d6d771..da66a8e0 100644 --- a/src/extent.c +++ b/src/extent.c @@ -394,6 +394,12 @@ extents_fit_alignment(extents_t *extents, size_t min_size, size_t max_size, return NULL; } +// ANDROID +// The best-fit selection is reported to possiblity cause a memory leak. +// This code has been completely removed from 5.2.0, so remove it from +// our tree rather than risk a leak. +// See https://github.com/jemalloc/jemalloc/issues/1454 +#if 0 /* Do any-best-fit extent selection, i.e. select any extent that best fits. */ static extent_t * extents_best_fit_locked(tsdn_t *tsdn, arena_t *arena, extents_t *extents, @@ -417,6 +423,7 @@ extents_best_fit_locked(tsdn_t *tsdn, arena_t *arena, extents_t *extents, return NULL; } +#endif /* * Do first-fit extent selection, i.e. select the oldest/lowest extent that is @@ -464,9 +471,18 @@ extents_fit_locked(tsdn_t *tsdn, arena_t *arena, extents_t *extents, return NULL; } +// ANDROID +// The best-fit selection is reported to possiblity cause a memory leak. +// This code has been completely removed from 5.2.0, so remove it from +// our tree rather than risk a leak. +// See https://github.com/jemalloc/jemalloc/issues/1454 +#if 0 extent_t *extent = extents->delay_coalesce ? extents_best_fit_locked(tsdn, arena, extents, max_size) : extents_first_fit_locked(tsdn, arena, extents, max_size); +#endif + extent_t *extent = + extents_first_fit_locked(tsdn, arena, extents, max_size); if (alignment > PAGE && extent == NULL) { /* -- cgit v1.2.3