proxygen
|
#include <JemallocHugePageAllocator.h>
Static Public Member Functions | |
static bool | init (int nr_pages) |
static void * | allocate (size_t size) |
static void * | reallocate (void *p, size_t size) |
static void | deallocate (void *p, size_t=0) |
static bool | initialized () |
static size_t | freeSpace () |
static bool | addressInArena (void *address) |
Static Private Attributes | |
static int | flags_ {0} |
static bool | hugePagesSupported {false} |
An allocator which uses Jemalloc to create a dedicated huge page arena, backed by 2MB huge pages (on linux x86-64).
This allocator is specifically intended for linux with the transparent huge page support set to 'madvise' and defrag policy set to 'madvise' or 'defer+madvise'. These can be controller via /sys/kernel/mm/transparent_hugepage/enabled and /sys/kernel/mm/transparent_hugepage/defrag.
The allocator reserves a fixed-size area using mmap, and sets the MADV_HUGEPAGE page attribute using the madvise system call. A custom jemalloc hook is installed which is called when creating a new extent of memory. This will allocate from the reserved area if possible, and otherwise fall back to the default method. Jemalloc does not use allocated extents across different arenas without first unmapping them, and the advice flags are cleared on munmap. A regular malloc will never end up allocating memory from this arena.
If binary isn't linked with jemalloc, the logic falls back to malloc / free.
Note that the madvise call does not guarantee huge pages, it is best effort.
1GB Huge Pages are not supported at this point.
Definition at line 57 of file JemallocHugePageAllocator.h.
|
static |
Definition at line 279 of file JemallocHugePageAllocator.cpp.
Referenced by initialized(), and TEST().
|
inlinestatic |
Definition at line 61 of file JemallocHugePageAllocator.h.
References flags_, hugePagesSupported, and mallocx.
Referenced by folly::CxxHugePageAllocator< T >::allocate(), and TEST().
|
inlinestatic |
Definition at line 71 of file JemallocHugePageAllocator.h.
References dallocx, flags_, bm::free(), and hugePagesSupported.
Referenced by folly::CxxHugePageAllocator< T >::deallocate(), and TEST().
|
static |
Definition at line 275 of file JemallocHugePageAllocator.cpp.
Referenced by initialized(), and TEST().
|
static |
Definition at line 258 of file JemallocHugePageAllocator.cpp.
References folly::usingJEMalloc(), and folly::WARNING.
Referenced by TEST().
|
inlinestatic |
Definition at line 75 of file JemallocHugePageAllocator.h.
References addressInArena(), flags_, and freeSpace().
Referenced by TEST().
|
inlinestatic |
Definition at line 67 of file JemallocHugePageAllocator.h.
References flags_, hugePagesSupported, and rallocx.
|
staticprivate |
Definition at line 83 of file JemallocHugePageAllocator.h.
Referenced by allocate(), deallocate(), initialized(), and reallocate().
|
staticprivate |
Definition at line 84 of file JemallocHugePageAllocator.h.
Referenced by allocate(), deallocate(), and reallocate().