I have a question about Symfony2 performance.
I have been developing with Symfony2 under Ubuntu 11.04 for a few weeks now, Apache 2.2.17, PHP 5.3.5, APC 3.1.9, no xDebug
On the dev environment, the time given on the Symfony2 toolbar was never above 70 ms.
Today, I've tried to install my app on a Windows 7 environment : Wampserver 2.2, PHP 5.3.8, Apache 2.2.21, APC 3.1.7, no xDebug
The computer on the windows environment is much better than the one on ubuntu (SSD, Quad core, etc).
And when I run the application on the dev environment, the toolbar indicates always a minimum of 300 ms.
So, do you know how it is possible ?
Thanks !
EDIT : found a link about the subject : http://fossplanet.com/f6/%5Bsymfony-users%5D-symfony2-slow-windows-xp-116465/
I noticed the problem with the file_exists function too (using webgrind).
So, any ideas ?
Maybe the subject has already been discussed, but I was surprised not to find anything related.
TL;DR; Set realpath_cache_size to a value > 1000
Edit 2: Problem solved in this PR: Try to set PHP.ini's realpath_cache_size to a value > 1000 A symfony requirement was recently added fixing this issue: https://github.com/sensiolabs/SensioDistributionBundle/commit/cf0179711b24d84d4a29d71a4010540f4c990bd8
Edit: I just saw this answer: https://stackoverflow.com/a/17914570/980547 And it decreased page generation time by 4 on windows when I set realpath_cache_size=4096k in my php.ini (!)
Old answer:
So, I did a comparison between both with webgrind:
On windows (fast computer), called app_dev.php:
So you can see that the web toolbar shows a 764ms time generation (increased because of xDebug and profiling, but still relevant). Webgrind shows:
On linux (slow computer), app_dev.php:
298ms of total generation time (which is more than twice less than on windows).
The problem seems to be file_exists() and filemtime(), which are much slower on windows than on Linux. On windows, PHP is looking for files with file_exists, filemtime, loadClass or findFile for 60% of the time. Is that a known problem ?
Edit : so the problem is only for the dev environment, in production no file_exists are done since everything is cached.
I just started developing with Symfony2 under Windows and this was a total pain in the ass - I tested xcache, apc and eaccelerator which either made nearly no difference or just crashed when used together with xdebug.
Now I discovered WinCache by Microsoft - which made Symfony2 under Windows unbelievable fast...
My requests took something between 1.5s to 3s - with WinCache its down to 200ms. And it doesn't even bother xdebug - profiling and debugging still works like a charm.
Edit: This is all about the dev environment.
The only downside is that it only runs on nts php and I think the apache modules requires ts - if you run it with fcgid though you will have no problems.
I can't believe I worked so many years without this monster...
Links:
WinCache on php.net
Official WinCache site
Binaries
Interesting found!
I would say since this is not a symfony2 issue at all, it has to be fixed in PHP binary..
But who runs his webserver on windows, anyway? :D
Make a try with ApcUniversalClassLoader http://symfony.com/doc/2.0/book/performance.html
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With