What it is
Redis and many databases snapshot by forking: the child sees a frozen copy while the parent keeps writing, and every page the parent writes is copied. With 4 KiB pages that is a few kilobytes per write; with transparent huge pages the cost depends on the kernel, which either splits the huge page and copies 4 KiB or copies the whole 2 MiB. THP also backs sparse data with whole huge pages, and when no free 2 MiB block exists the allocator falls back or stalls in compaction. This lab counts those effects and checks them against a memory.max limit.
When to use it
Use it before turning THP on or off for a fork-based database, to explain a BGSAVE memory spike or an OOM kill at snapshot time, or to size memory.max with headroom for the copy-on-write burst.
Gotchas & limits
Results are expected values for uniform random writes, not predictions for your key distribution. The split-and-copy-4 KiB behaviour was measured on Linux 6.18; the older copy-2 MiB behaviour is not yet measured and stays a to-be-verified assumption. The verification script only reads state. Never test an OOM scenario on a production host.