php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #45942 D_FILE_OFFSET_BITS=64 causes PHP to run at half speed
Submitted: 2008-08-28 17:36 UTC Modified: 2008-09-03 21:05 UTC
From: jhuckaby at gmail dot com Assigned:
Status: Closed Package: Performance problem
PHP Version: 5.2.6 OS: Fedora Core 6
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: jhuckaby at gmail dot com
New email:
PHP Version: OS:

 

 [2008-08-28 17:36 UTC] jhuckaby at gmail dot com
Description:
------------
Compiling PHP with -D_FILE_OFFSET_BITS=64 causes the PHP interpreter 
to run at approximately half speed.  This includes basic math 
operations (no file reading/writing necessary to reproduce).

Output from script with PHP 5.2.6 compiled with the default 32 bit 
file offsets:

[root@dev-ops buildscripts]# /ipix/php/bin/php ~/benchmark.php 
CPU Benchmark: 319

Output from script with PHP 5.2.6 compiled with -
D_FILE_OFFSET_BITS=64:

[root@dev-ops buildscripts]# /ipix/php/bin/php ~/benchmark.php 
CPU Benchmark: 153

Please note this number represents the number of iterations through 
the loop in 1 second of runtime, so larger numbers are faster.

I have reproduced the same behavior with the bleeding edge CVS daily 
snapshot (php5.2-200808281630) and latest 5.2.6 stable, as well as 
5.2.4 stable.

My ./configure line:

CFLAGS="-D_FILE_OFFSET_BITS=64" ./configure --with-pgsql=/ipix/pgsql -
-enable-ftp --with-zlib --enable-shmop --enable-sysvsem --enable-
sysvshm --enable-sysvmsg --enable-pcntl --enable-mbstring --with-xsl -
-with-curl --with-curlwrappers --without-mysql --with-ldap --with-
ldap-sasl --with-apache=../apache_1.3.39 --prefix=/ipix/php --with-
config-file-path=/ipix/php/lib

Simply removing the CFLAGS="-D_FILE_OFFSET_BITS=64" doubles the speed 
of the test script.





Reproduce code:
---------------
<?php

$start_time = microtime(true);
$done = 0;
$count = 0;

while (!$done) {
	for ($idx = 0; $idx < 10000; $idx++) {
		$x = 45 * 67 / 2 + $idx - 239892382.23232323;
		$y = 3483434.33483 / 28328372 * 384 + $idx - $x;
	}
	$count++;
	$now = microtime(true);
	if ($now - $start_time >= 1.0) { $done = 1; }
}

print "CPU Benchmark: $count\n";

?>



Expected result:
----------------
[root@dev-ops buildscripts]# /ipix/php/bin/php ~/benchmark.php 
CPU Benchmark: 319

The output of the script should be nearly identical whether the 
D_FILE_OFFSET_BITS is set to 64 or not.

The benchmark number is the number of iterations through the loop that 
was achieved in 1 second of runtime, so larger numbers are faster.





Actual result:
--------------
[root@dev-ops buildscripts]# /ipix/php/bin/php ~/benchmark.php 
CPU Benchmark: 153

(This is about half the speed it should be -- larger numbers are better, 
as this is a count of the iterations for one second of runtime.)





Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2008-08-28 21:07 UTC] jani@php.net
Try without any other stuff included, using --disable-all --disable-cgi as only configure options. And run that script at least 10 times in a row..
 [2008-08-28 21:20 UTC] jhuckaby at gmail dot com
Good idea.

CFLAGS="-D_FILE_OFFSET_BITS=64" ./configure --disable-all --disable-
cgi --with-apache=../apache_1.3.39 --prefix=/ipix/php --with-config-
file-path=/ipix/php/lib

[root@dev-ops buildscripts]# /ipix/php/bin/php ~/benchmark.php 
CPU Benchmark: 156
[root@dev-ops buildscripts]# /ipix/php/bin/php ~/benchmark.php 
CPU Benchmark: 157
[root@dev-ops buildscripts]# /ipix/php/bin/php ~/benchmark.php 
CPU Benchmark: 157
[root@dev-ops buildscripts]# /ipix/php/bin/php ~/benchmark.php 
CPU Benchmark: 156
[root@dev-ops buildscripts]# /ipix/php/bin/php ~/benchmark.php 
CPU Benchmark: 156
[root@dev-ops buildscripts]# /ipix/php/bin/php ~/benchmark.php 
CPU Benchmark: 156
[root@dev-ops buildscripts]# /ipix/php/bin/php ~/benchmark.php 
CPU Benchmark: 156
[root@dev-ops buildscripts]# /ipix/php/bin/php ~/benchmark.php 
CPU Benchmark: 156
[root@dev-ops buildscripts]# /ipix/php/bin/php ~/benchmark.php 
CPU Benchmark: 156
[root@dev-ops buildscripts]# /ipix/php/bin/php ~/benchmark.php 
CPU Benchmark: 156

./configure --disable-all --disable-cgi --with-apache=../apache_1.3.39 
--prefix=/ipix/php --with-config-file-path=/ipix/php/lib

[root@dev-ops buildscripts]# /ipix/php/bin/php ~/benchmark.php 
CPU Benchmark: 285
[root@dev-ops buildscripts]# /ipix/php/bin/php ~/benchmark.php 
CPU Benchmark: 293
[root@dev-ops buildscripts]# /ipix/php/bin/php ~/benchmark.php 
CPU Benchmark: 289
[root@dev-ops buildscripts]# /ipix/php/bin/php ~/benchmark.php 
CPU Benchmark: 298
[root@dev-ops buildscripts]# /ipix/php/bin/php ~/benchmark.php 
CPU Benchmark: 287
[root@dev-ops buildscripts]# /ipix/php/bin/php ~/benchmark.php 
CPU Benchmark: 293
[root@dev-ops buildscripts]# /ipix/php/bin/php ~/benchmark.php 
CPU Benchmark: 286
[root@dev-ops buildscripts]# /ipix/php/bin/php ~/benchmark.php 
CPU Benchmark: 289
[root@dev-ops buildscripts]# /ipix/php/bin/php ~/benchmark.php 
CPU Benchmark: 298
[root@dev-ops buildscripts]# /ipix/php/bin/php ~/benchmark.php 
CPU Benchmark: 285

Still almost twice as fast when I remove the D_FILE_OFFSET_BITS flag.
 [2008-08-29 19:03 UTC] crrodriguez at suse dot de
You dont pass D_FILE_OFFSET_BITS=64 directly, but add

AC_SYS_LARGEFILE

to configure.in then run ./buildconf --force and rebuild PHP.

BTW.. it is known that large file support may not work currenlty with PHP.
 [2008-08-29 20:28 UTC] jhuckaby at gmail dot com
Okay, I followed your instructions.  I added AC_SYS_LARGEFILE to configure.in, then ran ./buildconf --force.  Then I followed with ./configure..., make, and make install.  I found the following output from ./configure of interest:

checking for special C compiler options needed for large files... no
checking for _FILE_OFFSET_BITS value needed for large files... unknown
checking for _LARGE_FILES value needed for large files... unknown

Anyway, it compiled clean and installed.  And it seems to work correctly, writing >2GB large files without error AND the interpreter speed is fast!  Thanks!

[root@dev-ops php-5.2.6]# /ipix/php/bin/php ~/benchmark.php 
CPU Benchmark: 310
[root@dev-ops php-5.2.6]# /ipix/php/bin/php ~/benchmark.php 
CPU Benchmark: 311
[root@dev-ops php-5.2.6]# /ipix/php/bin/php ~/benchmark.php 
CPU Benchmark: 312
[root@dev-ops php-5.2.6]# /ipix/php/bin/php ~/benchmark.php 
CPU Benchmark: 306
[root@dev-ops php-5.2.6]# /ipix/php/bin/php ~/benchmark.php 
CPU Benchmark: 311

I guess we can close this bug!
 [2008-08-29 21:27 UTC] jhuckaby at gmail dot com
Wait, I spoke too soon!  Please don't close the bug yet.  As soon as I 
removed the "--disable-all --disable-cgi" ./configure command-line 
options, I got this build error from the "make" step:

/home/jhuckaby/dev/3rdparty/source/apache-1.3/php-
5.2.7/ext/posix/posix.c: In function 'zif_posix_uname':
/home/jhuckaby/dev/3rdparty/source/apache-1.3/php-
5.2.7/ext/posix/posix.c:471: error: 'struct utsname' has no member 
named 'domainname'
make: *** [ext/posix/posix.lo] Error 1

I didn't add any new command-line options, I simply removed the "--
disable-all --disable-cgi".

./configure --with-apache=../apache_1.3.39 --prefix=/ipix/php --with-
config-file-path=/ipix/php/lib  --disable-all --disable-cgi

Any ideas?

Should I file this under a separate bug?
 [2008-08-29 21:30 UTC] jhuckaby at gmail dot com
I should have also noted, this same error happens with 5.2.4 stable, 
5.2.6 stable, and the CVS daily snapshot build for Aug 29, 2008.
 [2008-09-03 21:05 UTC] jhuckaby at gmail dot com
This can be solved by using AC_SYS_LARGEFILE and a more modern operating 
system (tested with Mac OS X 10.5 and Fedora 9).  Apparently Fedora Core 
6 is too old to support the flag.  I am closing this bug.
 [2011-12-09 21:48 UTC] jhuckaby at gmail dot com
Just a follow-up note.  I was wrong about closing the bug.  This is still an open 
issue.  When using AC_SYS_LARGEFILE, PHP still fails to write more than 2 GB to a 
file -- it just doesn't throw any kind of error.

To this day, even with PHP 5.3.6, the only way to get true large file support 
seems to be adding the -D_FILE_OFFSET_BITS=64 compile flag, which still causes a 
50% runtime performance penalty.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Mon Dec 23 06:01:30 2024 UTC