diff options
author | Christopher Ferris <cferris@google.com> | 2016-07-19 14:05:20 -0700 |
---|---|---|
committer | Christopher Ferris <cferris@google.com> | 2016-07-19 16:57:27 -0700 |
commit | 08795324eae5f68d211dc5483746af51203dc661 (patch) | |
tree | efc3b23605daab5acd733e5da6562478be7e8472 | |
parent | 474a8fd14c47ba4f65e024a2a9247fffdb7706d1 (diff) | |
download | jemalloc-android-7.1.1_r57.tar.gz |
Improve performance of jemalloc svelte config.android-cts_7.1_r1android-cts-7.1_r9android-cts-7.1_r8android-cts-7.1_r7android-cts-7.1_r6android-cts-7.1_r5android-cts-7.1_r4android-cts-7.1_r3android-cts-7.1_r29android-cts-7.1_r28android-cts-7.1_r27android-cts-7.1_r26android-cts-7.1_r25android-cts-7.1_r24android-cts-7.1_r23android-cts-7.1_r22android-cts-7.1_r21android-cts-7.1_r20android-cts-7.1_r2android-cts-7.1_r19android-cts-7.1_r18android-cts-7.1_r17android-cts-7.1_r16android-cts-7.1_r15android-cts-7.1_r14android-cts-7.1_r13android-cts-7.1_r12android-cts-7.1_r11android-cts-7.1_r10android-cts-7.1_r1android-7.1.2_r9android-7.1.2_r8android-7.1.2_r6android-7.1.2_r5android-7.1.2_r4android-7.1.2_r39android-7.1.2_r38android-7.1.2_r37android-7.1.2_r36android-7.1.2_r33android-7.1.2_r32android-7.1.2_r30android-7.1.2_r3android-7.1.2_r29android-7.1.2_r28android-7.1.2_r27android-7.1.2_r25android-7.1.2_r24android-7.1.2_r23android-7.1.2_r2android-7.1.2_r19android-7.1.2_r18android-7.1.2_r17android-7.1.2_r16android-7.1.2_r15android-7.1.2_r14android-7.1.2_r13android-7.1.2_r12android-7.1.2_r11android-7.1.2_r10android-7.1.2_r1android-7.1.1_r9android-7.1.1_r8android-7.1.1_r7android-7.1.1_r61android-7.1.1_r60android-7.1.1_r6android-7.1.1_r59android-7.1.1_r58android-7.1.1_r57android-7.1.1_r56android-7.1.1_r55android-7.1.1_r54android-7.1.1_r53android-7.1.1_r52android-7.1.1_r51android-7.1.1_r50android-7.1.1_r49android-7.1.1_r48android-7.1.1_r47android-7.1.1_r46android-7.1.1_r45android-7.1.1_r44android-7.1.1_r43android-7.1.1_r42android-7.1.1_r41android-7.1.1_r40android-7.1.1_r4android-7.1.1_r39android-7.1.1_r38android-7.1.1_r35android-7.1.1_r33android-7.1.1_r32android-7.1.1_r31android-7.1.1_r3android-7.1.1_r28android-7.1.1_r27android-7.1.1_r26android-7.1.1_r25android-7.1.1_r24android-7.1.1_r23android-7.1.1_r22android-7.1.1_r21android-7.1.1_r20android-7.1.1_r2android-7.1.1_r17android-7.1.1_r16android-7.1.1_r15android-7.1.1_r14android-7.1.1_r13android-7.1.1_r12android-7.1.1_r11android-7.1.1_r10android-7.1.1_r1android-7.1.0_r7android-7.1.0_r6android-7.1.0_r5android-7.1.0_r4android-7.1.0_r3android-7.1.0_r2android-7.1.0_r1nougat-mr2.3-releasenougat-mr2.2-releasenougat-mr2.1-releasenougat-mr2-security-releasenougat-mr2-releasenougat-mr2-pixel-releasenougat-mr2-devnougat-mr1.8-releasenougat-mr1.7-releasenougat-mr1.6-releasenougat-mr1.5-releasenougat-mr1.4-releasenougat-mr1.3-releasenougat-mr1.2-releasenougat-mr1.1-releasenougat-mr1-volantis-releasenougat-mr1-security-releasenougat-mr1-releasenougat-mr1-flounder-releasenougat-mr1-devnougat-mr1-cts-releasenougat-dr1-release
Change the decay time from zero to one second, to avoid problems with
the purge interferring with allocations taking too long.
Also, decrease the arenas from 2 to 1 for the svelte config to offset
the PSS increase caused by the decay time change.
Bug: 30077848
Change-Id: Ie7688a8bfd50f0ba7d5f0e594a37baca43596e41
-rw-r--r-- | Android.bp | 18 | ||||
-rw-r--r-- | Android.mk | 20 | ||||
-rw-r--r-- | include/jemalloc/internal/arena.h | 7 |
3 files changed, 27 insertions, 18 deletions
@@ -23,8 +23,6 @@ common_cflags = [ ] // These parameters change the way jemalloc works. -// ANDROID_ALWAYS_PURGE -// If defined, always purge immediately when a page is purgeable. // ANDROID_MAX_ARENAS=XX // The total number of arenas will be less than or equal to this number. // The number of arenas will be calculated as 2 * the number of cpus @@ -43,11 +41,11 @@ common_cflags = [ // 1 << XX is the default chunk size used by the system. Decreasing this // usually decreases the amount of PSS used, but can increase // fragmentation. + +// Default to a single arena for svelte configurations to minimize +// PSS consumed by jemalloc. common_cflags += [ - "-DANDROID_ALWAYS_PURGE", - "-DANDROID_MAX_ARENAS=2", - "-DANDROID_TCACHE_NSLOTS_SMALL_MAX=8", - "-DANDROID_TCACHE_NSLOTS_LARGE=16", + "-DANDROID_MAX_ARENAS=1", "-DANDROID_LG_TCACHE_MAXCLASS_DEFAULT=16", ] @@ -59,7 +57,13 @@ common_c_local_includes = [ common_product_variables = { // Only enable the tcache on non-svelte configurations, to save PSS. malloc_not_svelte: { - cflags: ["-DJEMALLOC_TCACHE"], + cflags: [ + "-UANDROID_MAX_ARENAS", + "-DANDROID_MAX_ARENAS=2", + "-DJEMALLOC_TCACHE", + "-DANDROID_TCACHE_NSLOTS_SMALL_MAX=8", + "-DANDROID_TCACHE_NSLOTS_LARGE=16", + ], }, } @@ -24,8 +24,6 @@ jemalloc_common_cflags := \ -Wno-type-limits \ # These parameters change the way jemalloc works. -# ANDROID_ALWAYS_PURGE -# If defined, always purge immediately when a page is purgeable. # ANDROID_MAX_ARENAS=XX # The total number of arenas will be less than or equal to this number. # The number of arenas will be calculated as 2 * the number of cpus @@ -45,16 +43,22 @@ jemalloc_common_cflags := \ # usually decreases the amount of PSS used, but can increase # fragmentation. jemalloc_common_cflags += \ - -DANDROID_ALWAYS_PURGE \ - -DANDROID_MAX_ARENAS=2 \ - -DANDROID_TCACHE_NSLOTS_SMALL_MAX=8 \ - -DANDROID_TCACHE_NSLOTS_LARGE=16 \ -DANDROID_LG_TCACHE_MAXCLASS_DEFAULT=16 \ +ifeq ($(MALLOC_SVELTE),true) +# Use a single arena on svelte devices to keep the PSS consumption as low +# as possible. +jemalloc_common_cflags += \ + -DANDROID_MAX_ARENAS=1 \ + +else # Only enable the tcache on non-svelte configurations, to save PSS. -ifneq ($(MALLOC_SVELTE),true) jemalloc_common_cflags += \ - -DJEMALLOC_TCACHE + -DANDROID_MAX_ARENAS=2 \ + -DJEMALLOC_TCACHE \ + -DANDROID_TCACHE_NSLOTS_SMALL_MAX=8 \ + -DANDROID_TCACHE_NSLOTS_LARGE=16 \ + endif # Use a 512K chunk size on 32 bit systems. diff --git a/include/jemalloc/internal/arena.h b/include/jemalloc/internal/arena.h index f234ec6..47096b4 100644 --- a/include/jemalloc/internal/arena.h +++ b/include/jemalloc/internal/arena.h @@ -30,12 +30,13 @@ typedef enum { purge_mode_limit = 2 } purge_mode_t; /* ANDROID change */ -/* Use the decay mode purge method. By setting the DECAY_TIME_DEFAULT to - * zero, this forces all pages to be purged as soon as they are not in use. +/* Use the decay mode purge method. Do not set this value to zero, since + * forcing a purge immediately affects performance negatively. Using a + * small value provides a compromise between performance and extra PSS. */ #define PURGE_DEFAULT purge_mode_decay /* Default decay time in seconds. */ -#define DECAY_TIME_DEFAULT 0 +#define DECAY_TIME_DEFAULT 1 /* End ANDROID change */ /* Number of event ticks between time checks. */ #define DECAY_NTICKS_PER_UPDATE 1000 |