zendtech / ZendOptimizerPlus

Other
915 stars 142 forks source link

Partial page output when using zend optimizer+ #63

Closed bitinn closed 11 years ago

bitinn commented 11 years ago

This is my config:

zend_optimizerplus.enable=1 zend_optimizerplus.memory_consumption=128 zend_optimizerplus.interned_strings_buffer=8 zend_optimizerplus.max_accelerated_files=4000 zend_optimizerplus.revalidate_freq=10 zend_optimizerplus.fast_shutdown=1 zend_optimizerplus.enable_cli=1 zend_optimizerplus.optimization_level=0 zend_optimizerplus.error_log=/var/log/zendop.log

I am using codeigniter as my php framework, once I switch zo+ on, all page output appear to be "cut off" at a certain point (randomly), never finish to the end </html> tag.

the strange thing is that I saw no error in php or zo+ log, and the cut off point isn't linked to a specific variable.

outputing phpinfo() works without problem, I am wondering how should I even start to debug this problem?

bitinn commented 11 years ago

Previously php-fpm logging was not on, with it enabled, I am see this kind of logs every time I visit an affected page:

[13-Mar-2013 00:58:45] WARNING: [pool www] child 6734 exited with code 1 after 176.326628 seconds from start [13-Mar-2013 00:58:45] NOTICE: [pool www] child 6761 started

Without ZO+ it does not produce any of above logs.

Any tip to continue debugging it?

PS: unlike others, I do NOT see segfault error in log, just the child exit/restart

BTW: I am using the latest master, should I be using v7.0.0?

dstogov commented 11 years ago

You should use the latest master v7.0.1-dev. Also be sure that you completely recompile PHP and O+ for for th same PHP build. Which PHP version do you use? Linux? 32 or 64-bit PHP build?

I would say it might be a bug in code optimizaer, but you already switched it off using zend_optimizerplus.optimization_level=0.

You may try to check for possible memory corruptions running single FastCGI sapi instead of FPM.

USE_ZEND_ALLOC=0 valgrind sapi/cgi/php-cgi -b

bitinn commented 11 years ago

Yes I am using the latest source, though I am not sure what you mean by "completely recompile PHP"

My PHP version info:

php -v

PHP 5.3.10-1ubuntu3.5 with Suhosin-Patch (cli) (built: Jan 18 2013 23:40:19)
Copyright (c) 1997-2012 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2012 Zend Technologies

nginx -v

nginx version: nginx/1.1.19

phpinfo()

System  Linux moon 3.7.10-x86_64-linode30 #1 SMP Wed Feb 27 14:29:31 EST 2013 x86_64
Build Date  Jan 18 2013 23:42:58
Server API  FPM/FastCGI 

I posted a bit more info on: http://serverfault.com/questions/487310/using-zend-optimizer-with-php-fpm-nginx

(strange to see no one talking about ZO+ on serverfault/stackoverflow, at least none recently)

rlerdorf commented 11 years ago

Well, only a few people have any experience with this, and you will find those people here, not on serverfault/stackoverflow. But yes, the first suggestion there to try it without Suhosin is a good one. There are no guarantees this will work with Suhosin.

bitinn commented 11 years ago

@rlerdorf you are right, I just thought if PHP 5.5 were to bundle ZO+, they might as well advocate the community to test it first? :)

When I tried to google ZO+, I really don't see many Zend Server admin or PHP developer trying it out, maybe because it's new.

Anyway, will test default PHP later and report back.

bitinn commented 11 years ago

Tried same config with suhosin.simulation = On, still the same issue and logs

http://www.hardened-php.net/suhosin/configuration.html#suhosin.simulation

[13-Mar-2013 19:09:04] WARNING: [pool www] child 22663 exited with code 1 after
9.221262 seconds from start
[13-Mar-2013 19:09:04] NOTICE: [pool www] child 22682 started
[13-Mar-2013 19:09:04] WARNING: [pool www] child 22666 exited with code 1 after
7.460847 seconds from start
[13-Mar-2013 19:09:04] NOTICE: [pool www] child 22685 started
2013/03/13 19:08:59 [error] 10910#0: *4563 recv() failed (104: Connection reset
by peer) while reading response header from upstream, client: 180.173.15.248, se
rver: [site], request: "POST /port/1min HTTP/1.1", upstream: "fastcgi://127.0.0.1
:9000", host: "[site]", referrer: "https://[site]/port/1min"
2013/03/13 19:09:04 [error] 10910#0: *4563 readv() failed (104: Connection reset
 by peer) while reading upstream, client: 180.173.15.248, server: [site], request
: "POST /port/5min HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "[site]
", referrer: "https://[site]/port/5min"
2013/03/13 19:09:04 [error] 10911#0: *4590 readv() failed (104: Connection reset
 by peer) while reading upstream, client: 180.173.15.248, server: [site], request
dev01@moon:~$ 5min HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "[site]
", referrer: "https://[site]/port/5min"

PS: Given that quite a few linux distribution does apply suhosin to their default package (in my case Ubuntu), I am not sure how they will go forward with PHP 5.5...

bitinn commented 11 years ago

switch to https://launchpad.net/~ondrej/+archive/php5 for php 5.4 without suhosin, upgraded and re-compile ZO+ using new build and following config:

[zend]
zend_extension=/usr/lib/php5/20100525/ZendOptimizerPlus.so
zend_optimizerplus.enable=1
zend_optimizerplus.optimization_level=0
zend_optimizerplus.error_log=/var/log/zendop.log

Now the site works, BUT, neither phpinfo() nor php -v show ZO+, so I am guessing the module is not loaded for some reason. no error/warning/notice log from php-fpm or ZO+

I run into issue where make test output following:

Build complete.
Don't forget to run 'make test'.

ERROR: Cannot run tests without CLI sapi.

and my php-config --php-sapi return empty, is this the default result for php 5.4? or am I missing something.

ok so I am missing the config for php-cli, added and it output:

$ php -v
Zend Optimizer+ requires Zend Engine API version 220090626.
The Zend Engine API version 220100525 which is installed, is newer.
Contact Zend Technologies at http://www.zend.com/ for a later version of Zend Op
timizer+.

PHP 5.4.12-2~precise+1 (cli) (built: Mar  6 2013 08:01:44)
Copyright (c) 1997-2013 The PHP Group
Zend Engine v2.4.0, Copyright (c) 1998-2013 Zend Technologies

wait, doesn't ZO+ support 5.4.* already?

rlerdorf commented 11 years ago

Of course it does, but the one you built is for PHP 5.3. 220090626 is the API version for PHP 5.3.

bitinn commented 11 years ago

@rlerdorf thx, after downloading the source and running phpize again, now it appear to load correct. still can't seem to run make test like I did when in PHP 5.3.x though, Any idea what could have caused the ERROR: Cannot run tests without CLI sapi. error after upgrade?

rlerdorf commented 11 years ago

Which configure flags are you using? The CLI sapi is built by default unless you explicitly disable it using --disable-cli or --disable-all

bitinn commented 11 years ago
phpize
./configure
make

I tried it with explicit --with-php-config=/usr/bin/php-config previously, but got same error.

$ dpkg --get-selections | grep php
php-pear                                        install
php5-cli                                        install
php5-common                                     install
php5-curl                                       install
php5-dev                                        install
php5-fpm                                        install
php5-gd                                         install
php5-mcrypt                                     install
php5-mysql                                      install

$ ls -l /usr/bin/php*
lrwxrwxrwx 1 root root      21 Jun 27  2012 /usr/bin/php -> /etc/alternatives/ph
p
-rwxr-xr-x 1 root root 7994392 Mar  6 16:23 /usr/bin/php5
lrwxrwxrwx 1 root root      28 Jun 27  2012 /usr/bin/php-config -> /etc/alternat
ives/php-config
-rwxr-xr-x 1 root root    4527 Mar  6 16:23 /usr/bin/php-config5
lrwxrwxrwx 1 root root      24 Jun 27  2012 /usr/bin/phpize -> /etc/alternatives
/phpize
-rwxr-xr-x 1 root root    4739 Mar  6 16:23 /usr/bin/phpize5

_php-sapis_ were empty in php-config output, is it what might have caused it? I can't seem to find a config value for it

$ php-config
Usage: /usr/bin/php-config [OPTION]
Options:
  --prefix            [/usr]
  --includes          [-I/usr/include/php5 -I/usr/include/php5/main -I/usr/inclu
de/php5/TSRM -I/usr/include/php5/Zend -I/usr/include/php5/ext -I/usr/include/php
5/ext/date/lib ]
  --ldflags           [-L/usr/lib/php5  -L/usr/lib/x86_64-linux-gnu]
  --libs              [-lcrypt   -lz -lresolv -lcrypt -lonig -lstdc++ -lcrypto -
lssl -ldb -lqdbm -lbz2 -lz -lpcre -lcrypto -lssl -lrt -lm -ldl -lnsl  -lxml2 -lg
ssapi_krb5 -lkrb5 -lk5crypto -lcom_err -lxml2 -lxml2 -lxml2 -lcrypt -lxml2 -lxml
2 -lxml2 -lxml2 -lcrypt ]
  --extension-dir     [/usr/lib/php5/20100525]
  --include-dir       [/usr/include/php5]
  --man-dir           [/usr/share/man]
  --php-binary        [NONE]
  --php-sapis         [     ]
  --phpapi            [20100525]
  --configure-options [--prefix=/usr --with-apxs2=/usr/bin/apxs2 --with-config-f
ile-path=/etc/php5/apache2 --with-config-file-scan-dir=/etc/php5/apache2/conf.d
--build=x86_64-linux-gnu --host=x86_64-linux-gnu --sysconfdir=/etc --localstated
ir=/var --mandir=/usr/share/man --disable-debug --with-regex=php --disable-rpath
 --disable-static --with-pic --with-layout=GNU --with-pear=/usr/share/php --enab
le-calendar --enable-sysvsem --enable-sysvshm --enable-sysvmsg --enable-bcmath -
-with-bz2 --enable-ctype --with-db4 --with-qdbm=/usr --without-gdbm --with-iconv
 --enable-exif --enable-ftp --with-gettext --enable-mbstring --with-onig=/usr --
with-pcre-regex=/usr --enable-shmop --enable-sockets --enable-wddx --with-libxml
-dir=/usr --with-zlib --with-kerberos=/usr --with-openssl=/usr --enable-soap --e
nable-zip --with-mhash=yes --with-system-tzdata --with-mysql-sock=/var/run/mysql
d/mysqld.sock --without-mm --with-curl=shared,/usr --with-enchant=shared,/usr --
with-zlib-dir=/usr --with-gd=shared,/usr --enable-gd-native-ttf --with-gmp=share
d,/usr --with-jpeg-dir=shared,/usr --with-xpm-dir=shared,/usr/X11R6 --with-png-d
ir=shared,/usr --with-freetype-dir=shared,/usr --with-imap=shared,/usr --with-im
ap-ssl --enable-intl=shared --without-t1lib --with-ldap=shared,/usr --with-ldap-
sasl=/usr --with-mcrypt=shared,/usr --with-mysql=shared,/usr --with-mysqli=share
d,/usr/bin/mysql_config --with-pspell=shared,/usr --with-unixODBC=shared,/usr --
with-recode=shared,/usr --with-xsl=shared,/usr --with-snmp=shared,/usr --with-sq
lite3=shared,/usr --with-mssql=shared,/usr --with-tidy=shared,/usr --with-xmlrpc
=shared --with-pgsql=shared,/usr]
  --version           [5.4.12-2~precise+1]
  --vernum            [50412]
rlerdorf commented 11 years ago

This looks like more of an Ubuntu packaging issue than a PHP/ZO one. The php executable to be used for tests is gotten by calling: php-config --php-binary If that doesn't return a working php, then you can't run the tests. You can fix this manually by editing the Makefile in the ZO directory and near the top you will find a line like:

PHP_EXECUTABLE = /usr/bin/php

Set that to a working php binary and you should be able to run the tests.

bitinn commented 11 years ago

done that and it passes all 3 tests like in 5.3.x. that's some warm feeling :)

thx to @rlerdorf and @dstogov , and I should close this as a confirm on suhosin messing thing up.