diff options
author | Christopher Ferris <cferris@google.com> | 2019-04-30 17:45:48 -0700 |
---|---|---|
committer | Christopher Ferris <cferris@google.com> | 2019-05-01 12:15:35 -0700 |
commit | 801fe3af80eb7d6993f162586ac6d00d308871af (patch) | |
tree | a6edbb65b0e78d322d24be0a0f49c37b917e4576 /src | |
parent | 25b667ba3910fb6ad74e2cad1bd1d66d8de9369f (diff) | |
download | platform_external_jemalloc_new-801fe3af80eb7d6993f162586ac6d00d308871af.tar.gz platform_external_jemalloc_new-801fe3af80eb7d6993f162586ac6d00d308871af.tar.bz2 platform_external_jemalloc_new-801fe3af80eb7d6993f162586ac6d00d308871af.zip |
Remove unused stats from cache structure.
Removing the stats make the whole cache structure fit in a single page.
Bug: 131362671
Test: Verified that all bionic malloc benchmarks are still the same.
Test: It turns out that the malloc_sql benchmarks seem to get faster.
Test: Verified that after this change, it saves about 2K PSS per thread.
Change-Id: I4dcd633543f05f1a9d47db175f9977ddb42188a9
(cherry picked from commit a8b52518654725e64def5ebbd0ed472100e5a522)
Diffstat (limited to 'src')
-rw-r--r-- | src/arena.c | 4 | ||||
-rw-r--r-- | src/tcache.c | 16 |
2 files changed, 20 insertions, 0 deletions
diff --git a/src/arena.c b/src/arena.c index 5d55bf1a..61b8083f 100644 --- a/src/arena.c +++ b/src/arena.c @@ -1289,10 +1289,14 @@ arena_tcache_fill_small(tsdn_t *tsdn, arena_t *arena, tcache_t *tcache, } if (config_stats) { bin->stats.nmalloc += i; +#if defined(ANDROID_ENABLE_TCACHE_STATS) bin->stats.nrequests += tbin->tstats.nrequests; +#endif bin->stats.curregs += i; bin->stats.nfills++; +#if defined(ANDROID_ENABLE_TCACHE_STATS) tbin->tstats.nrequests = 0; +#endif } malloc_mutex_unlock(tsdn, &bin->lock); tbin->ncached = i; diff --git a/src/tcache.c b/src/tcache.c index b4320e42..b2557c15 100644 --- a/src/tcache.c +++ b/src/tcache.c @@ -140,8 +140,10 @@ tcache_bin_flush_small(tsd_t *tsd, tcache_t *tcache, cache_bin_t *tbin, assert(!merged_stats); merged_stats = true; bin->stats.nflushes++; +#if defined(ANDROID_ENABLE_TCACHE_STATS) bin->stats.nrequests += tbin->tstats.nrequests; tbin->tstats.nrequests = 0; +#endif } unsigned ndeferred = 0; for (unsigned i = 0; i < nflush; i++) { @@ -176,8 +178,10 @@ tcache_bin_flush_small(tsd_t *tsd, tcache_t *tcache, cache_bin_t *tbin, bin_t *bin = &arena->bins[binind]; malloc_mutex_lock(tsd_tsdn(tsd), &bin->lock); bin->stats.nflushes++; +#if defined(ANDROID_ENABLE_TCACHE_STATS) bin->stats.nrequests += tbin->tstats.nrequests; tbin->tstats.nrequests = 0; +#endif malloc_mutex_unlock(tsd_tsdn(tsd), &bin->lock); } @@ -192,7 +196,9 @@ tcache_bin_flush_small(tsd_t *tsd, tcache_t *tcache, cache_bin_t *tbin, void tcache_bin_flush_large(tsd_t *tsd, cache_bin_t *tbin, szind_t binind, unsigned rem, tcache_t *tcache) { +#if defined(ANDROID_ENABLE_TCACHE_STATS) bool merged_stats = false; +#endif assert(binind < nhbins); assert((cache_bin_sz_t)rem <= tbin->ncached); @@ -232,6 +238,7 @@ tcache_bin_flush_large(tsd_t *tsd, cache_bin_t *tbin, szind_t binind, tcache->prof_accumbytes); tcache->prof_accumbytes = 0; } +#if defined(ANDROID_ENABLE_TCACHE_STATS) if (config_stats) { merged_stats = true; arena_stats_large_nrequests_add(tsd_tsdn(tsd), @@ -239,6 +246,7 @@ tcache_bin_flush_large(tsd_t *tsd, cache_bin_t *tbin, szind_t binind, tbin->tstats.nrequests); tbin->tstats.nrequests = 0; } +#endif } malloc_mutex_unlock(tsd_tsdn(tsd), &locked_arena->large_mtx); @@ -269,6 +277,7 @@ tcache_bin_flush_large(tsd_t *tsd, cache_bin_t *tbin, szind_t binind, ndeferred); nflush = ndeferred; } +#if defined(ANDROID_ENABLE_TCACHE_STATS) if (config_stats && !merged_stats) { /* * The flush loop didn't happen to flush to this thread's @@ -278,6 +287,7 @@ tcache_bin_flush_large(tsd_t *tsd, cache_bin_t *tbin, szind_t binind, binind, tbin->tstats.nrequests); tbin->tstats.nrequests = 0; } +#endif memmove(tbin->avail - rem, tbin->avail - tbin->ncached, rem * sizeof(void *)); @@ -466,17 +476,21 @@ tcache_flush_cache(tsd_t *tsd, tcache_t *tcache) { cache_bin_t *tbin = tcache_small_bin_get(tcache, i); tcache_bin_flush_small(tsd, tcache, tbin, i, 0); +#if defined(ANDROID_ENABLE_TCACHE_STATS) if (config_stats) { assert(tbin->tstats.nrequests == 0); } +#endif } for (unsigned i = NBINS; i < nhbins; i++) { cache_bin_t *tbin = tcache_large_bin_get(tcache, i); tcache_bin_flush_large(tsd, tbin, i, 0, tcache); +#if defined(ANDROID_ENABLE_TCACHE_STATS) if (config_stats) { assert(tbin->tstats.nrequests == 0); } +#endif } if (config_prof && tcache->prof_accumbytes > 0 && @@ -531,6 +545,7 @@ tcache_cleanup(tsd_t *tsd) { void tcache_stats_merge(tsdn_t *tsdn, tcache_t *tcache, arena_t *arena) { +#if defined(ANDROID_ENABLE_TCACHE_STATS) unsigned i; cassert(config_stats); @@ -551,6 +566,7 @@ tcache_stats_merge(tsdn_t *tsdn, tcache_t *tcache, arena_t *arena) { tbin->tstats.nrequests); tbin->tstats.nrequests = 0; } +#endif } static bool |