Make your PHP7 faster hugepage usage analysis, php7hugepage
The example in this article tells you how to make your PHP7 faster hugepage usage. Share to everyone for your reference, as follows:
PHP7 just released RC4, contains bug fixes and one of our latest performance improvement results (news), which is "Hugepagefy PHP TEXT segment", by enabling this feature, PHP7 will "move" its TEXT segment (the actuator) To Huagepage, before the test, we can stabilize on WordPress to see the 2%~3% of the QPS ascension.
About Hugepage is what, simply say is the default memory is 4KB paging, and the virtual address and memory address is required to convert, and this conversion is to look up the table, the CPU in order to speed up the process will be built TLB (translation lookaside Buffer) , it is obvious that the smaller the virtual page, the more entries in the table, and the TLB size is limited, the more the number of entries TLB cache Miss will be higher, so if we can enable the large memory page can indirectly reduce the TLB cache Miss, as for the detailed introduction, Google a large search a lot of I will not repeat, here is the main instructions on how to enable this new feature, resulting in a significant performance improvement.
The new Kernel enable Hugepage has become very easy for me to develop virtual machines for example (Ubuntu Server 14.04,kernel 3.13.0-45), if we look at memory information:
$ cat/proc/meminfo | grep hugeanonhugepages: 444416 kbhugepages_total: 0hugepages_free: 0HUGEPAGES_RSVD: 0hugepages_ Surp: 0Hugepagesize: 2048 KB
A hugepage size of 2MB is visible, and hugepages is not currently enabled. Now let us compile PHP RC4, remember must not add: –disable-huge-code-pages (this new feature is enabled by default, you add this is off)
Then configure Opcache, starting from PHP5.5 Opcache is already enabled by default, but is compiled by the dynamic library, so we still want to configure the load in php.ini.
Zend_extension=opcache.so
This new feature is done in Opcache, so also to enable this feature via Opcache (by setting the Opcache.huge_code_pages=1), the specific configuration:
Opcache.huge_code_pages=1
Now let's configure the OS to allocate some hugepages:
$ sudo sysctl vm.nr_hugepages=128vm.nr_hugepages = 128
Now let's check the memory information again:
$ cat/proc/meminfo | grep hugeanonhugepages: 444416 kbhugepages_total: 128hugepages_free: 128HUGEPAGES_RSVD: 0hugepages_surp: 0Hugepagesize: 2048 KB
You can see that the 128 hugepages we've allocated are ready, and then we'll start php-fpm:
$/home/huixinchen/local/php7/sbin/php-fpm[01-oct-2015 09:33:27] NOTICE: [Pool www] ' user ' directive is ignored when FPM I s not running as root[01-oct-2015 09:33:27] NOTICE: [Pool www] ' group ' directive was ignored when FPM was not running as Roo T
Now, check the memory information again:
$ cat/proc/meminfo | grep hugeanonhugepages: 411648 kbhugepages_total: 128hugepages_free: 113HUGEPAGES_RSVD: 27hugepages_surp: 0Hugepagesize: 2048 KB
Speaking of which, if Hugepages is available, in fact Opcache will also use Hugepages to store the opcodes cache, so in order to verify that opcache.huge_code_pages does take effect, we might as well close Opcache.huge_code _pages, and then start again after looking at the memory information:
$ cat/proc/meminfo | grep hugeanonhugepages: 436224 kbhugepages_total: 128hugepages_free: 117HUGEPAGES_RSVD: 27hugepages_surp: 0Hugepagesize: 2048 KB
Visible when Huge_code_pages is turned on, the FPM starts with 4 pages, and now we check the text size of the PHP-FPM:
$ size/home/huixinchen/local/php7/sbin/php-fpm text data BSS Dec hex filename10114565 695200 131528 10941293 a6f36d /home/huixinchen/local/php7/sbin/php-fpm
The text segment is 10,114,565 bytes in size and requires a total of 4.8 or so 2M pages, taking into account the alignment (the tail is less than 2M page part does not move), apply for 4 pages, exactly as we see the match.
Description the configuration was successful! Enjoy!
But their assertions, when This feature is enabled, the problem is that if you try to profiling through perf Report/anno, you will find that the symbol is missing (Valgrind, GDB is not affected), The main reason for this is that the perf design uses the listener mmap, then records the address range, does the IP to the symbol conversion, but at present Hugetlb only supports Map_anon, therefore causes the perf to think this part address does not have the symbolic information , Hopefully later versions of kernel can fix this limitation.
Finally: Performance comparison test task is left to everyone to try, welcome to comment on the changes you see!
I hope this article is helpful to you in PHP programming.
http://www.bkjia.com/PHPjc/1133041.html www.bkjia.com true http://www.bkjia.com/PHPjc/1133041.html techarticle let your PHP7 faster hugepage usage analysis, Php7hugepage This example describes the Hugepage usage that makes your PHP7 faster. Share to everyone for reference, specifically as follows: PHP7 just released ...