Bug #69885 [NEW]: (unexpecteadly) Increasing wasted memory when file are removed
| From: | maxence at typhon dot com | Date: | Fri, 19 Jun 2015 15:13:34 +0000 |
| Subject: | Bug #69885 [NEW]: (unexpecteadly) Increasing wasted memory when file are removed | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-193701@lists.php.net to get a copy of this message | ||
From: maxence at typhon dot com
Operating system: Debian 7
PHP version: 5.6.10
Package: opcache
Bug Type: Bug
Bug description:(unexpecteadly) Increasing wasted memory when file are removed
Description:
------------
PHP 5.6.10 from tarbal, compiled with :
./configure --disable-all --prefix=/usr/local/php-5.6.10 --enable-fpm
--enable-ctype --enable-mbstring --enable-gd-native-ttf --enable-zip
--with-mcrypt --with-openssl --with-gd --with-jpeg-dir=/usr/lib
--with-freetype-dir --with-curl --with-pcre-regex --with-gettext
--enable-pdo --with-pdo-mysql=mysqlnd --with-iconv --enable-fileinfo
--enable-filter --enable-json --enable-session --enable-hash
--enable-libxml --enable-dom --enable-libxml --enable-simplexml
--enable-bcmath --enable-soap --enable-opcache --enable-ftp
--enable-intl
opcache config is :
opcache.blacklist_filename => no value => no value
opcache.consistency_checks => 0 => 0
opcache.dups_fix => Off => Off
opcache.enable => On => On
opcache.enable_cli => Off => Off
opcache.enable_file_override => Off => Off
opcache.error_log => no value => no value
opcache.fast_shutdown => 1 => 1
opcache.file_update_protection => 2 => 2
opcache.force_restart_timeout => 180 => 180
opcache.inherited_hack => On => On
opcache.interned_strings_buffer => 16 => 16
opcache.load_comments => 1 => 1
opcache.log_verbosity_level => 4 => 4
opcache.max_accelerated_files => 30000 => 30000
opcache.max_file_size => 0 => 0
opcache.max_wasted_percentage => 5 => 5
opcache.memory_consumption => 1024 => 1024
opcache.optimization_level => 0xFFFFFFFF => 0xFFFFFFFF
opcache.preferred_memory_model => no value => no value
opcache.protect_memory => 0 => 0
opcache.restrict_api => no value => no value
opcache.revalidate_freq => 2 => 2
opcache.revalidate_path => Off => Off
opcache.save_comments => 1 => 1
opcache.use_cwd => On => On
opcache.validate_timestamps => On => On
We used to remove a lot of php files from time to time (~ 70Mb) when
releasing, without any manual opcache flush or php restart. Every time
we remove the files, the same amount of space is added to wasted_memory.
Looks like opcache does not reclaim the memory when the file is removed
(and then recreated) but only put it as "wasted". Also, the memory
wasted is far bigger than the configured 5%, and opcache doesn't
restart.
I achieved to reproduce this in a simple test (see below). Note that the
sleep time matters. With "sleep 3", the wasted memory increase after
every cycle. With "sleep 2", it only increases every ~ 2 times, which
let me think the issue has something to do with the revalidate process
(and revalidate_freq).
Test script:
---------------
# for i in $(seq 1 100);do rm -f /var/www/web-default/a.php && echo '<?
echo("hi"); ?>' > /var/www/web-default/a.php; sleep 3; curl -s
http://127.0.0.1/a.php >/dev/null; curl -s
http://127.0.0.1/opcache_stat.php |grep
wasted_memory;done
Expected result:
----------------
wasted memory should not increase, so something like :
"wasted_memory": 72192,
"wasted_memory": 72192,
"wasted_memory": 72192,
"wasted_memory": 72192,
Actual result:
--------------
wasted memory increase for the same size every time.
"wasted_memory": 72192,
"wasted_memory": 72960,
"wasted_memory": 73728,
"wasted_memory": 74496,
"wasted_memory": 75264
--
Edit bug report at https://bugs.php.net/bug.php?id=69885&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=69885&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=69885&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=69885&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=69885&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=69885&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=69885&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=69885&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=69885&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=69885&r=support
Expected behavior: https://bugs.php.net/fix.php?id=69885&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=69885&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=69885&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=69885&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=69885&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=69885&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=69885&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=69885&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=69885&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=69885&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=69885&r=mysqlcfg