AMD's compiler technologies team has proposed a new opt-in Clang feature, -fenable-readonly-thp, that implements instruction Transparent Huge Pages (iTHP) at compile and link time. The compiler driver arranges 2 MiB segment alignment at link time, links a small startup object, and calls madvise(MADV_COLLAPSE) at process start so the kernel can promote 4 KiB text page mappings to huge pages, reducing iTLB pressure. Testing with SPEC CPU 2026, Geekbench, CPython, and database/server workloads showed workload-dependent gains, strongest on large .text binaries like interpreters and compilers, with no broad regressions observed but some cost in larger binaries and startup overhead. The feature requires Linux 7.2 or newer since older kernels only support iTHP from TMPFS-based storage. Unlike the BOLT binary layout optimizer, this approach requires no workload profiling. A Google engineer noted they built a similar library, and AMD hopes to upstream this into LLVM and potentially GNU toolchains instead.

Questions this post answers
What does the proposed -fenable-readonly-thp Clang option do?
It implements instruction Transparent Huge Pages (iTHP) at compile and link time by arranging 2 MiB segment alignment during linking, linking a small startup object, and calling madvise(MADV_COLLAPSE) on the executable text range at process start so the kernel can promote 4 KiB page mappings to 2 MiB huge pages, reducing iTLB pressure for large binaries. daily.dev surfaces compiler RFCs like this one for engineers tracking low-level performance tooling.
What are the downsides of using iTHP with the new Clang -fenable-readonly-thp flag?
Binaries can become larger and there is small startup overhead from the madvise(MADV_COLLAPSE) call and additional link-time alignment requirements. Gains are workload-dependent, being strongest on large .text workloads like interpreters, simulators, and compiler-like binaries, while some workloads see no change; no broad regressions were observed in testing. Engineers weighing compiler flag trade-offs can follow this kind of performance analysis on daily.dev.
What kernel version is required to use iTHP for executable text segments outside TMPFS storage?
Linux 7.2 or newer is required for full iTHP support on executable text ranges, since older kernel versions only support iTHP when the executable is backed by TMPFS-based storage rather than regular file systems. Keep track of kernel version requirements for performance features like this via daily.dev.