Bug 432475: Remove _malloc_options abuse, r=benjamin
Don't abuse _malloc_options to set platform-specific options, since doing so
makes the MALLOC_OPTIONS environment variable less useful.
--- a/memory/jemalloc/jemalloc.c
+++ b/memory/jemalloc/jemalloc.c
@@ -100,16 +100,23 @@
* defaults the A and J runtime options to off. These settings are appropriate
* for production systems.
*/
#ifndef MOZ_MEMORY_DEBUG
# define MALLOC_PRODUCTION
#endif
/*
+ * Use only one arena by default. Mozilla does not currently make extensive
+ * use of concurrent allocation, so the increased fragmentation associated with
+ * multiple arenas is not warranted.
+ */
+#define MOZ_MEMORY_NARENAS_DEFAULT_ONE
+
+/*
* MALLOC_STATS enables statistics calculation, and is required for
* jemalloc_stats().
*/
#define MALLOC_STATS
#ifndef MALLOC_PRODUCTION
/*
* MALLOC_DEBUG enables assertions and other sanity checks, and disables
@@ -1043,27 +1050,17 @@ static __thread arena_t *arenas_map;
/* Chunk statistics. */
static chunk_stats_t stats_chunks;
#endif
/*******************************/
/*
* Runtime configuration options.
*/
-const char *_malloc_options
-#ifdef MOZ_MEMORY_WINDOWS
-= "A10n"
-#elif (defined(MOZ_MEMORY_DARWIN))
-= "AP10n"
-#elif (defined(MOZ_MEMORY_LINUX))
-= "A10n"
-#elif (defined(MOZ_MEMORY_SOLARIS))
-= "A10n"
-#endif
-;
+const char *_malloc_options;
#ifndef MALLOC_PRODUCTION
static bool opt_abort = true;
#ifdef MALLOC_FILL
static bool opt_junk = true;
#endif
#else
static bool opt_abort = false;
@@ -5620,26 +5617,30 @@ MALLOC_OUT:
* the use of space that would otherwise be wasted.
*/
if (opt_dss)
base_pages_alloc(0);
#endif
base_nodes = NULL;
malloc_mutex_init(&base_mtx);
+#ifdef MOZ_MEMORY_NARENAS_DEFAULT_ONE
+ narenas = 1;
+#else
if (ncpus > 1) {
/*
* For SMP systems, create four times as many arenas as there
* are CPUs by default.
*/
opt_narenas_lshift += 2;
}
/* Determine how many arenas to use. */
narenas = ncpus;
+#endif
if (opt_narenas_lshift > 0) {
if ((narenas << opt_narenas_lshift) > narenas)
narenas <<= opt_narenas_lshift;
/*
* Make sure not to exceed the limits of what base_alloc() can
* handle.
*/
if (narenas * sizeof(arena_t *) > chunksize)