function fib($n) { if ($n <= 1) { return $n; } else { return fib($n - 1) + fib($n - 2); } }
$n = 30; $r = fib($n); echo "Fibonacci number $n is $r\n";
As indicated in the benchmark, it's a dumb exponential implementation.
29 karma · joined December 18, 2013
function fib($n) { if ($n <= 1) { return $n; } else { return fib($n - 1) + fib($n - 2); } }
$n = 30; $r = fib($n); echo "Fibonacci number $n is $r\n";
As indicated in the benchmark, it's a dumb exponential implementation.
I tried tweaking the nginx setup, especially the tcp_nodelay & keepalive_timeout settings. It provided maybe 15% speed up, nothing dramatic. I probably didn't collect enough datapoints to be able to reliably tell. In the end, I sticked to the nginx defaults.
If you would like to have the test re-run, you'll have to harass some real FB engineers, since the test was performed on a devbox that I don't have access too anymore. You're also more then welcome to try it yourself and post some alternate benchmarks.
I think I can promise to link to your results from the blog post.
Yes, we used opcode cache in PHP. I definitely don't consider myself to be an expert on PHP configuration. I used the default settings. I was obviously also very suspicious of the results that we got. To the extent, that I consulted a few people about what could be improved about the PHP setup. I remember opcode cache was the first thing I checked, since it's something everyone knows and talks about. It was turned on.
I will update the blog post first thing tomorrow (sorry guys, it's the middle of a night here in Poland, so don't feel like doing it right now).
Cheers.