Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
456 views
in Technique[技术] by (71.8m points)

php - PHP5 performance comparison, Windows and Linux

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.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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:

Web toolbar

So you can see that the web toolbar shows a 764ms time generation (increased because of xDebug and profiling, but still relevant). Webgrind shows:

  • 651 calls to file_exists() for a time of 232ms (which is a lot!)
  • 603 calls to filemtime() (211ms)
  • 230 calls to UniversalClassLoader->loadClass() (119ms)
  • 230 calls to UniversalClassLoader->findFile() (38ms)

On linux (slow computer), app_dev.php:

Web toolbar

298ms of total generation time (which is more than twice less than on windows).

  • 237 calls to UniversalClassLoader->findFile() (36ms => 4 times less)
  • 237 calls to UniversalClassLoader->loadClass() (20ms => 2 times less)
  • 623 calls to file_exists() (4ms only !!!)
  • 605 callsd to filemtime() (4ms only !!!)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...