php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #71292 Opcache settings have no effect, only default settings are loaded
Submitted: 2016-01-05 20:22 UTC Modified: 2016-01-07 17:16 UTC
From: dev at models dot com Assigned: ab (profile)
Status: Closed Package: opcache
PHP Version: 7.0.1 OS: Windows Server 2008 R2 / IIS
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: dev at models dot com
New email:
PHP Version: OS:

 

 [2016-01-05 20:22 UTC] dev at models dot com
Description:
------------
Changing any of the opcache. settings after having enabled the extension in php.ini has no effect on any of the settings.

The only thing that seems to work is loading or unloading the opcache extension adding or removing the zend_extension="full path to opcache dll" option.

Opcache is enabled and loaded, verified via phpinfo() which reports that the opcache module is loaded and enabled.

This is on Windows Server 2008 R2, running php 7.0.1 x64 nts in fastcgi mode.

Making the same changes on php 5.5.29 on the same server works properly, opcache settings can be changed via php.ini and new settings are reported by phpinfo().


Test script:
---------------
The info reported by phpinfo() is as follows:

Opcode Caching	Up and Running
Optimization	Enabled
SHM Cache	Enabled
File Cache	Disabled
Startup	OK
Shared memory model	win32
Cache hits	0
Cache misses	1
Used memory	9132712
Free memory	57976152
Wasted memory	0
Interned Strings Used memory	132024
Interned Strings Free memory	4062280
Cached scripts	1
Cached keys	2
Max keys	3907
OOM restarts	0
Hash keys restarts	0
Manual restarts	0
Directive	Local Value	Master Value
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	0	0
opcache.file_cache	no value	no value
opcache.file_cache_consistency_checks	1	1
opcache.file_cache_fallback	1	1
opcache.file_cache_only	0	0
opcache.file_update_protection	2	2
opcache.force_restart_timeout	180	180
opcache.inherited_hack	On	On
opcache.interned_strings_buffer	4	4
opcache.log_verbosity_level	1	1
opcache.max_accelerated_files	2000	2000
opcache.max_file_size	0	0
opcache.max_wasted_percentage	5	5
opcache.memory_consumption	64	64
opcache.mmap_base	no value	no value
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


Changing any of the corresponding settings in php.ini and restarting iis/recycling the app pool has no effect, the settings remain the same.

This is the [opcache] settings section of our php.ini file.
I have verified the correct php.ini is loaded, other custom settings are applied and reported by phpinfo()

opcache.enable=1
opcache.enable_cli=0
opcache.memory_consumption=256
opcache.interned_strings_buffer=16
opcache.max_accelerated_files=8000
opcache.max_wasted_percentage=5
opcache.use_cwd=1
opcache.validate_timestamps=1
opcache.revalidate_freq=30
opcache.fast_shutdown=1


Expected result:
----------------
Expecting php.ini changes to opcache. settings to be reported by phpinfo()

Actual result:
--------------
phpinfo() always reports the default values for opcache configruation options.

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2016-01-05 22:01 UTC] dev at models dot com
Adding more info, we are also seeing these errors in the Windows Application log:

Source: Zend OPcache
Event ID: 487
Base address marks unusable memory region
Attempt to access invalid address.

Which seems to be the same issue or related to the one described here:
https://github.com/zendtech/ZendOptimizerPlus/issues/167
and in this php bug report:
https://bugs.php.net/bug.php?id=64926
 [2016-01-06 18:23 UTC] ab@php.net
-Status: Open +Status: Feedback
 [2016-01-06 18:23 UTC] ab@php.net
Thanks for the report. Yes, it is the know issue that sometimes reattaching to SHM fails. 

In 7.0 the INI directive opcache.file_cache_fallback was added, to still make use of the file cache in this situation. In your configuration, opcache.file_cache= has no value, thus the fallback cannot work. Please set a valid path as a value and observe the happenings.

Thanks.
 [2016-01-06 20:52 UTC] dev at models dot com
Thanks for responding.

I added these two directives:
opcache.file_cache_fallback=1
opcache.file_cache="path to a server writable directory"

Then recycled the app pool,
At first the page was not responding (blank) and the windows log generated an Event ID 487 for each request.

After doing another recycle php pages started responding again, but the ini settings are still not applied or changing.

I can verify that the app pool is recycled, as every time I do it the "Cache hits" counter resets itself to 0 an starts incrementing back up for each request to the phpinfo() page.


The new opcache.cache_file is still showing as undefined.
This is the output of phpinfo() after doing those changes:

Opcode Caching	Up and Running
Optimization	Enabled
SHM Cache	Enabled
File Cache	Disabled
Startup	OK
Shared memory model	win32
Cache hits	5
Cache misses	1
Used memory	9132712
Free memory	57976152
Wasted memory	0
Interned Strings Used memory	132024
Interned Strings Free memory	4062280
Cached scripts	1
Cached keys	2
Max keys	3907
OOM restarts	0
Hash keys restarts	0
Manual restarts	0
Directive	Local Value	Master Value
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	0	0
opcache.file_cache	no value	no value
opcache.file_cache_consistency_checks	1	1
opcache.file_cache_fallback	1	1
opcache.file_cache_only	0	0
opcache.file_update_protection	2	2
opcache.force_restart_timeout	180	180
opcache.inherited_hack	On	On
opcache.interned_strings_buffer	4	4
opcache.log_verbosity_level	1	1
opcache.max_accelerated_files	2000	2000
opcache.max_file_size	0	0
opcache.max_wasted_percentage	5	5
opcache.memory_consumption	64	64
opcache.mmap_base	no value	no value
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
 [2016-01-06 23:28 UTC] ab@php.net
Now, please be a bit more verbose. "SHM Cache	Enabled" means there was no fallback required, but the file_cache value is still empty in your latest posting. That means the file where you set the file cache directive was not read in, for some reasons.

What was in the event, same as before about the "invalid address"? If yes, that' s another sign the php.ini doesn't even got read in. Please check what is the path to your php.ini shown in the phpinfo page, and check that you properly set it for the PHP environment.

Maybe there a specific PHP code leading to this?

Anatol
 [2016-01-07 14:29 UTC] dev at models dot com
Thank you!

I have solved the issue. Your recommended settings to add opcache.file_cache_fallback=1
opcache.file_cache=[dir] were correct.

They were not working because our ini file had a line break in the middle of a config statement breaking it, so only part of our php.ini settings were loading.
 [2016-01-07 17:16 UTC] ab@php.net
-Status: Feedback +Status: Closed -Assigned To: +Assigned To: ab
 [2016-01-07 17:16 UTC] ab@php.net
Great you consequently stayed on the investigation. Time to close the issue. File cache fallback is a new feature, so any feedback on it were much appreciated, especially bugs.

Thanks.
 
PHP Copyright © 2001-2022 The PHP Group
All rights reserved.
Last updated: Wed Aug 10 05:05:46 2022 UTC