Ah, but transparent huge pages are portable. They don't change your code. In HPC land, your task pretty much own the node(s) on which you're running, so there is little danger of the fragmentation you encountered. THP often is a big performance win with *no* code change. Fixing the zero page issue will fix the remaining decently-sized gotcha for HPC-style uses.
And some of these HPC codes are old and/or expect to run on more than Linux. Conditionally changing all the user-specified and compiler-generated memory allocations is a painful task.
Posted Sep 28, 2012 9:11 UTC (Fri) by alankila (subscriber, #47141)
[Link]
Right. Well, I'm just saying that there are cases where it doesn't work, so it's a bit akin a voodoo feature you enable and then convince yourself that there is a speed benefit. It is only when you read AnonHugePages line from /proc/meminfo and see, for instance, that only 64 MB is actually in hugepages that you realize it isn't all it's cracked up to be. But hey, it's better than nothing, right?
I was wondering if there shouldn't be a memory defragmenting task that goes through the running process' heap periodically and would move the 4k pages around until coalescing them to a hugepage becomes possible. I mean, if using these pages really gives you around 5 % performance benefit, it would seem reasonable to spend up to few % of CPU to do it for tasks that seem long-lived enough.
Adding a huge zero page
Posted Sep 28, 2012 11:13 UTC (Fri) by nix (subscriber, #2304)
[Link]
The latter machine is running a single virtual machine, but the former is running no VMs of any kind and has still turned a gigabyte into transpages (probably largely inside monsters like Chromium). That's not insignificant. (For that matter, I routinely see compile jobs getting hugepaged up, and a TLB saving in a pointer-mad monster like GCC really does speed it up. Sure, it's only a few percent, but that's better than nothing, right?)
Adding a huge zero page
Posted Sep 28, 2012 23:19 UTC (Fri) by alankila (subscriber, #47141)
[Link]
Sure. I'm not saying it never works, I just wish it worked for my use case. Anyway, explicit hugepages are not too huge a pain for now, you just have to calculate/measure how many you need and then hack some apparmor rules for kvm to allow the hugepages mount region to be accessible for writing.
That being said, out of 1.5 GB of other services on the server:
AnonHugePages: 71680 kB
*sigh*
Adding a huge zero page
Posted Sep 28, 2012 23:37 UTC (Fri) by khc (subscriber, #45209)
[Link]
are we doing some kind of poll? :-)
MemTotal: 16327088 kB
AnonHugePages: 3102720 kB
Of course, this box has a fairly specialized daemon that allocates 8GB of memory as 2 separate pools, so it's not surprising that auto huge pages work well (although I've never measured the performance impact of that).
Adding a huge zero page
Posted Sep 29, 2012 10:28 UTC (Sat) by nix (subscriber, #2304)
[Link]
Yeah, exactly. If you run things with big heaps composed of lots of little pieces (so malloc uses arena allocation and allocates >>2Mb), you'll probably do well with transparent hugepages. If instead you have lots of little programs with small heaps, you won't see any benefit: if you have programs that make lots of medium-big allocations between 512Kb and 2Mb, you'll probably see glibc malloc falling back to mmap() of regions a bit too small to be converted into a transparent hugepage.
Adding a huge zero page
Posted Sep 28, 2012 14:09 UTC (Fri) by ejr (subscriber, #51652)
[Link]
Look up Mel Gorman's memory compaction work. IIRC, there was a somewhat recent (months ago?) bit here on the painful interactions between memory compaction and VFAT on removable devices.
Adding a huge zero page
Posted Oct 5, 2012 16:10 UTC (Fri) by cpasqualini (guest, #69417)
[Link]
Looking at this article and it's comments adn started to read about THP and found an interesting file in the Docs: http://lwn.net/Articles/423592/
Did you test any of these?
echo always >/sys/kernel/mm/transparent_hugepage/defrag
echo madvise >/sys/kernel/mm/transparent_hugepage/defrag
echo never >/sys/kernel/mm/transparent_hugepage/defrag