Impact of CFLAGS on GOTO and SWITCH executers

php.internals

Sebastian Bergmann

19 years ago
Today I 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} [1]. CFLAGS: -march=pentium-m -msse3 -O{0|1|2|3|s} -pipe configure options: --disable-cgi --disable-all I let each of the resulting binaries run the PHP_5_2/Zend/bench.php script (five times). I noticed that for the following configurations the running of the bench.php script results in a segmentation fault: GCC 3.4.6 PHP 5.1.6 GOTO: -O1 SWITCH: -O1 PHP_5_2 GOTO: -O0, -O1, -O2, -O3, -Os SWITCH: -O0, -O1, -O2, -O3, -Os GCC 4.1.1 PHP 5.1.6 GOTO: -O0 SWITCH: -O0 PHP_5_2 GOTO: -O0, -O1, -O2, -O3 SWITCH: -O0, -O1, -O2, -O3 What strikes me as odd are the segmentation faults when PHP is built with -O0 (no optimizations). These results also beg the question how well supported/tested the two alternative executers, GOTO and SWITCH, are.
-- [1] Yes, these means I build 80 PHP binaries. -- Sebastian Bergmann http://sebastian-bergmann.de/ GnuPG Key: 0xB85B5D69 / 27A7 2B14 09E4 98CD 6277 0E5B 6867 C514 B85B 5D69

Sebastian Bergmann

19 years ago
Sebastian Bergmann wrote:
> What strikes me as odd are the segmentation faults when PHP is built > with -O0 (no optimizations).
Some more information of the segfaults: It looks as if the ackermann test is responsible for the segfaults. I uploaded a backtrace from GDB and a logfile from valgrind to http://static.phpunit.de/gdb-php_5_2-goto-gcc-4.1.1-O0.txt and http://static.phpunit.de/valgrind-php_5_2-goto-gcc-4.1.1-O0.txt, respectively.
-- Sebastian Bergmann http://sebastian-bergmann.de/ GnuPG Key: 0xB85B5D69 / 27A7 2B14 09E4 98CD 6277 0E5B 6867 C514 B85B 5D69

Ilia A.

19 years ago
Given the tricky nature of enabling different execution modes I'd be very surprised to see people use non-default values, so to your answer of how well tested other executors are, I'd say not a whole lot. On 15-Oct-06, at 9:21 AM, Sebastian Bergmann wrote:
> Sebastian Bergmann wrote: >> What strikes me as odd are the segmentation faults when PHP is built >> with -O0 (no optimizations). > > Some more information of the segfaults: It looks as if the ackermann > test is responsible for the segfaults. > > I uploaded a backtrace from GDB and a logfile from valgrind to > http://static.phpunit.de/gdb-php_5_2-goto-gcc-4.1.1-O0.txt and > http://static.phpunit.de/valgrind-php_5_2-goto-gcc-4.1.1-O0.txt, > respectively. > > -- > Sebastian Bergmann http://sebastian- > bergmann.de/ > GnuPG Key: 0xB85B5D69 / 27A7 2B14 09E4 98CD 6277 0E5B 6867 C514 > B85B 5D69 > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php > >
Ilia Alshanetsky

Dmitry Stogov

19 years ago
The reason of the crash is just a stack overflow. You use -O0 and unoptimized execute() function require a lot of stack space, because space for local variables is not reused. During execution of "ackermann" benchmark execute() is called recursively many times and eats all stack space... Dmitry.

Sebastian Bergmann

19 years ago
Dmitry Stogov wrote:
> You use -O0 and unoptimized execute() function require a lot of stack > space, because space for local variables is not reused.
Thank you for this explanation, Dmitry.
-- Sebastian Bergmann http://sebastian-bergmann.de/ GnuPG Key: 0xB85B5D69 / 27A7 2B14 09E4 98CD 6277 0E5B 6867 C514 B85B 5D69

Sara Golemon

19 years ago
> Today I 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} [1]. >
That's a nice trick considering that PHP4 doesn't have a CALL or GOTO vm...
> These results also beg the question how well supported/tested the two > alternative executers, GOTO and SWITCH, are. >
My guess is that there are only about ten people using alternate VMs to any serious degree and maybe a hundred who "tried it once". The VMs aren't a heavily advertised feature and I personally like the flexibility of the CALL version best. -Sara

Sebastian Bergmann

19 years ago
Sara Golemon wrote:
>> Today I 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} [1]. >> > That's a nice trick considering that PHP4 doesn't have a CALL or > GOTO vm.
Please read the part in the braces again and you will see that I meant PHP 5.1.6 and PHP 5_2.
-- Sebastian Bergmann http://sebastian-bergmann.de/ GnuPG Key: 0xB85B5D69 / 27A7 2B14 09E4 98CD 6277 0E5B 6867 C514 B85B 5D69