Giter Club home page Giter Club logo

zendoptimizerplus's Introduction

The Zend OPcache
================

The Zend OPcache provides faster PHP execution through opcode caching and
optimization. It improves PHP performance by storing precompiled script
bytecode in the shared memory. This eliminates the stages of reading code from
the disk and compiling it on future access. In addition, it applies a few
bytecode optimization patterns that make code execution faster.

Compatibility
-------------

This version of Zend OPcache is compatible with PHP 5.2.*, 5.3.*, 5.4.* branch.

For PHP 5.5+, please use the bundled Zend Opcache.

Quick Install
-------------

- Compile

 $PHP_DIR/bin/phpize
 ./configure \
      --with-php-config=$PHP_DIR/bin/php-config
 make

- Install

 make install # this will copy opcache.so into PHP extension directory

- Edit php.ini

 zend_extension=/...full path.../opcache.so

NOTE: In case you are going to use Zend OPcache together with Xdebug or Zend Debugger,
be sure that the debugger is loaded after OPcache. "php -v" must show the debugger
after OPcache.

- Restart PHP

Speed Tuning
-------------

We recommend the following configuration options for best performance
in a production environment.

opcache.memory_consumption=128
opcache.interned_strings_buffer=8
opcache.max_accelerated_files=4000
opcache.revalidate_freq=60
opcache.fast_shutdown=1
opcache.enable_cli=1

You also may add the following, but it may break some applications and
frameworks. Please, read description of these directives and add them on your
own risk.

opcache.save_comments=0
opcache.enable_file_override=1

In some cases you may like to prefer enabling/disabling some features
to avoid incompatibilities at the cost of some performance degradation.

For development environment we would recommend setting opcache.revalidate_freq
into 0.

Configuration Directives
------------------------

opcache.enable (default "1")
	OPcache On/Off switch. When set to Off, code is not optimized and cached.

opcache.enable_cli (default "0")
	Enables the OPcache for the CLI version of PHP. It's mostly for testing
	and debugging.

opcache.memory_consumption (default "64")
	The OPcache shared memory storage size. The amount of memory for storing
	precompiled PHP code in Mbytes.

opcache.interned_strings_buffer (default "4")
	The amount of memory for interned strings in Mbytes.

opcache.max_accelerated_files (default "2000")
	The maximum number of keys (scripts) in the OPcache hash table.
	The number is actually the first one in the following set of prime
	numbers that is bigger than the one supplied: { 223, 463, 983, 1979, 3907,
	7963, 16229, 32531, 65407, 130987, 262237, 524521, 1048793 }. Only numbers
	between 200 and 1000000 are allowed.

opcache.max_wasted_percentage (default "5")
	The maximum percentage of "wasted" memory until a restart is scheduled.

opcache.use_cwd (default "1")
	When this directive is enabled, the OPcache appends the current working
	directory to the script key, thus eliminating possible collisions between
	files with the same name (basename). Disabling the directive improves
	performance, but may break existing applications.

opcache.validate_timestamps (default "1")
	When disabled, you must reset the OPcache manually or restart the
	webserver for changes to the filesystem to take effect.
	The frequency of the check is controlled by the directive
	"opcache.revalidate_freq".

opcache.revalidate_freq (default "2")
	How often (in seconds) to check file timestamps for changes to the shared
	memory storage allocation. ("1" means validate once per second, but only
	once per request. "0" means always validate)

opcache.file_update_protection (default "2")
	Prevents caching files that are less than this number of seconds old.
	It protects from caching of incompletely updated files. In case all file
	updates on your site are atomic, you may increase performance setting it
	to "0".

opcache.revalidate_path (default "0")
	Enables or disables file search in include_path optimization
	If the file search is disabled and a cached file is found that uses
	the same include_path, the file is not searched again. Thus, if a file
	with the same name appears somewhere else in include_path, it
	won't be found. Enable this directive if this optimization has an effect on
	your applications. The default for this directive is disabled, which means
	that optimization is active.

opcache.save_comments (default "1")
	If disabled, all PHPDoc comments are dropped from the code to reduce the
	size of the optimized code. Disabling "Doc Comments" may break some
	existing applications and frameworks (e.g. Doctrine, ZF2, PHPUnit)

opcache.load_comments (default "1")
	If disabled, PHPDoc comments are not loaded from SHM, so "Doc Comments"
	may be always stored (save_comments=1), but not loaded by applications
	that don't need them anyway.

opcache.fast_shutdown (default "0")
	If enabled, a fast shutdown sequence is used for the accelerated code
	The fast shutdown sequence doesn't free each allocated block, but lets
	the Zend Engine Memory Manager do the work.

opcache.enable_file_override (default "0")
	Allow file existence override (file_exists, etc.) performance feature.

opcache.optimization_level (default "0xffffffff")
	A bitmask, where each bit enables or disables the appropriate OPcache
	passes

opcache.inherited_hack (default "1")
	Enable this hack as a workaround for "can't redeclare class" errors.
	The OPcache stores the places where DECLARE_CLASS opcodes use
	inheritance (These are the only opcodes that can be executed by PHP,
	but which may not be executed because the parent class is missing due to
	optimization). When the file is loaded, OPcache tries to bind the
	inherited classes by using the current environment. The problem with this
	scenario is that, while the DECLARE_CLASS opcode may not be needed for the
	current script, if the script requires that the opcode at least be defined,
	it may not run. The default for this directive is disabled, which means
	that optimization is active. In php-5.3 and above this hack is not needed
	anymore and this setting has no effect.

opcache.dups_fix (default "0")
	Enable this hack as a workaround for "Cannot redeclare class" errors.

opcache.blacklist_filename
	The location of the OPcache blacklist file (wildcards allowed).
	Each OPcache blacklist file is a text file that holds the names of files
	that should not be accelerated. The file format is to add each filename
	to a new line. The filename may be a full path or just a file prefix
	(i.e., /var/www/x  blacklists all the files and directories in /var/www
	that start with 'x'). Line starting with a ; are ignored (comments).
	Files are usually triggered by one of the following three reasons:
	1) Directories that contain auto generated code, like Smarty or ZFW cache.
	2) Code that does not work well when accelerated, due to some delayed
	   compile time evaluation.
	3) Code that triggers an OPcache bug.

opcache.max_file_size (default "0")
	Allows exclusion of large files from being cached. By default all files
	are cached.

opcache.consistency_checks (default "0")
	Check the cache checksum each N requests.
	The default value of "0" means that the checks are disabled.
	Because calculating the checksum impairs performance, this directive should
	be enabled only as part of a debugging process.

opcache.force_restart_timeout (default "180")
	How long to wait (in seconds) for a scheduled restart to begin if the cache
	is not being accessed.
	The OPcache uses this directive to identify a situation where there may
	be a problem with a process. After this time period has passed, the
	OPcache assumes that something has happened and starts killing the
	processes that still hold the locks that are preventing a restart.
	If the log level is 3 or above, a "killed locker" error is recorded
	in the Apache logs when this happens.

opcache.error_log
	OPcache error_log file name. Empty string assumes "stderr".

opcache.log_verbosity_level (default "1")
	All OPcache errors go to the Web server log.
	By default, only fatal errors (level 0) or errors (level 1) are logged.
	You can also enable warnings (level 2), info messages (level 3) or
	debug messages (level 4).

opcache.preferred_memory_model
	Preferred Shared Memory back-end. Leave empty and let the system decide.

opcache.protect_memory (default "0")
	Protect the shared memory from unexpected writing during script execution.
	Useful for internal debugging only.

opcache.restrict_api (default "")
	Allows calling OPcache API functions only from PHP scripts which path is
	started from specified string. The default "" means no restriction.

opcache.mmap_base
	Mapping base of shared memory segments (for Windows only). All the PHP
	processes have to map shared memory into the same address space. This
	directive allows to manually fix the "Unable to reattach to base address"
	errors.

zendoptimizerplus's People

Contributors

adoy avatar bwoebi avatar cbhp avatar cjbj avatar damz avatar danack avatar dstogov avatar felipensp avatar glensc avatar iliaal avatar johnl avatar krakjoe avatar laruence avatar nathanhruby avatar nikic avatar patrickallaert avatar pborreli avatar pierrejoye avatar raziel057 avatar reeze avatar remicollet avatar rlerdorf avatar sasezaki avatar smalyshev avatar tyrael avatar vlajos avatar weltling avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

zendoptimizerplus's Issues

segfaults in drupal7

I am getting segfaults in drupal7 with a fresh build of ZO, cloned from github:

[Wed Mar 06 00:54:27.789968 2013] [core:notice] [pid 8732] AH00052: child pid 9160 exit signal Segmentation fault (11)
[Wed Mar 06 00:54:31.810703 2013] [core:notice] [pid 8732] AH00052: child pid 9153 exit signal Segmentation fault (11)
[Wed Mar 06 00:54:35.830102 2013] [core:notice] [pid 8732] AH00052: child pid 9165 exit signal Segmentation fault (11)
[Wed Mar 06 00:54:39.850015 2013] [core:notice] [pid 8732] AH00052: child pid 9073 exit signal Segmentation fault (11)
[Wed Mar 06 00:54:41.880204 2013] [core:notice] [pid 8732] AH00052: child pid 9152 exit signal Segmentation fault (11)

This happens consistently when I run the linkchecker of drupal7. Log in to a drupal7 site as webmaster and run:

http://[http_host]/admin/reports/linkchecker

System:

  • Centos 5.9
  • Apache 2.4.4
  • PHP 5.3.22 as mod_php

[ZendOptimizerPlus]
zend_extension=/usr/local/lib/php/extensions/no-debug-non-zts-20090626/ZendOptimizerPlus.so

zend_optimizerplus.memory_consumption=128
zend_optimizerplus.interned_strings_buffer=8
zend_optimizerplus.max_accelerated_files=4000
zend_optimizerplus.revalidate_freq=60
zend_optimizerplus.fast_shutdown=1
zend_optimizerplus.enable_cli=1
;zend_optimizerplus.save_comments=0
;zend_optimizerplus.enable_file_override=1

Getting worse performance with save_comments = 0 and enable_file_override = 1

Hi

Some days ago I did some performance tests with a Hello world built up with Symfony2 framework. You can see some metrics here http://www.ricardclau.com/2013/03/apc-vs-zend-optimizer-benchmarks-with-symfony2/

While most of the results were consistent and of course faster than APC those two settings led to worse performance than letting them default values.

I've repeated the test several times on my machine (to discard eventual CPU exhausting processes) and it always gives less performance (about 10%).

I'm using MacOsX, PHP 5.4.12 and I git cloned about 10 days ago.

Might it be an issue with MacOsX? Maybe with Symfony2?

Comments or hints appreciated!

Serious regressions with existing libraries

Hello,
I've installed ZO+ to try its performance as well as test it with some libraries I use. Unfortunately, I've been disappointed when I saw serious problems with these existing libraries. Usage os ZO+ has broken a lot of previously working code, or even worse, completely broke it so it's not working at all.

At this moment, I have tested Nette Framework, Doctrine 2 and Symfony\Console. All of these had had no failing test before. Doctrine 2 and Symfony\Console passed without problems. But Nette Framework is failing seriously.
I'm attaching link to sources of Nette Framework as well as the output from test suite which indicates the roots of the problems pretty well I think. As you can see, there are really strange problems, to highlight some of the strangest ones:

  • Nette\FatalErrorException: syntax error, unexpected ''From'' (T_CONSTANT_ENCAPSED_STRING), expecting identifier (T_STRING) or variable (T_VARIABLE) or '{' or '$' -- malformed templates compilation, templates are generated in invalid php format (that is Nette\Latte namespace);
  • Failed asserting that array(9) is identical to expected array(6) - somehow malformed arrays;
  • Fatal error: Can only throw objects

Test suite results are here: https://gist.github.com/Majkl578/4948914

I performed these tests under PHP 5.4.12RC1 with FPM, without loaded XDebug or APC. ZO+ was used in default configuration.

please make the cachedir configureable

i recebtly started to test zendoptimizerplus with my own RPM on Fedora 18 and was a little bit shocked that /tmp is hardcoded - depending on the environment this maybe tmpfs with is no good place for mmap or simply is no intentet for cache-files

currently my hack is to include a patch in my RPM-SPEC but that's a dirty solution

--- zendoptimizerplus-7.0.0/zendoptimizerplus-7.0.0/zend_shared_alloc.c 2013-03-04 13:02:03.000000000 +0100
+++ zendoptimizerplus-7.0.0-patched/zendoptimizerplus-7.0.0/zend_shared_alloc.c 2013-03-11 12:38:49.323387043 +0100
@@ -38,7 +38,7 @@

include "sys/mman.h"

#endif

-#define TMP_DIR "/tmp"
+#define TMP_DIR "/var/cache/zendoptimizer"
#define SEM_FILENAME_PREFIX ".ZendSem."
#define S_H(s) g_shared_alloc_handler->s

README missing info

There are 2 issues I have with the README.

  1. zend_optimizerplus.mmap_base (for Windows), is not in the list of configuration directives
  2. It should mention:

To use symfony/doctrine, both of these directives must be set.
zend_optimizerplus.save_comments=1
zend_optimizerplus.load_comments=1

Doctrine requires classes have annotations like @Orm\Entity. Annotations are comments. Comments have to be loaded and saved or doctrine won't see those annotations.

Divide by 0 error with a PHPT

I'm testing on Windows with PHPTs.

Using php-5.4-ts-windows-vc9-x86-rcc34dfc and http://windows.php.net/downloads/pecl/snaps/Optimizer/7.0.0-dev/php_ZendOptimizerPlus-20130219-7.0.0-dev-5.4-ts-vc9-x86.zip

Intermittently I get an integer divide by zero with the CLEAN section of this PHPT
ext/phar/tests/phar_oo_006

The BT
0089f7f4 10004366 php_ZendOptimizerPlus!zend_accel_hash_find+0x113 [c:\php-sdk\pecl_php54\vc9\x86\php-5.4.10-src\ext\zendoptimizerplus\zend_accelerator_hash.c @ 150]
0089f96c 6cf39d60 php_ZendOptimizerPlus!persistent_compile_file+0x1b6 [c:\php-sdk\pecl_php54\vc9\x86\php-5.4.10-src\ext\zendoptimizerplus\zendaccelerator.c @ 1319]
0089f9ac 6cf3a007 php5ts!zend_execute_scripts+0xb0 [c:\php-sdk\snap_5_4\vc9\x86\ts-windows-vc9-x86\zend\zend.c @ 1307]
0089fbbc 00aa219e php5ts!php_execute_script+0x1a7 [c:\php-sdk\snap_5_4\vc9\x86\ts-windows-vc9-x86\main\main.c @ 2492]
0089fe2c 00aa2de2 php!do_cli+0x7fe [c:\php-sdk\snap_5_4\vc9\x86\ts-windows-vc9-x86\sapi\cli\php_cli.c @ 989]
0089fe5c 00aa2dc1 php!main+0x432 [c:\php-sdk\snap_5_4\vc9\x86\ts-windows-vc9-x86\sapi\cli\php_cli.c @ 1364]
0089fec0 00aa957d php!main+0x411 [c:\php-sdk\snap_5_4\vc9\x86\ts-windows-vc9-x86\sapi\cli\php_cli.c @ 1360]
*** ERROR: Symbol file could not be found. Defaulted to export symbols for C:\Windows\syswow64\kernel32.dll -
0089ff04 75b23677 php!__tmainCRTStartup+0x10f [f:\dd\vctools\crt_bld\self_x86\crt\src\crtexe.c @ 586]
WARNING: Stack unwind information not available. Following frames may be wrong.
0089ff10 77e89d72 kernel32!BaseThreadInitThunk+0x12
0089ff50 77e89d45 ntdll!RtlInitializeExceptionChain+0x63
0089ff68 00000000 ntdll!RtlInitializeExceptionChain+0x36

Opcache v7.0.1-dev recv() failed

Hello,

This is similar to the issue mentioned in:
https://github.com/zend-dev/ZendOptimizerPlus/issues/63

I am running with PHP (FPM) without suhosin and still can't get this to work:
php -v
PHP 5.3.18 (cli) (built: Dec 14 2012 20:37:26)
Copyright (c) 1997-2012 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2012 Zend Technologies
with Zend OPcache v7.0.1-dev, Copyright (c) 1999-2013, by Zend Technologies
with Zend Guard Loader v3.3, Copyright (c) 1998-2010, by Zend Technologies

Trying to load site I get the same error:
recv() failed (104: Connection reset by peer) while reading response header from upstream, client:

PHP-FPM error log shows segfaults:
[19-Mar-2013 04:11:01] WARNING: [pool www] child 18357 exited on signal 11 (SIGSEGV) after 0.175630 seconds from start

I also tried with older ones and can't get it to work.

Travis-CI, make test, ZendOptimizerPlus.so in Unknown on line 0

My travis script looks like this:
language: php
php:

  • 5.4
    before_script:
  • phpize
  • ./configure --enable-optimizer-plus
  • make
  • make test
    script:
  • php -d zend_extension=pwd/modules/ZendOptimizerPlus.so -m

The output of "make test" is:

PHP Warning: PHP Startup: Invalid library (maybe not a PHP library) 'ZendOptimizerPlus.so' in Unknown on line 0

PHP Warning: PHP Startup: Invalid library (maybe not a PHP library) 'ZendOptimizerPlus.so' in Unknown on line 0

PHP : /home/travis/.phpenv/versions/5.4.9/bin/php

Warning: PHP Startup: Invalid library (maybe not a PHP library) 'ZendOptimizerPlus.so' in Unknown on line 0

Complete output: https://travis-ci.org/thomasbley/ZendOptimizerPlus
This works fine: php -d zend_extension=pwd/modules/ZendOptimizerPlus.so -m

Bypassing the unnecessary zend_stream_open() in the ZEND_INCLUDE_OR_EVAL_*_HANDER() rtns

At the moment the ZEND_INCLUDE_OR_EVAL_*_HANDER() routines open the included file (for the *_once flavours) using zend_stream_open() before calling the zend_compile_file hook which O+ intercepts. Hence with zend_optimizerplus.revalidate_path=0 even though the file might be cached, the handler still generates file I/O. In the case of some packages this can amount to 50-100 unnecessary file opens. These should be avoided.

The approach that I used for my CLI/GCI opcode cache was to wrap the handler with my own interceptor which temporarily patches the opline converting the include_once to an include, etc. on the first inclusion, if the file is already cached. Unfortunately this approach is unsafe if the op_array is shared across multiple threads/processes as is the case for O+.

A better approach for O+ would to be intercept the zend_stream_open hook (as phar does; see phar_fopen() in ext/phar/func_interceptors.c). This interceptor would pass through any opens except those being executed in a ZEND_INCLUDE_OR_EVAL opline outside the persistent_compile_file() call. The intercepted opens can then be checked against the Zend cache / age etc. In the case of a cache hit, the interceptor simply returns a SUCCESS without opening the source file. The opcode handler will then add the entry to the EG(included_files) HashTable and fall through to the zend_compile_file(). No unnecessary source file opens :-)

static analyzer report, current master

ZendAccelerator.c
..\pecl\optimizer\ZendAccelerator.c(1836) : warning C4244: '=' : conversion from 'double' to 'time_t', possible loss of data
g:\php-sdk\php-master\vc11\x86\pecl\optimizer\zendaccelerator.c(850) : warning C6330: 'const char' passed as Param(1) when 'unsigned char' is required in call to 'isalpha'.
g:\php-sdk\php-master\vc11\x86\pecl\optimizer\zendaccelerator.c(1753) : warning C6330: 'const char' passed as Param(1) when 'unsigned char' is required in call to 'isalpha'.
g:\php-sdk\php-master\vc11\x86\pecl\optimizer\zendaccelerator.c(2173) : warning C6011: Dereferencing NULL pointer 'accel_shared_globals'. : Lines: 2165, 2167, 2168, 2169, 2171, 2173
g:\php-sdk\php-master\vc11\x86\pecl\optimizer\zendaccelerator.c(2249) : warning C28278: Function start_accel_module appears with no prototype in scope. Only limited analysis can be performed. Include the appropriate header or add a prototype. This warning also occurs if parameter or return types are omitted in a function definition.
shared_alloc_win32.c
g:\php-sdk\php-master\vc11\x86\pecl\optimizer\shared_alloc_win32.c(105) : warning C6387: 'memory_mutex' could be '0': this does not adhere to the specification for the function 'ReleaseMutex'. : Lines: 104, 105
g:\php-sdk\php-master\vc11\x86\pecl\optimizer\shared_alloc_win32.c(210) : warning C6011: Dereferencing NULL pointer '_shared_segments_p'. : Lines: 171, 172, 173, 174, 175, 176, 177, 183, 184, 185, 200, 207, 208, 209, 210
g:\php-sdk\php-master\vc11\x86\pecl\optimizer\shared_alloc_win32.c(265) : warning C6011: Dereferencing NULL pointer 'shared_segment'. See line 210 for an earlier location where this can occur: Lines: 171, 172, 173, 174, 175, 176, 177, 183, 184, 185, 200, 207, 208, 209, 210, 212, 214, 215, 224, 252, 255, 258, 265
g:\php-sdk\php-master\vc11\x86\pecl\optimizer\shared_alloc_win32.c(284) : warning C6387: 'fp' could be '0': this does not adhere to the specification for the function 'fprintf'. : Lines: 171, 172, 173, 174, 175, 176, 177, 183, 184, 185, 200, 207, 208, 209, 210, 212, 214, 215, 224, 252, 255, 258, 265, 266, 268, 269, 271, 272, 277, 278, 279, 280, 281, 282, 284
g:\php-sdk\php-master\vc11\x86\pecl\optimizer\shared_alloc_win32.c(285) : warning C6387: 'fp' could be '0': this does not adhere to the specification for the function 'fclose'. See line 284 for an earlier location where this can occur: Lines: 171, 172, 173, 174, 175, 176, 177, 183, 184, 185, 200, 207, 208, 209, 210, 212, 214, 215, 224, 252, 255, 258, 265, 266, 268, 269, 271, 272, 277, 278, 279, 280, 281, 282, 284, 285
zend_accelerator_blacklist.c
g:\php-sdk\php-master\vc11\x86\pecl\optimizer\zend_accelerator_blacklist.c(90) : warning C6011: Dereferencing NULL pointer 'regexp'. : Lines: 74, 75, 76, 78, 83, 84, 85, 88, 84, 85, 88, 89, 90
g:\php-sdk\php-master\vc11\x86\pecl\optimizer\zend_accelerator_blacklist.c(112) : warning C6011: Dereferencing NULL pointer '_regexp_list_it'. : Lines: 74, 75, 76, 78, 83, 84, 85, 88, 84, 85, 88, 89, 90, 91, 93, 94, 96, 97, 101, 94, 96, 97, 98, 101, 94, 108, 109, 111, 112
g:\php-sdk\php-master\vc11\x86\pecl\optimizer\zend_accelerator_blacklist.c(175) : warning C6385: Reading invalid data from 'buf': the readable size is '_Old_5`261' bytes, but '-1' bytes may be read.: Lines: 157, 158, 159, 160, 162, 167, 169, 170, 172, 173, 174, 175, 183, 184, 190, 195, 172, 173, 174, 175
g:\php-sdk\php-master\vc11\x86\pecl\optimizer\zend_accelerator_blacklist.c(176) : warning C6386: Buffer overrun while writing to 'buf': the writable size is '261' bytes, but '-1' bytes might be written.: Lines: 157, 158, 159, 160, 162, 167, 169, 170, 172, 173, 174, 175, 183, 184, 190, 195, 172, 173, 174, 175, 176
g:\php-sdk\php-master\vc11\x86\pecl\optimizer\zend_accelerator_blacklist.c(209) : warning C6387: 'blacklist->entries[blacklist->pos].path' could be '0': this does not adhere to the specification for the function 'memcpy'. : Lines: 157, 158, 159, 160, 162, 167, 169, 170, 172, 173, 174, 175, 183, 184, 190, 195, 199, 200, 201, 203, 205, 206, 207, 208, 209
zend_accelerator_debug.c
g:\php-sdk\php-master\vc11\x86\pecl\optimizer\zend_accelerator_debug.c(59) : warning C6340: Mismatch on sign: 'unsigned long' passed as Param(4) when some signed type is required in call to 'fprintf'.
zend_accelerator_hash.c
g:\php-sdk\php-master\vc11\x86\pecl\optimizer\zend_accelerator_hash.c(65) : warning C6387: 'accel_hash->hash_table' could be '0': this does not adhere to the specification for the function 'memset'. : Lines: 41, 43, 50, 51, 52, 55, 56, 57, 61, 62, 65
zend_accelerator_module.c
g:\php-sdk\php-master\vc11\x86\pecl\optimizer\zend_accelerator_module.c(266) : warning C6330: 'char' passed as Param(1) when 'unsigned char' is required in call to 'isalpha'.
zend_accelerator_util_funcs.c
zend_persist.c
zend_persist_calc.c
zend_shared_alloc.c
zend_optimizer.c
..\pecl\optimizer\Optimizer/nop_removal.c(95) : warning C4018: '<' : signed/unsigned mismatch
g:\php-sdk\php-master\vc11\x86\pecl\optimizer\optimizer\block_pass.c(375) : warning C28182: Dereferencing NULL pointer. '__t' contains the same NULL value as '__s' did. : Lines: 375, 356, 357, 358, 359, 360, 361, 365, 369, 370, 371, 373, 374, 375, 377, 358, 359, 360, 361, 365, 369, 373, 374, 375
g:\php-sdk\php-master\vc11\x86\pecl\optimizer\optimizer\block_pass.c(439) : warning C28182: Dereferencing NULL pointer. 'blocks' contains the same NULL value as 'b' did. : Lines: 411, 412, 415, 416, 433, 436, 437, 438, 439
g:\php-sdk\php-master\vc11\x86\pecl\optimizer\optimizer\block_pass.c(1050) : warning C28182: Dereferencing NULL pointer. '<COMPLEX_EXPR>-><COMPLEX_EXPR>' contains the same NULL value as 'last_op' did. See line 484 for an earlier location where this can occur: Lines: 477, 478, 479, 484, 498, 499, 501, 502, 503, 511, 523, 535, 541, 551, 560, 572, 652, 677, 755, 769, 808, 850, 855, 880, 915, 935, 946, 970, 985, 1001, 1015, 1031, 1040, 1043, 1044, 1046, 503, 511, 523, 535, 541, 551, 560, 572, 652, 677, 755, 769, 808, 850, 855, 880, 915, 935, 946, 970, 985, 1001, 1015, 1031, 1040, 1043, 1044, 1046, 503, 1050
g:\php-sdk\php-master\vc11\x86\pecl\optimizer\optimizer\block_pass.c(1050) : warning C28182: Dereferencing NULL pointer. '<COMPLEX_EXPR><COMPLEX_EXPR><COMPLEX_EXPR>' contains the same NULL value as 'last_op' did. See line 484 for an earlier location where this can occur: Lines: 477, 478, 479, 484, 498, 499, 501, 502, 503, 511, 523, 535, 541, 551, 560, 572, 652, 677, 755, 769, 808, 850, 855, 880, 915, 935, 946, 970, 985, 1001, 1015, 1031, 1040, 1043, 1044, 1046, 503, 511, 523, 535, 541, 551, 560, 572, 652, 677, 755, 769, 808, 850, 855, 880, 915, 935, 946, 970, 985, 1001, 1015, 1031, 1040, 1041, 1043, 1044, 1046, 503, 1050
g:\php-sdk\php-master\vc11\x86\pecl\optimizer\optimizer\block_pass.c(1070) : warning C28182: Dereferencing NULL pointer. '<COMPLEX_EXPR>' contains the same NULL value as 'last_op' did. See line 484 for an earlier location where this can occur: Lines: 477, 478, 479, 484, 498, 499, 501, 502, 503, 511, 523, 535, 541, 551, 560, 572, 652, 677, 755, 769, 808, 850, 855, 880, 915, 935, 946, 970, 985, 1001, 1015, 1031, 1040, 1043, 1044, 1046, 503, 511, 523, 535, 541, 551, 560, 572, 652, 677, 755, 769, 808, 850, 855, 880, 915, 935, 946, 970, 985, 1001, 1015, 1031, 1040, 1043, 1044, 1046, 503, 1050, 1067, 1068, 1069, 1070
g:\php-sdk\php-master\vc11\x86\pecl\optimizer\optimizer\block_pass.c(1160) : warning C6011: Dereferencing NULL pointer 'blocks'. : Lines: 1097, 1098, 1099, 1102, 1151, 1154, 1155, 1156, 1160

Feature request: Add ability to store session data in memcached

Since this is going to be integrated into php5.5, and thus be the default OP cache, I'd like to have an additional feature added to the extension so that it could take one of the last features apc provides that this one doesn't. That feature is allowing a user to store session data in memcached by default inside of the php.ini.

APC allows you to easily to do this, and that's a really nice feature that I feel is sorely missed inside of opcache. I know that this'll likely require some more work, I'm unsure of how much more work this would cause the developers, but since this is trying to pretty much destroy apc(or well not exactly) but since it is integrated into the default extensions, it's going to have a similar effect. I'd love to see that option be available to users.

P.S. I looked at the other issues but they don't seem cover this issue, the only one that was close was https://github.com/zend-dev/ZendOptimizerPlus/issues/71 but that didn't seem to be with session data(maybe it did?). If this feature is already there/available and I've not yet seen it, please just close this bug, point me to the docs, as it's redundant. I've looked over the docs, and I can't find any information that proves to me that this feature is inside of this extension.

invalidate cache on file_put_contents/fwrite/fputs possible?

I recently had trouble with upgrading some owncloud instances. I tracked the problem down to opcache, although there was nothing wrong. Let me explain:

owncloud is writing it's config.php file to activate the maintenance mode. Afterwards reloading and reading the config, and checking if maintenance mode is on. As opcache was caching 60 seconds on my system, the changes to config.php where not there yet and the script ending in endless reloading.
So the caching is of course expected, but in this case lead to troubles.

Do you think it is possible to detect usage of file_put_contents/fwrite/fputs and if there is a cache entry for this file, invalidate it? That would be awesome.

Otherwise a high opcache.revalidate_freq of 60 may not make that much sense for me.

Make test failing with undefined symbol shm_open on PHP 5.3.3

Hi there,

I feel like I might be missing something obvious here; apologies in advance if that's the case :)

This is for PHP 5.3.3, on CentOS 6.2, output of uname -a is:

Linux tomdev 2.6.32-220.el6.x86_64 #1 SMP Tue Dec 6 19:48:22 GMT 2011 x86_64 x86_64 x86_64 GNU/Linux

Everything compiles fine, but when trying to use the module - either configuring it in php.ini or via make test - I get an error: undefined symbol, shm_open.

Any ideas where I could be going wrong? I've included a few more bits of debugging below:

Thanks!,
Tom.

Not sure if these lines are relevant from configure:

checking for mmap() using MAP_ANON shared memory support... yes
checking for mmap() using /dev/zero shared memory support... yes
checking for mmap() using shm_open() shared memory support... no
checking for mmap() using regular file shared memory support... yes

Here's the full output from make test:

Warning: PHP Startup: Unable to load dynamic library '/tmp/zop/3/ZendOptimizerPlus/modules/ZendOptimizerPlus.so' - /tmp/zop/3/ZendOptimizerPlus/modules/ZendOptimizerPlus.so: undefined symbol: shm_open in Unknown on line 0

Warning: PHP Startup: Unable to load dynamic library '/tmp/zop/3/ZendOptimizerPlus/modules/ZendOptimizerPlus.so' - /tmp/zop/3/ZendOptimizerPlus/modules/ZendOptimizerPlus.so: undefined symbol: shm_open in Unknown on line 0

PHP : /usr/bin/php
PHP_SAPI : cli
PHP_VERSION : 5.3.3
ZEND_VERSION: 2.3.0
PHP_OS : Linux - Linux tomdev 2.6.32-220.el6.x86_64 #1 SMP Tue Dec 6 19:48:22 GMT 2011 x86_64
INI actual : /tmp/zop/3/ZendOptimizerPlus/tmp-php.ini
More .INIs :
CWD : /tmp/zop/3/ZendOptimizerPlus
Extra dirs :

VALGRIND : Not used

TIME START 2013-02-13 18:28:17

No tests were run.

Output of php -i | grep configure:

Configure Command => './configure' '--build=x86_64-redhat-linux-gnu' '--host=x86_64-redhat-linux-gnu' '--target=x86_64-redhat-linux-gnu' '--program-prefix=' '--prefix=/usr' '--exec-prefix=/usr' '--bindir=/usr/bin' '--sbindir=/usr/sbin' '--sysconfdir=/etc' '--datadir=/usr/share' '--includedir=/usr/include' '--libdir=/usr/lib64' '--libexecdir=/usr/libexec' '--localstatedir=/var' '--sharedstatedir=/var/lib' '--mandir=/usr/share/man' '--infodir=/usr/share/info' '--cache-file=../config.cache' '--with-libdir=lib64' '--with-config-file-path=/etc' '--with-config-file-scan-dir=/etc/php.d' '--disable-debug' '--with-pic' '--disable-rpath' '--without-pear' '--with-bz2' '--with-exec-dir=/usr/bin' '--with-freetype-dir=/usr' '--with-png-dir=/usr' '--with-xpm-dir=/usr' '--enable-gd-native-ttf' '--without-gdbm' '--with-gettext' '--with-gmp' '--with-iconv' '--with-jpeg-dir=/usr' '--with-openssl' '--with-pcre-regex=/usr' '--with-zlib' '--with-layout=GNU' '--enable-exif' '--enable-ftp' '--enable-magic-quotes' '--enable-sockets' '--enable-sysvsem' '--enable-sysvshm' '--enable-sysvmsg' '--with-kerberos' '--enable-ucd-snmp-hack' '--enable-shmop' '--enable-calendar' '--without-sqlite' '--with-libxml-dir=/usr' '--enable-xml' '--with-system-tzdata' '--enable-force-cgi-redirect' '--enable-pcntl' '--with-imap=shared' '--with-imap-ssl' '--enable-mbstring=shared' '--enable-mbregex' '--with-gd=shared' '--enable-bcmath=shared' '--enable-dba=shared' '--with-db4=/usr' '--with-xmlrpc=shared' '--with-ldap=shared' '--with-ldap-sasl' '--with-mysql=shared,/usr' '--with-mysqli=shared,/usr/lib64/mysql/mysql_config' '--enable-dom=shared' '--with-pgsql=shared' '--enable-wddx=shared' '--with-snmp=shared,/usr' '--enable-soap=shared' '--with-xsl=shared,/usr' '--enable-xmlreader=shared' '--enable-xmlwriter=shared' '--with-curl=shared,/usr' '--enable-fastcgi' '--enable-pdo=shared' '--with-pdo-odbc=shared,unixODBC,/usr' '--with-pdo-mysql=shared,/usr/lib64/mysql/mysql_config' '--with-pdo-pgsql=shared,/usr' '--with-pdo-sqlite=shared,/usr' '--with-sqlite3=shared,/usr' '--enable-json=shared' '--enable-zip=shared' '--without-readline' '--with-libedit' '--with-pspell=shared' '--enable-phar=shared' '--with-tidy=shared,/usr' '--enable-sysvmsg=shared' '--enable-sysvshm=shared' '--enable-sysvsem=shared' '--enable-posix=shared' '--with-unixODBC=shared,/usr' '--enable-fileinfo=shared' '--enable-intl=shared' '--with-icu-dir=/usr' '--with-enchant=shared,/usr' '--with-recode=shared,/usr'

AV with PHPTs on Windows

I'm testing on Windows with PHPTs.

Using php-5.4-ts-windows-vc9-x86-rcc34dfc and http://windows.php.net/downloads/pecl/snaps/Optimizer/7.0.0-dev/php_ZendOptimizerPlus-20130219-7.0.0-dev-5.4-ts-vc9-x86.zip and

I get an Access Violation when running the CLEAN section of these PHPTs
ext/spl/tests/splfileobject_fputcsv_variation13.phpt
ext/xmlwriter/tests/xmlwriter_set_indent_string_basic_001.phpt
ext/standard/tests/file/stat_variation6-win32.phpt
ext/standard/tests/general_functions/bug44394_2.phpt
ext/standard/tests/file/mkdir_rmdir_variation-win32.phpt
ext/phar/tests/zip/notphar.phpt
ext/phar/tests/phar_buildfromdirectory4.phpt
ext/phar/tests/phar_dotted_path.phpt
ext/phar/tests/phar_stub_write_file.phpt
ext/phar/tests/bug52013.phpt
ext/phar/tests/cache_list/copyonwrite6.phpt
ext/phar/tests/phar_convert_repeated_b.phpt
ext/phar/tests/zip/create_new_phar_b.phpt
ext/phar/tests/create_new_phar_b.phpt
ext/phar/tests/tar/create_new_phar_b.phpt
ext/phar/tests/032.phpt
ext/phar/tests/phar_isvalidpharfilename.phpt

The FILE and CLEAN sections of a PHPT are each executed by a separate php.exe process. The FILE sections of these PHPTs pass without crashing.

All PHPTs cause an AV here:
00c7faf0 6d125977 php_ZendOptimizerPlus!accel_startup+0x4b3 [c:\php-sdk\pecl_php54\vc9\x86\php-5.4.10-src\ext\zendoptimizerplus\zendaccelerator.c @ 2307]
00c7fafc 6d08f4d6 php5ts!zend_extension_startup+0xf [c:\php-sdk\snap_5_4\vc9\x86\ts-windows-vc9-x86\zend\zend_extensions.c @ 154]
00c7fb14 6cf69a5f php5ts!zend_llist_apply_with_del+0x125a66
00c7fca0 77e83af4 php5ts!zend_startup_extensions+0xf [c:\php-sdk\snap_5_4\vc9\x86\ts-windows-vc9-x86\zend\zend_extensions.c @ 175]
00c7fe20 002b2d49 php!php_cli_startup+0xf [c:\php-sdk\snap_5_4\vc9\x86\ts-windows-vc9-x86\sapi\cli\php_cli.c @ 414]
00c7feac 002b957d php!main+0x399 [c:\php-sdk\snap_5_4\vc9\x86\ts-windows-vc9-x86\sapi\cli\php_cli.c @ 1344]
00c7fef0 75b23677 php!__tmainCRTStartup+0x10f [f:\dd\vctools\crt_bld\self_x86\crt\src\crtexe.c @ 586]
00c7fefc 77e89d72 kernel32!BaseThreadInitThunk+0x12

opcache assumes cwd is in the include_path

When per-request stats are enabled with:

opcache.validate_timestamps=1
opcache.revalidate_freq=0

and include_path is set to a single directory like /usr/local/lib/php opcache will stat for an include in the cwd before checking the include_path directory. Without opcache enabled cwd is not checked (because there is no "." in the include_path). The stats look like this:

chdir("/var/www")                       = 0
fcntl(26, F_SETLK, {type=F_RDLCK, whence=SEEK_SET, start=1, len=1}) = 0
stat("/var/www/index.php", {st_mode=S_IFREG|0644, st_size=83, ...}) = 0
getcwd("/var/www", 4096)                = 9
getcwd("/var/www", 4096)                = 9
lstat("/var/www/test.php", 0x7fff6845cbc0) = -1 ENOENT (No such file or directory)
stat("/usr/local/lib/php/test.php", {st_mode=S_IFREG|0664, st_size=32, ...}) = 0

My index.php is:

This is /var/www/index.php
<?php
echo ini_get('include_path');
include 'test.php';

and test.php is:

This is /usr/local/lib/test.php

And the output is simply:

This is /var/www/index.php
/usr/local/lib/php
This is /usr/local/lib/test.php

leak + error

[shared_alloc_win32.c:284] -> [shared_alloc_win32.c:280]: (error, inconclusive) Possible null pointer dereference: fp - otherwise it is redundant to check it against null.
[shared_alloc_win32.c:141]: (error) Resource leak: fp
[zend_accelerator_util_funcs.c:178]: (error) Uninitialized variable: ret_ptr

Segfault in zend_mm_startup ()

Tried to switch APC vs Optimizer+ in production environment and am getting random segfaults.

[15-Feb-2013 14:40:15] WARNING: [pool www] child 3352 exited on signal 11 (SIGSEGV - core dumped) after 95.935092 seconds from start
[15-Feb-2013 14:41:00] WARNING: [pool www] child 3360 exited on signal 11 (SIGSEGV - core dumped) after 140.965388 seconds from start
[15-Feb-2013 14:41:45] WARNING: [pool www] child 3572 exited on signal 11 (SIGSEGV - core dumped) after 89.059380 seconds from start

Sadly its not a debug build and its also not so easy to reproduce as it happens under load.

.ini settings:

zend_extension=ZendOptimizerPlus.so
zend_optimizerplus.memory_consumption=164
zend_optimizerplus.interned_strings_buffer=8
zend_optimizerplus.max_accelerated_files=4000
zend_optimizerplus.revalidate_freq=60
zend_optimizerplus.save_comments=0
zend_optimizerplus.fast_shutdown=1

Core was generated by `php-fpm: pool www '.
Program terminated with signal 11, Segmentation fault.
#0 0x000000000060b268 in zend_mm_startup () at /data/install/20130131/php-5.4.11/Zend/zend_alloc.c:1212

warning: Source file is more recent than executable.
1212 exit(255);
(gdb) bt full
#0 0x000000000060b268 in zend_mm_startup () at /data/install/20130131/php-5.4.11/Zend/zend_alloc.c:1212

    i = <optimized out>
    seg_size = <optimized out>
    mem_type = 0x762d6f76697a642f <Address 0x762d6f76697a642f out of bounds>
    tmp = <optimized out>
    handlers = 0xeaf380
    heap = <optimized out>

#1 0x0000000000000001 in ?? ()

No symbol table info available.
#2 0x0000000000000032 in ?? ()

No symbol table info available.
#3 0x000000000062b34c in is_numeric_string_ex (oflow_info=, allow_errors=0, dval=, lval=, length=507229204, str=0xa <Address 0xa out of bounds>)

at /data/install/20130131/php-5.4.11/Zend/zend_operators.h:138
    digits = 0
    type = <optimized out>
    ptr = 0x8 <Address 0x8 out of bounds>
    base = 10
    dp_or_e = 0
    local_dval = <optimized out>

#4 zendi_smart_strcmp (result=0xeaf380, s1=0x7f9d2da366b8, s2=0x32) at /data/install/20130131/php-5.4.11/Zend/zend_operators.c:2046

    ret1 = <optimized out>
    ret2 = <optimized out>
    oflow1 = <optimized out>
    oflow2 = <optimized out>
    lval1 = <optimized out>
    lval2 = <optimized out>
    dval1 = <optimized out>
    dval2 = <optimized out>

#5 0x000000000067b1f0 in gc_zval_check_possible_root (z=0x7f9d1e3bb414) at /data/install/20130131/php-5.4.11/Zend/zend_gc.h:182

No locals.
#6 zend_pzval_unlock_func (unref=1, should_free=, z=0x7f9d1e3bb414) at /data/install/20130131/php-5.4.11/Zend/zend_execute.c:81

No locals.
#7 _get_zval_ptr_var (should_free=, Ts=0x200000, var=<error reading variable: Cannot access memory at address 0x11>) at /data/install/20130131/php-5.4.11/Zend/zend_execute.c:184

    ptr = 0x7f9d1e3bb414

#8 ZEND_SL_SPEC_VAR_VAR_HANDLER (execute_data=0xeaf380) at /data/install/20130131/php-5.4.11/Zend/zend_vm_execute.h:16292

    opline = 0x1
    free_op1 = <optimized out>
    free_op2 = {var = 0x0}

#9 0x00007f9d2da69b68 in ?? ()

No symbol table info available.
#10 0x00007fff14d8fdb0 in ?? ()

No symbol table info available.

Partial page output when using zend optimizer+

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?

BIG request: files or memcached based storage (please read before dismissing)

Now that Zend Optimizer Plus will make it to 5.5, I think it's time to resurface this discussion. PLEASE do read it before dismissing it.

Times changed. There are a lot of SuPHP (and the likes) installations out there that suffer from horrible performance ... and as we know, all current opcode cachers fail. SuPHP and the likes now account for quite a lot of php installations, a non-negligible number. All those installations would greatly benefit from a storage engine that survives between requests. Both users and hosting providers would be extremely grateful!

There are too many slow (and/or poorly) written but still very popular scripts out there cough like WordPress cough, especially when they have all sort of other (popular and) slow scripts/plugins being called as part of a single request. This tends to be the norm now with websites based on WordPress, Drupal, etc, and a large number of them are hosted in SuPHP setups.

I know the cons of file-based storage but please let's reconsider it for a moment.

MEMCACHED. would be a nice solution although most probably (especially for SuPHP environments), hosting providers won't allow it or won't provide it at all since it would be a memory hog as clients fill up the server's RAM with cached php opcode.

It would still be great to have as a storage engine though.

FILE-BASED. Everybody says cache hits would be slow. And they are right, however:

  • it would be on average faster than loading and executing an entire chain of scripts long scripts considering the OS file-cache (those php files have to be read anyway without an opcode cacher)
  • The OS would cache the opcode files transparently in its file cache -- and hosting providers will not disable that as they don't want their disks thrashed -- so this would actually be pretty much as fast as SHM-based solutions as long as the files are in the OS's file cache. On average, it would be noticeably faster than without any opcode cache at all ... probably faster than a Memcached-based cache which incurs network latency.
  • The OS would automatically take care of wiping the oldest accessed files from its file cache when memory fills up, so garbage collection would be pretty simple.

This solution would be appealing as the server's memory won't be hogged (as opposed to memcached or SHM-based solutions), and it would not require any dependencies for it to run (as opposed to memcached).

Both users and providers alike would enjoy a faster service + less resources hogged. It would be a great compromise for those numerous SuPHP-and-friends setups.

I know tons of people interested in this if it existed!

Hoping you'll consider this.

Cheers.

p.s. I remember when eAccelerator had file-based storage and it was making a great deal of difference for such big and slow scripts. Now there is no PHP opcode cache (that I know of) which works with SuPHP.

Blacklist improvment

Hi

Following PR 82 I was thinking on another way to improve blacklist, for packaging.

It will be great to allow various blacklist files, for example:

opcache.blacklist_filename=/etc/php.d/*.blacklist

This allow each application (package) to come with its own blacklist.

Alternative (with current implementation) is to provide some awfull scriptlets to add / remove entries in the global file, and probably to raise some trigger when opcache is installed after the app... really ugly.

What do you think of this proposal.
If accepted, I will work on the code change.

Traits related issue

Hi, Zeev! Glad to hear that Zend Optimizer+ finally open sourced! There's this bug I found, it's actually very strange, because it reproducible fairly easy.
Anyway, there's description:

Environment: Ubuntu 12.04 with PHP compiled, here's php -v output:

PHP 5.4.9 (cli) (built: Feb 12 2013 17:14:19) 
Copyright (c) 1997-2012 The PHP Group
Zend Engine v2.4.0, Copyright (c) 1998-2012 Zend Technologies
    with Xdebug v2.2.1, Copyright (c) 2002-2012, by Derick Rethans
    with Zend Optimizer+ v7.0.0, Copyright (c) 1999-2013, by Zend Technologies

php.ini contents:

include_path=/usr/local/lib/php

date.timezone=Europe/Moscow

extension=amqp.so
;extension=apc.so
zend_extension=/usr/local/lib/php/extensions/no-debug-non-zts-20100525/xdebug.so
zend_extension=/usr/local/lib/php/extensions/no-debug-non-zts-20100525/ZendOptimizerPlus.so

;apc.enabled=1
zend_optimizerplus.enable=1
zend_optimizerplus.memory_consumption=128
zend_optimizerplus.save_comments=1

Code reproducing the bug:

<?php

trait FooTrait
{
    public function foo()
    {
        return "foo";
    }
}


class BarClass
{
    use FooTrait;
}

var_dump((new BarClass())->foo());

Expected output:

string(3) "foo"

First run output:

string(3) "foo"

Second and subsequent runs output:

Fatal error: Call to undefined method BarClass::foo()

This bug is reproducible on fpm, but not on cli.

shared_alloc_win32.c does not compile

When compiling under Windows for PHP 5.3.22RC2 NTS:

shared_alloc_win32.c
ext\ZendOptimizerPlus\shared_alloc_win32.c(215) : error C2198: 'zend_win_error_message' : too few arguments for call
NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\BIN\cl.exe"' : return code '0x2'
Stop.

Phar PHPTs intermittently crash with O+ in accel_startup

On 5.5.0a6 built with the VC11 compiler, these PHPTs intermittently (about 1 in 10 test runs) crash with O+:
ext/phar/tests/tar/phar_commitwrite.phpt
ext/phar/tests/zip/phar_commitwrite.phpt
ext/phar/tests/zip/phar_setsignaturealgo2.phpt
ext/phar/tests/tar/phar_setsignaturealgo2.phpt

Just run run-tests a few times on Windows to reproduce this issue.

I think there has to be a bunch of PHPTs run between the runs of these 4 Phar PHPTs (ie, just running these 4 PHPTs 10 times won't work... however, this issue is also reproducable by running thse 4 PHPTs a few hundred times).

Note: that 5.4 and 5.3 for Windows have been built using the VC9 compiler, but for 5.5 we are moving to VC11 and this has broken a few other things... so this is an issue with using both O+ and VC11 together.

This is the backtrace(same for all PHPTs):
0009f904 713df1af php_ZendOptimizerPlus!accel_startup+0x3f3 [c:\php-sdk\php55\vc11\x86\php-5.5.0alpha5-src\ext\zendoptimizerplus\zendaccelerator.c @ 2377]
0009f910 7152b2d0 php5ts!zend_extension_startup+0xf [c:\php-sdk\snap_5_5\vc11\x86\ts-windows-vc11-x86\zend\zend_extensions.c @ 154]
0009f928 7127ae90 php5ts!zend_llist_apply_with_del+0x259190 [c:\php-sdk\snap_5_5\vc11\x86\ts-windows-vc11-x86\zend\zend_llist.c @ 178]
0009fc18 74c01b01 php5ts!php_module_startup+0x7d0 [c:\php-sdk\snap_5_5\vc11\x86\ts-windows-vc11-x86\main\main.c @ 2207]

Incorrect memory alignment of SMA allocated memory

zend_shared_alloc() in zend_shared_alloc.c has a flaw in its memory alignment algo for LP64 memory models (including of course x86 64bit). The routine does do platform alignment (viz size_t aligned) for each overall block, but returns base+sizeof(int) as the allocated address to the calling function (see line 312).

Since all pointers and size_t elements in op_arrays, etc are size_t aligned to this second base address, this means that all such memory fetches are odd 32-bit boundary aligned which incurs an unnecessary performance hit on x86 and is a hard error on some 64bit architectures.

Either make size in the typedef struct _zend_shared_memory_block_header of type site_t / add an extra packing int, or or add the extra alignment computation in line 312, etc.

What is the purpose of the sma strategy?

For anonymous regions are used for both mmap and posix implementations of the sma (that is the *nix platforms). I've only ever used this to share a memory region across a parent/child set of processes. Given that in this case the process does not fork off child processes, I can't think of any reason to do this rather than just mallocing a block of memory, say. Have I missed something here?

Also, the regions are private-to-process, I don't understand the purpose of the lock file based zend_shared_alloc_lock/unlock: on non-windows platforms, the only time that locking is required is in the case of ZTS builds and here tsrm_mutex_lock() is already used; and on Windows platforms where the regions can be shared cross process surely the native inter-process Mutex functions are a better fit? We seem to be generating file I/O for no purpose. (This links to #60 ).

There is a longer term issue of memory scaling in that O+ doesn't currently provide the option to use named shared regions across multiple webserver workers, though I can see the rationale for this given O+ death-and-rebirth strategy for sma garbage-collection. However, there is also a testing / repeatability concern given that in reality the caching models are fundamentally different and the restart coordination is intra-process in the case of *nix platforms and inter-process in the case of Windows.

PHP 5.2 Error

I compile this zend extension on PHP 5.2.11 and when I restart the Apache, I got this error.

"Failed loading /usr/lib64/php/modules/ZendOptimizerPlus.so: /usr/lib64/php/modules/ZendOptimizerPlus.so: undefined symbol: zend_parse_parameters_none
[Wed Mar 06 04:36:56 2013] [notice] caught SIGTERM, shutting down"

Does not compile anymore with VC9 PHP 5.3.23 nts

Creating library Release\php_opcache.lib and object Release\php_opcache.exp
zend_optimizer.obj : error LNK2019: unresolved external symbol _ZEND_HANDLE_NUMERIC_EX referenced in function _zend_optimize_block

Release\php_opcache.dll : fatal error LNK1120: 1 unresolved externals
NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio 9.0
VC\BIN\cl.exe"' : return code '0x2'

Stop.

VC9, PHP 5.3.23 NTS. A pity. I wanted to test your recent optimizations.

New beta release

Hi,

As the extension have been merged in PHP 5.5 and renamed to "opcache", with all the configuration directives, it will be interesting to publish a new pecl beta release (7.0.1)

Regards

doesn't work with phpmyadmin

Env: phpMyAdmin-4.0.0-beta1, ZenOptimizer commit 511b33c, PHP5.4.11 (php-fpm), FreeBSD9.1

Settings:
zend_optimizerplus.memory_consumption=128
zend_optimizerplus.interned_strings_buffer=8
zend_optimizerplus.max_accelerated_files=4000
zend_optimizerplus.revalidate_freq=60
zend_optimizerplus.fast_shutdown=1
zend_optimizerplus.enable_cli=1

PMA fails with PHP Fatal error: Call to undefined function pma_issuperuser() in /usr/home/phpmyadmin/libraries/Menu.class.php on line 434

ZTS Problem ?

I tried to install the ZendOptimizer+ provided earlier today but wasn't able to make it work. I compiled it with success but when I looked at the phpinfo(); I had this :

Opcode Caching Disabled
Optimization Enabled
Startup Failed no value

I'm using the apache2handler (MPM Worker - multi-threaded), PHP Version 5.4.13-dev.

Here's my configure :

'./configure' '--enable-debug' '--enable-bcmath' '--enable-calendar' '--enable-gd-native-ttf' '--enable-maintainer-zts' '--enable-mbstring' '--enable-soap' '--enable-sockets' '--enable-sysvsem' '--enable-sysvshm' '--enable-zip' '--with-apxs2=/usr/bin/apxs2' '--with-config-file-path=/etc/php5/PHP-5.4' '--with-config-file-scan-dir=/etc/php5/PHP-5.4/conf.d' '--with-curl' '--with-freetype-dir=/usr/lib' '--with-gd' '--with-jpeg-dir' '--with-kerberos' '--with-mcrypt' '--with-mysql-sock=/var/run/mysqld/mysqld.sock' '--with-mysql=mysqlnd' '--with-mysqli=mysqlnd' '--with-openssl' '--with-pdo-mysql=mysqlnd' '--with-png-dir' '--with-readline' '--with-xsl' '--with-zlib-dir'

I only added the zend_extension line in my php.ini file.

I tried to look at the log but did not found anything that could explain why the Startup Failed. I looked a little bit at the code and the accel_startup worked as expected at the apache start and ZCG(startup_ok) was equal to 1 at the end of it. I'm suspecting that my problem is related to the fact that I'm using a multi-threaded environment. Could it be because the startup_ok variable is in the zend_accel_globals structure and not in the zend_accel_shared_globals ? And that a new zend_accel_globals is created for my request where the startup_ok is not 1 ?

error reported despite an user error handler is present

At least In cli mode, with enable_cli=1

$ pear list
Deprecated: Assigning the return value of new by reference is deprecated in /usr/share/pear/PEAR/Frontend.php on line 91
Deprecated: Assigning the return value of new by reference is deprecated in /usr/share/pear/PEAR/Config.php on line 664
Deprecated: Assigning the return value of new by reference is deprecated in /usr/share/pear/PEAR/Config.php on line 713
Deprecated: Assigning the return value of new by reference is deprecated in /usr/share/pear/PEAR/Config.php on line 773
...

While, in pearcmd.php, a user error handler is enabled to skip the deprecated message.

Compilation error (OSX)

Please fix small typo into shared_alloc_posix.c

48c48
<       return ALLOC_FAILURE;

---
>       rerurn ALLOC_FAILURE;

enhancement request: "stat once" feature

I would like to suggest a feature that I was able to create for APC but is currently impossible with optimizer+ (based on some quick testing).

On production servers for best performance we run opcode caches with file stat off (aka validate_timestamps=0 on zop) But on rare occasion a single file has to be updated. The solitary accelerator_reset function is unacceptable in this situation when there are thousands of optimized, unaltered files in the cache.

So this new "stat once" feature would only on demand simply run through all the files currently in the cache and stat them on disk to see only to if they have changed (or have been removed). Then only those files would be reprocessed.

Obviously this would grow wasted space for the few files changed but that is far more acceptable than nuking the entire cache memory (and even restarting the module?) with the accelerator_reset if there are thousands of files in there.

Note such a function would need to store the original files timestamps which validate_timestamps=0 actually turns off.

I've tinkered with the idea of keeping validate_timestamps on and just setting a crazy high revalidate_freq by default and change it when needed on the fly but ini_set cannot seem to affect validate_timestamps or revalidate_freq after startup so this idea is moot if they are read-only.

Maybe that is an alternate idea if "stat once" is too difficult, simply allow revalidate_freq to be adjusted on the fly via a new function.

proposal:

accelerator_stat ( $fullpath='' )

If $fullpath is given, just stat that one file and reprocess it if changed. If no current timestamp is stored for the original file in the cache, always replace it.

If no $fullpath is given, stat all the files in the cache and reprocess any that have changed. If timestamps are not stored because validate_timestamps is disabled then this process is impossible because it would have to replace the entire cache. So it would only be logical with a very high revalidate_freq

alternately:

accelerator_set ( $key, $value )

ala
accelerator_set ( 'revalidate_freq', '60')

Thank you for considering.

leaks from stream stuff

tests started failing a couple of days ago, I saw some changes going on that were something to do with streams and assumed something was being worked on ...

I'm pretty sure it cant have gone un-noticed but thought I'd put up an issue anyway ...

Code is in pull #36, basically everything leaks:

[Thu Feb 21 21:16:17 2013] Script: '/usr/src/php-nts/ext/ZendOptimizerPlus/tests/0001_serving.php'
/usr/src/php-nts/main/streams/plain_wrapper.c(910) : Freeing 0x7F42D44B11C0 (64 bytes), script=/usr/src/php-nts/ext/ZendOptimizerPlus/tests/0001_serving.php
[Thu Feb 21 21:16:17 2013] Script: '/usr/src/php-nts/ext/ZendOptimizerPlus/tests/0001_serving.php'
/usr/src/php-nts/main/main.c(2450) : Freeing 0x7F42E2EF9860 (62 bytes), script=/usr/src/php-nts/ext/ZendOptimizerPlus/tests/0001_serving.php

Compile error CentOS 6.3, php 5.2.17 - zend_accel_directives has no member named interned_strings_buffer

I may be missing something obvious but I am getting a compile error.

/bin/sh /root/ZendOptimizerPlus/libtool --mode=compile cc  -I. -I/root/ZendOptimizerPlus -DPHP_ATOM_INC -I/root/ZendOptimizerPlus/include -I/root/ZendOptimizerPlus/main -I/root/ZendOptimizerPlus -I/usr/include/php -I/usr/include/php/main -I/usr/include/php/TSRM -I/usr/include/php/Zend -I/usr/include/php/ext -I/usr/include/php/ext/date/lib  -DHAVE_CONFIG_H  -g -O2   -c /root/ZendOptimizerPlus/zend_accelerator_module.c -o zend_accelerator_module.lo
 cc -I. -I/root/ZendOptimizerPlus -DPHP_ATOM_INC -I/root/ZendOptimizerPlus/include -I/root/ZendOptimizerPlus/main -I/root/ZendOptimizerPlus -I/usr/include/php -I/usr/include/php/main -I/usr/include/php/TSRM -I/usr/include/php/Zend -I/usr/include/php/ext -I/usr/include/php/ext/date/lib -DHAVE_CONFIG_H -g -O2 -c /root/ZendOptimizerPlus/zend_accelerator_module.c  -fPIC -DPIC -o .libs/zend_accelerator_module.o
/root/ZendOptimizerPlus/zend_accelerator_module.c: In function ‘zif_accelerator_get_configuration’:
/root/ZendOptimizerPlus/zend_accelerator_module.c:537: error: ‘zend_accel_directives’ has no member named ‘interned_strings_buffer’
make: *** [zend_accelerator_module.lo] Error 1

Optimization Problem/Bug

I found a wired bug and was able to track it down to the following code:

http://pastebin.com/VZMEXuuf

I expect this to return true true END, which it does without optcache.
With optcache enabled it returns null null end.

I tested this against the current master branch and against version v7.0.0. using PHP 5.4.13--pl0-gentoo and Apache 2.2.24 No other extensions were loaded.

The following code changes result in the correct output:

  • Adding a flush or echo to my_parse_m
  • Commenting out either $a = 'b' or the else block.

Setting opcache.optimization_level=0 fixes the problem as well.

Please let me know if I can assist with additional information.

Regards,

Martin

undefined symbol: zend_new_interned_string

First error I have seen after running the trunk from 3/18/2013

Failed loading .../opcache.so: .../opcache.so: undefined symbol: zend_new_interned_string

Running on php-fpm 5.4 trunk from same date.

Been running for a week without problems and even after that error it seems like it is still humming along.

This error seems to appear in google previously going back a year or more from the original optimizer+ ?

Enable/Disable per php-fpm master process

Hi,
at the moment it is not possible to enable/disable zend optimizer per different php-fpm master process. It takes into account setting only from master .ini. E.g. even though in php-fpm pool settings it's set

php_admin_flag[zend_optimizerplus.enable] = off

Cache is still enabled.

Bad error in phpinfo

With default configuration enable_cli=0

$ php -i 
Zend Optimizer+

Opcode Caching => Disabled
Optimization => Enabled
Startup Failed => Opcode Caching is only supported in Apache, ISAPI and FastCGI SAPIs

I think the message is wrong. CLI is supported, but just not enabled, by configuration.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.