Transparent Hugepages: measuring the performance impact (2017)
alexandrnikitin.github.io
alexandrnikitin.github.io
[0] https://github.com/discourse/discourse_docker/blob/ade283329...
AFAIK only thing that could be improved in Linux is that when THP are enabled, it should split the 2MB page into 4kg pages and copy just that.
Splitting up such pages into their 4kb counterparts when dirtying a COWed huge page isn't particularly crazy. I don't think there's much reason to do that when huge pages are used, but given THP it seems pretty obvious that there's potential for substantial regressions without that feature.
> and actually is very hard to do better in user-space with a different persistence model.
Howso? It's not like management of a buffering layer over disks is a particularly new thing. There's plenty of different data stores that have persistence models that don't have the problems (uneven write rate, explosion in memory usage after fork, latency increases due to the increase in page misses, ...) of fork() and then writing out the data in the fork.
Transparent huge pages are great for applications like the JVM example from the article. It's not terribly difficult to localize it for one buffer/pool if that's what's right for your application.
> Do not blindly follow any recommendation on the Internet, please! Measure, measure and measure again!
Amen!
They're also especially valuable to workloads where you can predict the memory access pattern.
Also note that THP opt-in instead of opt-out is already possible. You just have to set the sysfs control to "madvise" instead of "always", many distros do this by default already.
It keeps getting better, maybe one day..