diff options
author | wolfbeast <mcwerewolf@gmail.com> | 2018-04-28 08:59:44 +0200 |
---|---|---|
committer | wolfbeast <mcwerewolf@gmail.com> | 2018-04-28 08:59:44 +0200 |
commit | 08e66d35127fc77abf1aebe88a84eb0c20c9046f (patch) | |
tree | c982551a9591018ece1a719dbb39edb4b894a97a /memory/mozjemalloc/jemalloc.c | |
parent | ffd62ae6c93c30b16a7e9331d7cbd6b7fe9afb62 (diff) | |
download | UXP-08e66d35127fc77abf1aebe88a84eb0c20c9046f.tar UXP-08e66d35127fc77abf1aebe88a84eb0c20c9046f.tar.gz UXP-08e66d35127fc77abf1aebe88a84eb0c20c9046f.tar.lz UXP-08e66d35127fc77abf1aebe88a84eb0c20c9046f.tar.xz UXP-08e66d35127fc77abf1aebe88a84eb0c20c9046f.zip |
Make our allocator use multiple arenas based on number of CPU cores.
Diffstat (limited to 'memory/mozjemalloc/jemalloc.c')
-rw-r--r-- | memory/mozjemalloc/jemalloc.c | 40 |
1 files changed, 19 insertions, 21 deletions
diff --git a/memory/mozjemalloc/jemalloc.c b/memory/mozjemalloc/jemalloc.c index 8516658f5..0cbd2821e 100644 --- a/memory/mozjemalloc/jemalloc.c +++ b/memory/mozjemalloc/jemalloc.c @@ -140,17 +140,9 @@ #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. - * - * When using the Servo style system, we do indeed make use of significant - * concurrent allocation, and the overhead matters. Bug 1291355 tracks - * investigating the fragmentation overhead of turning this on for users. + * Uncomment this to use only one arena by default. */ -#ifndef MOZ_STYLO -#define MOZ_MEMORY_NARENAS_DEFAULT_ONE -#endif +// #define MOZ_MEMORY_NARENAS_DEFAULT_ONE /* * Pass this set of options to jemalloc as its default. It does not override @@ -5251,7 +5243,10 @@ huge_dalloc(void *ptr) base_node_dealloc(node); } -#ifndef MOZ_MEMORY_NARENAS_DEFAULT_ONE +/* + * Platform-specific methods to determine the number of CPUs in a system. + * This will be used to determine the desired number of arenas. + */ #ifdef MOZ_MEMORY_BSD static inline unsigned malloc_ncpus(void) @@ -5349,11 +5344,19 @@ malloc_ncpus(void) { return sysconf(_SC_NPROCESSORS_ONLN); } +#elif (defined(MOZ_MEMORY_WINDOWS)) +static inline unsigned +malloc_ncpus(void) +{ + SYSTEM_INFO info; + + GetSystemInfo(&info); + return (info.dwNumberOfProcessors); +} #else static inline unsigned malloc_ncpus(void) { - /* * We lack a way to determine the number of CPUs on this platform, so * assume 1 CPU. @@ -5361,7 +5364,6 @@ malloc_ncpus(void) return (1); } #endif -#endif static void malloc_print_stats(void) @@ -5562,20 +5564,16 @@ malloc_init_hard(void) GetSystemInfo(&info); result = info.dwPageSize; - -#ifndef MOZ_MEMORY_NARENAS_DEFAULT_ONE - ncpus = info.dwNumberOfProcessors; -#endif } #else -#ifndef MOZ_MEMORY_NARENAS_DEFAULT_ONE - ncpus = malloc_ncpus(); -#endif - result = sysconf(_SC_PAGESIZE); assert(result != -1); #endif +#ifndef MOZ_MEMORY_NARENAS_DEFAULT_ONE + ncpus = malloc_ncpus(); +#endif + /* We assume that the page size is a power of 2. */ assert(((result - 1) & result) == 0); #ifdef MALLOC_STATIC_SIZES |