Slow HHVM performance

I evaluate HipHop-PHP for compatibility and performance on our code base, but when working with the embedded web server I get very poor performance.

I have the following test program that calculates the Fibonacci sequence.

ex3.php:

function fib($n) { if ($n <= 2) return 1; else return fib($n-1) + fib($n-2); } $n = 36; printf("fib(%d) = %d\n", $n, fib($n, 2)); 

When I run this through HHVM using the command line, I get impressive results:

 time hhvm -v"Eval.Jit=true" -f ./ex3.php fib(36) = 14930352 real 0m0.267s user 0m0.248s sys 0m0.020s 

Compare this with standard PHP:

 root@hiphop:/www# time php -f ./ex3.php fib(36) = 14930352 real 0m5.606s user 0m5.600s sys 0m0.000s 

However, when I want to enable the embedded web server in HHVM, all performance losses are lost:

 hhvm -v"Eval.Jit=true" -m server -p 8000 & time wget -qSO - http://localhost:8000/ex3.php HTTP/1.1 200 OK Content-Type: text/html; charset=utf-8 X-Powered-By: HPHP Date: Sat, 27 Jul 2013 14:16:09 GMT Content-Length: 19 fib(36) = 14930352 real 0m5.279s user 0m0.000s sys 0m0.000s 

As you can see, I get a response from HHVM, but it takes more than 5 seconds to process this request. What am I missing?

+42
performance hhvm
Jul 27 '13 at 14:19
source share
3 answers

HHVM engineer is here.

In server mode, HHVM will start the first N requests that it sees in interpreter-only mode (i.e., when JIT is disabled).

The default value in the optimized assembly is N = 11, so if you run the query 12 times, the 12th will be much faster.

You can configure this using the configuration option, for example: -v Eval.JitWarmupRequests=3 . If you set it to 0, you will immediately see acceleration.

There are several reasons for this.

Firstly, it prevents the effects of temporary demining from being affected by JIT-compiled code.

For example, for the first few queries, you may need to fill in the values ​​in APC, which will cause the application code to go along different paths from established paths. Thus, we do not lose space in JIT compilations, which will be used only a few times.

Secondly, it allows HHVM to collect profiling data to improve future compilation.

If we notice that a certain value is an integer in 99% of cases, for example, we can compile code optimized for an integer case. We currently do not have the ability to compile JIT code with profiling enabled (the difficult part safely discards it when we finish with it), so we collect data in interpreter-only mode.

+97
Jul 28 '13 at 21:55
source share

I have the same performance issue, and I get impressive results only after commenting out these lines in /etc/hhvm/php.ini

 ;hhvm.log.level = Warning ;hhvm.log.always_log_unhandled_exceptions = true ;hhvm.log.runtime_error_reporting_level = 8191 
+2
Mar 19 '15 at 12:32
source share

if HHVM> v3.4 Changed Eval.JitWarmupRequests = 0 to Eval.JitProfileInterpRequests = 0

 `#! / usr / bin / hhvm -v Eval.Jit = 1 -v Eval.JitProfileInterpRequests = 0. / do.php`
+2
Apr 26 '15 at 2:47
source share



All Articles