php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #41193 relative paths affecting script performance (compared to 5.1.x)
Submitted: 2007-04-25 21:56 UTC Modified: 2008-08-06 01:00 UTC
Votes:8
Avg. Score:4.6 ± 0.5
Reproduced:7 of 7 (100.0%)
Same Version:6 (85.7%)
Same OS:7 (100.0%)
From: mauroi at digbang dot com Assigned: dmitry (profile)
Status: No Feedback Package: Performance problem
PHP Version: 5.2.3 OS: Win32
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: mauroi at digbang dot com
New email:
PHP Version: OS:

 

 [2007-04-25 21:56 UTC] mauroi at digbang dot com
Description:
------------
First of all, I couldn't reproduce this on Linux. Maybe because it doesn't exist, or maybe because of worse perfomance on filesystem operations on Windows.
We've found a performance degradation between PHP5.1.6 and PHP5.2.x (also checked with PHP5.2.2rc1) when including a file with a relative path. It gets notorious if using include_path and it has a big number of directories.
In the provided zip file you'll find 8 directories. Only one of them contains the file that will be required by the main script. So, script.php & script1.php show the problem. script.php only requires the file one time, and even in that case you'll see the difference. script1.php iterates including a non-existant file (that's why errors ar supressed) and the execution time is twice as big.
At first glance this could look as a bug with less importance, but any framework that uses __autoload & include_path with some sort of frequency, will be slower on PHP5.2 on Windows. Also, any site using MVC (not even using __autoload) and relative paths could be affected.

Thank you very much.

Reproduce code:
---------------
http://webmail.digbang.com/include_performance.zip

# one inclusion
php -n script.php

# multiple inclusions
php -n script1.php


Expected result:
----------------
Same or better performance on PHP5.2.x than in PHP5.1.6


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-05-09 15:36 UTC] mark at markwest dot me dot uk
I can reproduce what I believe to be the same issue too.

A very simple test case to highlight this issue is 

<?php
for ($i = 0; $i < 5000; $i++) {
    if (is_readable('test.txt')) {
        // dummy - do nothing!
    }
}
?>

Sample results, measured using xdebug, are as follows

is_readable with non-existent file
5.1.6 5000 calls to is_readable taking 166ms
5.2.2 5000 calls to is_readable taking 1511ms

is_readable with existing file
5.1.6 5000 calls to is_readable taking 135ms
5.2.2 5000 calls to is_readable taking 151ms

When the file isn't present php 5.2.x takes significantly longer that in previous releases.

-Mark
 [2007-05-09 15:47 UTC] mauroi at digbang dot com
Thanks Mark... The original example comes from a real life application, but yours is far much better. Hope someone will take a look at it now it's simpler.

Regards,
Mauro.
 [2007-06-15 02:49 UTC] sfox@php.net
Just to add to this report - it looks very much like it's impacting PHP-GTK (CLI only) Windows users too.

The base demo script in the PHP-GTK distro is reportedly 'twice as slow' under 5.2.3 as it is under 5.1.6 in the same environment with the same GTK+ libraries in tow.

The base demo script includes a long list of class files via relative includes. The relevant bit of code goes:

protected function load_demos()
    {
        $files = glob(dirname(__FILE__).'/components/*.php');
        foreach ($files as $id => $file) {
            $GLOBALS['class'] = null;
            if (basename($file) != basename(__FILE__)) {
                if (!@include_once($file)) {
                    continue;
                }
etc
(see http://cvs.php.net/viewvc.cgi/php-gtk/demos/phpgtk2-demo.php?content-type=text%2Fplain&view=co for the murky details)

The performance difference is also reported as 'visibly noticeable' between relative and hard-coded paths under 5.2.3, although that's a less direct comparison.

Ping me if you think I can help with any donkeywork, this one's fairly major for us and may hold up our 'surprise release', given that the demo scripts number rather less than the number of includes you could expect in a RL application.

- Steph
 [2007-07-14 09:12 UTC] jani@php.net
Dmitry, please check this out. 
 [2008-04-03 16:17 UTC] mh at nextra dot ch
It's still there in 5.3.0-dev.
 [2008-07-29 10:41 UTC] dmitry@php.net
I don't see any slowdown with current 5.2 and 5.3

5.1.7-dev: 483.88600349426
5.2.7-dev: 479.18510437012
5.3.0-dev: 424.29900169373

 [2008-08-06 01:00 UTC] php-bugs at lists dot php dot net
No feedback was provided for this bug for over a week, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Dec 26 20:01:29 2024 UTC