From: champs dot name at gmail dot com
Operating system: Windows Server 2003/IIS6
PHP version: 5.2.3
PHP Bug Type: Performance problem
Bug description: Low throughput with readfile/fpassthru
Description:
------------
With a client using a 10Mbps connection, it is possible to saturate the
pipe using print(fread(...)) in chunks of 32K or larger, but the throughput
of fpassthru() and readfile() is consistently ~1/3 of that speed. On the
other side of the coin, a client with sub-Mbit DSL is not able to complete
100MB downloads at all, unless readfile/fpassthru() is used.
This has been tested in different orders, at different times of day, and
on different, non-consecutive days.
Reproduce code:
---------------
if ($file = fopen($path, $mode)) {
$chunk_size = 32;
while(!feof($file)) {
print(fread($file, $chunk_size * 1024));
if (connection_status() == 0) {
flush();
}
else {
break;
}
}
fclose($file);
}
Expected result:
----------------
Similar throughput if while() block is replaced with "fpassthru($file)" or
"readfile($path)".
Actual result:
--------------
File is served at over 900kB/s with fread(), less than 300kB/s with
fpassthru/readfile().
--
Edit bug report at http://bugs.php.net/?id=41859&edit=1
--
Try a CVS snapshot (PHP 4.4):
http://bugs.php.net/fix.php?id=41859&r=trysnapshot44
Try a CVS snapshot (PHP 5.2):
http://bugs.php.net/fix.php?id=41859&r=trysnapshot52
Try a CVS snapshot (PHP 6.0):
http://bugs.php.net/fix.php?id=41859&r=trysnapshot60
Fixed in CVS: http://bugs.php.net/fix.php?id=41859&r=fixedcvs
Fixed in release:
http://bugs.php.net/fix.php?id=41859&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=41859&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=41859&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=41859&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=41859&r=support
Expected behavior: http://bugs.php.net/fix.php?id=41859&r=notwrong
Not enough info:
http://bugs.php.net/fix.php?id=41859&r=notenoughinfo
Submitted twice:
http://bugs.php.net/fix.php?id=41859&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=41859&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=41859&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=41859&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=41859&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=41859&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=41859&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=41859&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=41859&r=mysqlcfg