|
We're always working to improve performance PHP7 of last month, we note that the GCC PGO on Wordpress can bring nearly 10% performance boost, this makes us very excited.
However, PGO as the name implies (Profile Guided Optimization interested can Google), he needs to use a number of use cases to get feedback, that this is the need to optimize a particular scene and binding.
You optimize a scene, perhaps in another scene on a backfire. It is not a common optimization. So we can not simply contains these optimizations can not directly publish PGO compiled PHP7.
Of course, we are trying to find some common optimization from PGO, and then manually Apply to PHP7 up, but this obviously can not do specifically optimized for a scene that can be achieved, so I decided to write this article a brief introduction how to use PGO compiled PHP7, so that you can compile PHP7 special make your own independent applications faster.
First, decide what means is the scene to Feedback GCC, we usually choose: you want to optimize the scene: the most visited, most time-consuming, resource consumption heaviest one page.
Take Wordpress as an example, we have chosen Wordpress home (because Home is often the most visited).
We my machine as an example:
Intel (R) Xeon (R) CPU X5687 @ 3.60GHz X 16 (Hyper-Threading),
48G Memory
php-fpm using a fixed 32 worker, opcache default configuration (must remember to load opcache)
In order to optimize the scene .. wordpress 4.1
First, we have to test the performance of the current WP PHP7 of (ab -n 10000 -c 100):
$ Ab -n 10000 -c 100 http://inf-dev-maybach.weibo.com:8000/wordpress/
This is ApacheBench, Version 2.3 <$ Revision: 655654 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/
Benchmarking inf-dev-maybach.weibo.com (be patient)
Completed 1000 requests
Completed 2000 requests
Completed 3000 requests
Completed 4000 requests
Completed 5000 requests
Completed 6000 requests
Completed 7000 requests
Completed 8000 requests
Completed 9000 requests
Completed 10000 requests
Finished 10000 requests
Server Software: nginx / 1.7.12
Server Hostname: inf-dev-maybach.weibo.com
Server Port: 8000
Document Path: / wordpress /
Document Length: 9048 bytes
Concurrency Level: 100
Time taken for tests: 8.957 seconds
Complete requests: 10000
Failed requests: 0
Write errors: 0
Total transferred: 92860000 bytes
HTML transferred: 90480000 bytes
Requests per second: 1116.48 [# / sec] (mean)
Time per request: 89.567 [ms] (mean)
Time per request: 0.896 [ms] (mean, across all concurrent requests)
Transfer rate: 10124.65 [Kbytes / sec] received
Wordpress 4.1 is currently visible on the machine, the QPS Home can to 1116.48. That is so many requests per second can be processed on the homepage,
Now, let us begin to teach GCC, so he ran Wordpress4.1 compile faster PHP7 come, first requires GCC 4.0 or later, but I suggest that you use GCC-4.8 or later (now the GCC-5.1).
The first step is to download PHP7 natural source, and then do ./configure. These are no different
Then there is the distinct place, we must first build a first pass PHP7, it will have to generate an executable file profile data:
$ Make prof-gen
Note that we use the prof-gen argument (this is the Makefile PHP7 unique, do not attempt to do so on other projects ha :))
Then, let's start training GCC:
$ Sapi / cgi / php-cgi -T 100 /home/huixinchen/local/www/htdocs/wordpress/index.php> / dev / null
Let php-cgi is run 100 times wordpress home to generate some of the profile information in this process.
Then we start the second compilation PHP7.
$ Make prof-clean
$ Make prof-use && make install
Yes, it's that simple, PGO compiled, and now we look at the performance of PGO compiled after PHP7:
$ Ab -n10000 -c 100 http://inf-dev-maybach.weibo.com:8000/wordpress/
This is ApacheBench, Version 2.3 <$ Revision: 655654 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/
Benchmarking inf-dev-maybach.weibo.com (be patient)
Completed 1000 requests
Completed 2000 requests
Completed 3000 requests
Completed 4000 requests
Completed 5000 requests
Completed 6000 requests
Completed 7000 requests
Completed 8000 requests
Completed 9000 requests
Completed 10000 requests
Finished 10000 requests
Server Software: nginx / 1.7.12
Server Hostname: inf-dev-maybach.weibo.com
Server Port: 8000
Document Path: / wordpress /
Document Length: 9048 bytes
Concurrency Level: 100
Time taken for tests: 8.391 seconds
Complete requests: 10000
Failed requests: 0
Write errors: 0
Total transferred: 92860000 bytes
HTML transferred: 90480000 bytes
Requests per second: 1191.78 [# / sec] (mean)
Time per request: 83.908 [ms] (mean)
Time per request: 0.839 [ms] (mean, across all concurrent requests)
Transfer rate: 10807.45 [Kbytes / sec] received
Now it can handle 1191.78 per QPS, and ascension to 7%. Not bad ha (Hey, did not you say that 10% of it? How to 7% of the? Oh, as I said before, we do try to analyze PGO something optimization, optimization and then put some generic manual Apply to PHP7 in. so to say, that to 3% more generic optimization has been included to PHP7 inside, of course, the work continues).
So it's that simple, we can use their products classic scenes to train GCC, simple steps, get promoted, why not do it |
|
|
|