php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #79644 OpCache opcache.max_wasted_percentage cannot be set over 0.50%
Submitted: 2020-05-27 16:38 UTC Modified: 2020-06-02 12:21 UTC
From: abuse at botrax dot com Assigned: cmb (profile)
Status: Closed Package: opcache
PHP Version: 7.4.6 OS: CentOS 7
Private report: No CVE-ID: None
 [2020-05-27 16:38 UTC] abuse at botrax dot com
Description:
------------
Zend Opcache v7.4.6 does not allow "opcache.max_wasted_percentage" to go over 0.50%, no matter the setting in INI. 

Causes Opcache to be constantly reset

PHP 7.4.6 (cli) (built: May 12 2020 08:09:15) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
    with the ionCube PHP Loader v10.4.0 (beta2), Copyright (c) 2002-2020, by ionCube Ltd.
    with Zend OPcache v7.4.6, Copyright (c), by Zend Technologies


"opcache.max_wasted_percentage"
Setting of 60 sets it to 0.05%
Setting of 50 sets it to 0.50%
Setting of 5 sets it to 0.05%
Setting of 6 sets it to 0.06%


Using PHP 7.4 from REMI repo
10-opcache.ini   /etc/opt/remi/php74/php.d

php -i
opcache.max_wasted_percentage => 50 => 50


Value is then verified from within WordPress plugins to display configuration of OpCache.

3 different WordPress plugins show "opcache.max_wasted_percentage" to be never above 0.50%



Expected result:
----------------
Expect "opcache.max_wasted_percentage" OpCache parameter to be set from 0 to 100 in percentage.

Expect script to read value to go above 0.50% when setting any value larger than 1.

Value should return exact value configured in INI file.

Actual result:
--------------
OpCache

"opcache.max_wasted_percentage"
Setting of 60 sets it to 0.05%
Setting of 50 sets it to 0.50%
Setting of 5 sets it to 0.05%
Setting of 6 sets it to 0.06%

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2020-05-27 16:45 UTC] cmb@php.net
-Status: Open +Status: Verified -Type: Bug +Type: Documentation Problem
 [2020-05-27 16:45 UTC] cmb@php.net
Indeed, 50% is the maximum permissible value.
 [2020-05-28 16:15 UTC] abuse at botrax dot com
What is also confusing is why various plugins read the value as 0.50% instead of 50%

0.50% is vastly different from 50%.
 [2020-06-01 14:37 UTC] cmb@php.net
-Type: Documentation Problem +Type: Bug
 [2020-06-01 14:37 UTC] cmb@php.net
Well, this is not only a documentation issue.  The modifier
callback changes the given value[1], but immediately after return,
the value gets changed back to what was passed[2].  That causes
ini_get() to return the originally set value, instead of the
adjusted value.

> What is also confusing is why various plugins read the value as
> 0.50% instead of 50%

I assume that is because these plugins retrieve the value via
opcache_get_configuration() which returns the value as float
number (not as percentage).  So if the value is given as 40, the
function would return it as 0.4.  The WordPress plugins having it
wrong should just multiply the value by 100 (and maybe round).

opcache.memory_consumption and opcache.max_accelerated_files have
the same problem, namely that they (temporarily) change the value,
but they ignore that change when actually assigning to the member
which holds the value.  So, for instance, setting the memory
consumption to 4 yields a warning that this value is too low, and
that the default of 8 MB would be used, but actually 4MB are used,
causing a fatal error.

[1] <https://github.com/php/php-src/blob/php-7.4.6/ext/opcache/zend_accelerator_module.c#L213>
[2] <https://github.com/php/php-src/blob/php-7.4.6/Zend/zend_ini.c#L254>
 [2020-06-02 11:39 UTC] cmb@php.net
> […] but they ignore that change when actually assigning to the
> member which holds the value.

No, these settings are handled exactly like
opcache.max_wasted_percentage.

The current behavior is documented now:
<http://svn.php.net/viewvc?view=revision&revision=350001>
 [2020-06-02 12:21 UTC] cmb@php.net
-Status: Verified +Status: Closed -Type: Bug +Type: Documentation Problem -Assigned To: +Assigned To: cmb
 [2020-06-02 12:21 UTC] cmb@php.net
I've filed a separate ticket (bug #79665) for the bug, and close this as doc problem.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Mon Nov 11 03:01:28 2024 UTC