On 03/20/2016 01:58 PM, Anatol Belski wrote: > Dmitry has already merged this patch into the 7.0 branch. I also know from > Remi that Fedora doesn't play well with the huge pages. Huge pages require > special system settings which are usually not enabled in OSes by default. > Having it off by default in PHP would therefore not cause any functional > disadvantage while addressing the stability concerns. Thus reversing the > default setting sounds feasible, it could be already done for the upcoming > 7.0.5 if there are no objections.
Yes, and since the special system settings, namely setting vm.nr_hugepages is a system-wide shared setting and not PHP-specific it makes even more sense to not enable huge pages by default. If you happen to install PHP on a system that has vm.nr_hugepages set to non-zero for some other service on that machine, PHP is going blow up as soon as it runs out of huge pages. And the 2nd reason to disable huge pages by default is that, as you say, on most systems vm.nr_hugepages is going to be 0 but MAP_HUGETLB will be defined because every modern OS supports huge pages even if they are not actually enabled. But the allocator doesn't know that. It will try to do a MAP_HUGETLB mmap every single time here: https://github.com/php/php-src/blob/master/Zend/zend_alloc.c#L470 which is going to fail with an ENOMEM error and fall back to a non-HUGETLB mmap. So every alloc there incurs an extra syscall in the default case. So we have 3 things to do: 1. Default it to off 2. Provide a way to specify the huge page size as per bug 71355 3. Document the use of USE_ZEND_ALLOC_HUGE_PAGES and how to set vm.nr_hugepages appropriately along with a warning about what might happen if don't allocate enough 1 and 3 are trivial. 2 is a little trickier if we want to try to detect the page size. We could just not try and let the user specify it. Perhaps even use ZEND_ALLOC_HUGE_PAGES directly. As in: ZEND_ALLOC_HUGE_PAGES=2048 would turn on huge pages in the allocator with 2k pages. -Rasmus -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php