Improve performance of jemalloc svelte config.
am: 53bf335388
Change-Id: I9057c7acb14869b9a672a55fe363ddfb7134cd68
diff --git a/Android.bp b/Android.bp
index f65c934..3d55e6f 100644
--- a/Android.bp
+++ b/Android.bp
@@ -23,8 +23,6 @@
]
// 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,10 +41,11 @@
// 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_MAX_ARENAS=2",
- "-DANDROID_TCACHE_NSLOTS_SMALL_MAX=8",
- "-DANDROID_TCACHE_NSLOTS_LARGE=16",
+ "-DANDROID_MAX_ARENAS=1",
"-DANDROID_LG_TCACHE_MAXCLASS_DEFAULT=16",
]
@@ -58,7 +57,13 @@
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",
+ ],
},
}
diff --git a/include/jemalloc/internal/arena.h b/include/jemalloc/internal/arena.h
index a8819f9..4062660 100644
--- a/include/jemalloc/internal/arena.h
+++ b/include/jemalloc/internal/arena.h
@@ -30,12 +30,13 @@
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