-
Notifications
You must be signed in to change notification settings - Fork 3k
Performance Tuning
This page will be a collection of wisdoms about how to get even more speed out of HHVM if you're willing to put some effort in. The percentages are just empirically what average speedups people have seen.
You may also want to look into profiling and optimizing the code actually running on HHVM.
Using RepoAuthoritative mode requires doing a "build" step to produce a bytecode archive in advance. If you have PHP files file1.php
and file2.php
, you can build a bytecode archive named hhvm.hhbc
by executing this command:
hhvm --hphp -thhbc -o some_dir file1.php file2.php
Now you will have a pre-compiled archive file named some_dir/hhvm.hhbc
. The file hhvm.hhbc
is actually an sqlite database file - you can even view the structure of the file using sqlite. This is similar to a java .jar
or a python .par
file. It is a stand-alone version of your scripts. To run the program file1.php
, use this command:
hhvm -vRepo.Authoritative=true -vRepo.Central.Path=some_dir/hhvm.hhbc file1.php
To run the program file2.php
, use this command:
hhvm -vRepo.Authoritative=true -vRepo.Central.Path=some_dir/hhvm.hhbc file2.php
Note: If you get the error message Unable to find/load systemlib.php
, make sure you are pointing at the hhvm.hhbc
file and not the directory.
The cache locality of the JITted code is very important, and you want all your important endpoint's code to be located close to each other in memory. The best way to accomplish this is to pick your most important requests (say 5) and cycle through them all serially until you've done them all 12 times. Something like
for i in `seq 12`; do
while read url; do
curl "$url"
done < important_urls.txt
done
Do this every time you startup the server before it sees user traffic.