File HugePageAllocator.h

↰ Parent directory (ADS/memory)

An allocator for the large blocks of a structure, beyond the book: a request of at least one huge page (2 MB) is aligned to a huge page, rounded up to whole ones and, on Linux, advised to the kernel for the transparent huge pages (madvise( MADV_HUGEPAGE ), which the kernel may ignore); a smaller one goes to std::allocator.

Definition (ADS/memory/HugePageAllocator.h)

Detailed Description

A structure whose nodes are reached in no useful order, e.g., the trees of a heap, then misses the TLB once per 2 MB instead of once per 4 KB page, and its memory is faulted in a huge page at a time; the price is up to one huge page more of address space per block, which is not touched, so that it costs no memory. Elsewhere than on Linux the large requests are only aligned.

A block of 8 MB or more given back is kept by its thread, up to 16 blocks and 64 MB in all, and given again to the next request of the same size, as the size-class allocators keep their freed spans (Berger et al.; Leijen et al.): its pages are already faulted in, cleared and made huge, so that a structure that is built and destroyed again and again, or that grows through the same sizes (a vector that doubles, a pool whose blocks double), pays the faults once; a smaller block goes back to the allocator of the system, which serves it again from its heap, and the blocks kept go back to the system when the thread ends.

The allocators are all equal, and stateless.

  1. Navarro, S. Iyer, P. Druschel, A. Cox, Practical, transparent operating system support for superpages, ACM SIGOPS Operating Systems Review 36(SI), 89-104, 2002 (OSDI 2002), doi:10.1145/844128.844138

    1. Berger, B. G. Zorn, K. S. McKinley, Reconsidering custom memory allocation, Proceedings of the 17th ACM SIGPLAN Conference on Object-Oriented Programming, Systems, Languages, and Applications (OOPSLA), 1-12, 2002, doi:10.1145/582419.582421

  1. Leijen, B. Zorn, L. de Moura, Mimalloc: free list sharding in action, Programming Languages and Systems (APLAS 2019), Lecture Notes in Computer Science 11893, 244-265, 2019, doi:10.1007/978-3-030-34175-6_13

Donato Meoli

Dipartimento di Informatica Universita’ di Pisa

by Donato Meoli

Includes

Included By

Namespaces

Classes

Functions