zendtech / ZendOptimizerPlus

Other
914 stars 142 forks source link

make shared_free type match in _zend_shared_memory_state and _zend_smm_s... #205

Closed nathanhruby closed 9 years ago

nathanhruby commented 9 years ago

...hared_globals

nathanhruby commented 9 years ago

This is similar to https://bugs.php.net/bug.php?id=68565 which seems to be merged in php-src, but not reflected in this repo.

Also, the CI build failed for 5.2 and was failing before this PR on:

FAIL ISSUE #183 (TMP_VAR is not only used once) [tests/issue0183.phpt] 
nathanhruby commented 9 years ago

Hi,

So to be specific, like the 68565 bug, when memory_consumption is set to a large value (in my case 5GB using opcache 7.0.4 with php 5.3) a cache restart will cause wasted memory to be 0 after the restart and never change, the used memory number will increase and not decrease, and keys/scripts will remain fairly steady (not drop to 0 or increase). Continued clears with opcache_clear() do nothing to resolve this. During this time hits/misses and hitrate are all adversely affected (eg, hitrate drops, misses increase).

After this applying this patch and the one from 68565 a opcache restart correctly clears all memory and keys/scripts increase with memory consumption until another restart clears all data.

This would most affect a large machine with a working set much larger than the opcache size, where frequent cycling of the cache is a requirement. Here's a graph from one of our production machines that fits this traffic patterns after our apc to opcache switch illustrating the problem: opcache-stats-pre-post-patch

dstogov commented 9 years ago

Thanks. Committed.