mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-09-06 07:48:38 +09:00
Make our allocator use multiple arenas based on number of CPU cores.
This commit is contained in:
parent
c37c93d911
commit
30e71338fd
1 changed files with 19 additions and 21 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue