PHP / GCC / ICC Benchmark

Sebastian Bergmann » 07 November 2006 » in Benchmarks » 4 Comments

Last month I got a bit bored and built PHP 4.4.4, PHP 5.0.5, PHP 5.1.6, and current PHP_5_2 (the last two each with CALL, GOTO, and SWITCH VMs) with GCC 3.4.6 and GCC 4.1.1 with -O{0|1|2|3|s}. Yes, this means I built 80 PHP binaries. No, I did not do this manually.

Below are the results of running bench.php with each of the binaries that I built.

PHP 4.4.4, PHP 5.0.5, PHP 5.1.6, and PHP 5.2 built with GCC 3.4.6 and CFLAGS='-O{0|1|2|3|s}'

As you can see, PHP 5.1 and PHP 5.2 are both around three times faster than PHP 4.4 and PHP 5.0 (GCC 3.4.6, -O2).

PHP 4.4.4, PHP 5.0.5, PHP 5.1.6, and PHP 5.2 built with GCC 4.1.1 and CFLAGS='-O{0|1|2|3|s}'

Each binary ran the benchmark script five times, the numbers shown are the respective mean from the five runs.

The numbers for PHP 5.1.6 and PHP 5.2 are based upon the CALL-based virtual machine as GOTO and SWITCH did not work for most of the optimization levels.

Update: Yesterday I built PHP 4.4.4, PHP 5.0.5, PHP 5.1.6, and PHP 5.2.0 with ICC 9.1.042 using -O{0|1|2|3|s} and -fast.

PHP 4.4.4, PHP 5.0.5, PHP 5.1.6, and PHP 5.2.0 built with ICC 9.1.042 and CFLAGS='-O{0|1|2|3|s}' and CFLAGS='-fast'Below is a chart that directly compares GCC 3.4.6, GCC 4.1.1, and ICC 9.1.042.

GCC 3.4.6 vs GCC 4.1.1 vs ICC 9.1.042 for PHP 4.4.4, PHP 5.0.5, PHP 5.1.6, and PHP 5.2.0

The GCC versions used were Gentoo sys-devel/gcc-4.1.1-r1 and Gentoo sys-devel/gcc-3.4.6-r2 together with Gentoo sys-devel/binutils-2.17.

The CFLAGS used for GCC were "-march=pentium-m -msse3 -O{0|1|2|3|s} -pipe".

The configure options used were "--disable-all --disable-cgi".

The extended body of this posting contains the raw test results as well as detailed information on the hardware used to run the benchmarks.
Raw Data
PHP 4.4.4, gcc-3.4.6 (O0): 46.8846
PHP 4.4.4, gcc-3.4.6 (O1): 30.0452
PHP 4.4.4, gcc-3.4.6 (O2): 31.683
PHP 4.4.4, gcc-3.4.6 (O3): 31.9084
PHP 4.4.4, gcc-3.4.6 (Os): 29.8004
PHP 4.4.4, gcc-4.1.1 (O0): 49.53
PHP 4.4.4, gcc-4.1.1 (O1): 31.4644
PHP 4.4.4, gcc-4.1.1 (O2): 31.7962
PHP 4.4.4, gcc-4.1.1 (O3): 32.179
PHP 4.4.4, gcc-4.1.1 (Os): 32.6704
PHP 4.4.4, icc-9.1.042 (O0): 45.760
PHP 4.4.4, icc-9.1.042 (O1): 32.328
PHP 4.4.4, icc-9.1.042 (O2): 26.610
PHP 4.4.4, icc-9.1.042 (O3): 26.809
PHP 4.4.4, icc-9.1.042 (Os): 28.659
PHP 4.4.4, icc-9.1.042 (fast): 26.891
PHP 5.0.5, gcc-3.4.6 (O0): 48.5814
PHP 5.0.5, gcc-3.4.6 (O1): 29.0156
PHP 5.0.5, gcc-3.4.6 (O2): 28.8424
PHP 5.0.5, gcc-3.4.6 (O3): 28.8292
PHP 5.0.5, gcc-3.4.6 (Os): 26.655
PHP 5.0.5, gcc-4.1.1 (O0): 50.1632
PHP 5.0.5, gcc-4.1.1 (O1): 29.6024
PHP 5.0.5, gcc-4.1.1 (O2): 28.9848
PHP 5.0.5, gcc-4.1.1 (O3): 29.057
PHP 5.0.5, gcc-4.1.1 (Os): 32.6502
PHP 5.0.5, icc-9.1.042 (O0): 47.031
PHP 5.0.5, icc-9.1.042 (O1): 32.847
PHP 5.0.5, icc-9.1.042 (O2): 25.196
PHP 5.0.5, icc-9.1.042 (O3): 25.112
PHP 5.0.5, icc-9.1.042 (Os): 26.133
PHP 5.0.5, icc-9.1.042 (fast): 23.756
PHP 5.1.6 (VM: CALL), gcc-3.4.6 (O0): 19.9088
PHP 5.1.6 (VM: CALL), gcc-3.4.6 (O1): 12.0674
PHP 5.1.6 (VM: CALL), gcc-3.4.6 (O2): 11.398
PHP 5.1.6 (VM: CALL), gcc-3.4.6 (O3): 11.3282
PHP 5.1.6 (VM: CALL), gcc-3.4.6 (Os): 11.2306
PHP 5.1.6 (VM: CALL), gcc-4.1.1 (O0): 20.4064
PHP 5.1.6 (VM: CALL), gcc-4.1.1 (O1): 11.6848
PHP 5.1.6 (VM: CALL), gcc-4.1.1 (O2): 11.1316
PHP 5.1.6 (VM: CALL), gcc-4.1.1 (O3): 11.0876
PHP 5.1.6 (VM: CALL), gcc-4.1.1 (Os): 13.8992
PHP 5.1.6 (VM: CALL), icc-9.1.042 (O0): 20.522
PHP 5.1.6 (VM: CALL), icc-9.1.042 (O1): 13.966
PHP 5.1.6 (VM: CALL), icc-9.1.042 (O2): 10.301
PHP 5.1.6 (VM: CALL), icc-9.1.042 (O3): 10.353
PHP 5.1.6 (VM: CALL), icc-9.1.042 (Os): 11.001
PHP 5.1.6 (VM: CALL), icc-9.1.042 (fast): 9.331
PHP 5.1.6 (VM: GOTO), gcc-3.4.6 (O0): 18.8796
PHP 5.1.6 (VM: GOTO), gcc-3.4.6 (O2): 9.7342
PHP 5.1.6 (VM: GOTO), gcc-3.4.6 (O3): 9.972
PHP 5.1.6 (VM: GOTO), gcc-3.4.6 (Os): 10.051
PHP 5.1.6 (VM: GOTO), gcc-4.1.1 (O1): 10.216
PHP 5.1.6 (VM: GOTO), gcc-4.1.1 (O2): 9.8896
PHP 5.1.6 (VM: GOTO), gcc-4.1.1 (O3): 9.8724
PHP 5.1.6 (VM: GOTO), gcc-4.1.1 (Os): 12.7706
PHP 5.1.6 (VM: SWITCH), gcc-3.4.6 (O0): 20.0308
PHP 5.1.6 (VM: SWITCH), gcc-3.4.6 (O2): 10.2184
PHP 5.1.6 (VM: SWITCH), gcc-3.4.6 (O3): 10.3852
PHP 5.1.6 (VM: SWITCH), gcc-3.4.6 (Os): 12.2126
PHP 5.1.6 (VM: SWITCH), gcc-4.1.1 (O1): 10.6876
PHP 5.1.6 (VM: SWITCH), gcc-4.1.1 (O2): 10.564
PHP 5.1.6 (VM: SWITCH), gcc-4.1.1 (O3): 10.6248
PHP 5.1.6 (VM: SWITCH), gcc-4.1.1 (Os): 15.2186
PHP 5.2.0 (VM: CALL), gcc-3.4.6 (O0): 21.7908
PHP 5.2.0 (VM: CALL), gcc-3.4.6 (O1): 12.2534
PHP 5.2.0 (VM: CALL), gcc-3.4.6 (O2): 11.5976
PHP 5.2.0 (VM: CALL), gcc-3.4.6 (O3): 11.3194
PHP 5.2.0 (VM: CALL), gcc-3.4.6 (Os): 11.6044
PHP 5.2.0 (VM: CALL), gcc-4.1.1 (O0): 22.2472
PHP 5.2.0 (VM: CALL), gcc-4.1.1 (O1): 11.9178
PHP 5.2.0 (VM: CALL), gcc-4.1.1 (O2): 11.3162
PHP 5.2.0 (VM: CALL), gcc-4.1.1 (O3): 11.1834
PHP 5.2.0 (VM: CALL), gcc-4.1.1 (Os): 14.0054
PHP 5.2.0 (VM: CALL), icc-9.1.042 (O0): 21.687
PHP 5.2.0 (VM: CALL), icc-9.1.042 (O1): 14.391
PHP 5.2.0 (VM: CALL), icc-9.1.042 (O2): 10.331
PHP 5.2.0 (VM: CALL), icc-9.1.042 (O3): 10.477
PHP 5.2.0 (VM: CALL), icc-9.1.042 (Os): 11.338
PHP 5.2.0 (VM: CALL), icc-9.1.042 (fast): 9.763
PHP 5.2.0 (VM: GOTO), gcc-4.1.1 (Os): 12.8902
PHP 5.2.0 (VM: SWITCH), gcc-4.1.1 (Os): 15.1576
Output of cat /proc/cpuinfo
processor	: 0
vendor_id	: GenuineIntel
cpu family	: 6
model		: 14
model name	: Genuine Intel(R) CPU           L2400  @ 1.66GHz
stepping	: 8
cpu MHz		: 1000.000
cache size	: 2048 KB
physical id	: 0
siblings	: 2
core id		: 0
cpu cores	: 2
fdiv_bug	: no
hlt_bug		: no
f00f_bug	: no
coma_bug	: no
fpu		: yes
fpu_exception	: yes
cpuid level	: 10
wp		: yes
flags		: fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe nx constant_tsc pni monitor vmx est tm2 xtpr
bogomips	: 3328.67

processor	: 1
vendor_id	: GenuineIntel
cpu family	: 6
model		: 14
model name	: Genuine Intel(R) CPU           L2400  @ 1.66GHz
stepping	: 8
cpu MHz		: 1667.000
cache size	: 2048 KB
physical id	: 0
siblings	: 2
core id		: 1
cpu cores	: 2
fdiv_bug	: no
hlt_bug		: no
f00f_bug	: no
coma_bug	: no
fpu		: yes
fpu_exception	: yes
cpuid level	: 10
wp		: yes
flags		: fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe nx constant_tsc pni monitor vmx est tm2 xtpr
bogomips	: 3325.12
Output of x86info
x86info v1.20.  Dave Jones 2001-2006
Feedback to <davej@redhat.com>.

Found 2 CPUs
--------------------------------------------------------------------------
CPU #1
Family: 6 Model: 14 Stepping: 8 Type: 0 Brand: 0
CPU Model: Core  Original OEM
Feature flags:
 fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat clflsh ds acpi mmx fxsr sse sse2 ss ht tm pbe sse3 monitor vmx est tm2 xTPR
Extended feature flags:
 xd
Cache info
 L1 Instruction cache: 32KB, 8-way associative. 64 byte line size.
 L1 Data cache: 32KB, 8-way associative. 64 byte line size.
 L2 unified cache: 2MB, sectored, 8-way associative. 64 byte line size.
TLB info
 Instruction TLB: 4K pages, 4-way associative, 128 entries.
 Instruction TLB: 4MB pages, fully associative, 2 entries
 Data TLB: 4K pages, 4-way associative, 128 entries.
 Data TLB: 4MB pages, 4-way associative, 8 entries
 64 byte prefetching.
The physical package supports 2 logical processors 

--------------------------------------------------------------------------
CPU #2
Family: 6 Model: 14 Stepping: 8 Type: 0 Brand: 0
CPU Model: Core  Original OEM
Feature flags:
 fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat clflsh ds acpi mmx fxsr sse sse2 ss ht tm pbe sse3 monitor vmx est tm2 xTPR
Extended feature flags:
 xd
Cache info
 L1 Instruction cache: 32KB, 8-way associative. 64 byte line size.
 L1 Data cache: 32KB, 8-way associative. 64 byte line size.
 L2 unified cache: 2MB, sectored, 8-way associative. 64 byte line size.
TLB info
 Instruction TLB: 4K pages, 4-way associative, 128 entries.
 Instruction TLB: 4MB pages, fully associative, 2 entries
 Data TLB: 4K pages, 4-way associative, 128 entries.
 Data TLB: 4MB pages, 4-way associative, 8 entries
 64 byte prefetching.
The physical package supports 2 logical processors 

--------------------------------------------------------------------------
Defined tags for this entry: , ,

Trackback specific URI for this entry

4 Comments to "PHP / GCC / ICC Benchmark"

Display comments as (Linear | Threaded)
  1. Chuck Burgess
    24/10/2006 at 15:02 Permalink
    That was some Saturday night! It's interesting to me to see that the -Os flag, which I understood to only optimize the size of the resulting binary, looks to have equivalent results to the -O2 and -O3 speed optimization flags, at least on GCC 3.4. I also see that -Os did better in 3.4 than it did in 4.1. I don't keep close tabs on GCC's details, but these points did surprise me. Thanks for posting them! Also, "salute" to you from a fellow Gentoo users.

    Reply

  2. viric
    15/02/2007 at 23:00 Permalink
    Don't trust that "-Os" in the gcc 3 series. I've seen too many programs crash due to that flag.
    And half of my gentoo system is still compiled with it :)

    Reply

  3. Volker Buzek
    16/11/2006 at 14:56 Permalink
    Inspired by this, we ran a similar but less extensive test on a Sun Fire T2000 with Solaris 10:
    http://www.blogs.uni-erlangen.de/webworking/stories/648/

    Reply

  4. Artur
    02/01/2007 at 23:13 Permalink
    This is a little off-topic, but how do use use the PHP VM in a php statement? The reason I'm asking this is because I want to integrate a goto statement in my code, if you could help it would be very appreciated.

    Reply

3 Trackbacks to "PHP / GCC / ICC Benchmark"

  1. Gregory Szorc's blog 07/11/2006 at 15:09
    PHP / GCC / ICC Benchmarks If your hosting provider hasn't upgraded, show them these graphs. It is also worth...
  2. Sebastian Bergmann 26/03/2009 at 20:26
    Benchmarks such as the PHP / GCC / ICC Benchmark I posted quite a while ago on this blog are synthetic. They test "raw bytecode execution" speed that cannot be translated into real-world situations per se.Flickr recently migrated from PHP 4 to PHP 5. And
  3. infovm9-3.rrze.uni-erlangen.de 19/03/2010 at 11:39

Add Comment


To prevent automated Bots from commentspamming, please enter the string you see in the image below in the appropriate input box. Your comment will only be submitted if the strings match. Please ensure that your browser supports and accepts cookies, or your comment cannot be verified correctly.
CAPTCHA

Submitted comments will be subject to moderation before being displayed.