Low Latency Optimization: Using Huge Pages on Linux (Part 2)
Dec 2, 2022ndepalo

Summary
This post details the practical challenges and caveats of using huge pages on Linux, focusing on memory fragmentation, Transparent Huge Pages (THP) modes ('always' and 'madvise'), and hugetlbfs. It discusses software support for huge page allocation in memory allocators (jemalloc, tcmalloc, mimalloc, glibc) and specific applications (Java VM, PostgreSQL), as well as external libraries like libhugetlbfs. The post also covers running programs from huge pages, including considerations for code sharing and the use of tmpfs with the 'huge' option. Finally, it delves into fine-tuning TLB usage by examining the multi-level structure of TLBs on x86 CPUs and their impact on performance.