Merge pull request #106 from amnuts/105-jit-disabled

Updated for better JIT handling
This commit is contained in:
Andrew Collington 2023-10-25 20:09:56 +01:00 committed by GitHub
commit f3a8fe44c0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 84 additions and 14 deletions

View file

@ -231,6 +231,9 @@ So to get started with a new language, copy the `example.json` to the language y
## Releases ## Releases
**Version 3.5.4**\
Better handling of whether JIT is enabled or disabled. Now also shows _why_ it might be disabled even if you have the setting turned on. The interface also disables the graph and memory stats correctly for JIT if it's disabled for any reason.
**Version 3.5.3**\ **Version 3.5.3**\
Worked around some inconsistencies with links in the opcache documentation on php.net. Worked around some inconsistencies with links in the opcache documentation on php.net.

View file

@ -114,6 +114,7 @@ function MainNavigation(props) {
start={props.opstate.overview && props.opstate.overview.readable.start_time || null} start={props.opstate.overview && props.opstate.overview.readable.start_time || null}
reset={props.opstate.overview && props.opstate.overview.readable.last_restart_time || null} reset={props.opstate.overview && props.opstate.overview.readable.last_restart_time || null}
version={props.opstate.version} version={props.opstate.version}
jit={props.opstate.jitState}
txt={props.txt} txt={props.txt}
/> />
<Directives <Directives
@ -347,6 +348,13 @@ function GeneralInfo(props) {
<tr><td>{props.txt('Server Software')}</td><td>{props.version.server}</td></tr> <tr><td>{props.txt('Server Software')}</td><td>{props.version.server}</td></tr>
{ props.start ? <tr><td>{props.txt('Start time')}</td><td>{props.start}</td></tr> : null } { props.start ? <tr><td>{props.txt('Start time')}</td><td>{props.start}</td></tr> : null }
{ props.reset ? <tr><td>{props.txt('Last reset')}</td><td>{props.reset}</td></tr> : null } { props.reset ? <tr><td>{props.txt('Last reset')}</td><td>{props.reset}</td></tr> : null }
<tr>
<td>{props.txt('JIT enabled')}</td>
<td>
{props.txt(props.jit.enabled ? "Yes" : "No")}
{props.jit.reason && (<span dangerouslySetInnerHTML={{__html: ` (${props.jit.reason})` }} />)}
</td>
</tr>
</tbody> </tbody>
</table> </table>
); );

View file

@ -103,5 +103,11 @@
"{0} files cached": "", "{0} files cached": "",
"{0} files cached, {1} showing due to filter '{2}'": "", "{0} files cached, {1} showing due to filter '{2}'": "",
"{0} ignore file locations": "", "{0} ignore file locations": "",
"{0} preloaded files": "" "{0} preloaded files": "",
"JIT enabled": "",
"disabled due to <i>opcache.jit</i> setting": "",
"the <i>opcache.jit_buffer_size</i> must be set to fully enable JIT": "",
"incompatible with extensions that override <i>zend_execute_ex()</i>, such as <i>xdebug</i>": "",
"Yes": "",
"No": ""
} }

View file

@ -103,5 +103,11 @@
"{0} files cached": "{0} fichiers mis en cache", "{0} files cached": "{0} fichiers mis en cache",
"{0} files cached, {1} showing due to filter '{2}'": "{0} fichiers mis en cache, {1} s'affichent en raison du filtre '{2}'", "{0} files cached, {1} showing due to filter '{2}'": "{0} fichiers mis en cache, {1} s'affichent en raison du filtre '{2}'",
"{0} ignore file locations": "{0} ignore les fichiers en fonction de l'emplacement", "{0} ignore file locations": "{0} ignore les fichiers en fonction de l'emplacement",
"{0} preloaded files": "{0} fichiers préchargés" "{0} preloaded files": "{0} fichiers préchargés",
} "JIT enabled": "JIT activé",
"disabled due to <i>opcache.jit</i> setting": "désactivé en raison du paramètre <i>opcache.jit</i>",
"the <i>opcache.jit_buffer_size</i> must be set to fully enable JIT": "le <i>opcache.jit_buffer_size</i> doit être défini pour activer complètement JIT",
"incompatible with extensions that override <i>zend_execute_ex()</i>, such as <i>xdebug</i>": "incompatible avec les extensions qui remplacent <i>zend_execute_ex()</i>, telles que <i>xdebug</i>",
"Yes": "Oui",
"No": "Non"
}

View file

@ -4,7 +4,7 @@
* OPcache GUI - build script * OPcache GUI - build script
* *
* @author Andrew Collington, andy@amnuts.com * @author Andrew Collington, andy@amnuts.com
* @version 3.5.3 * @version 3.5.4
* @link https://github.com/amnuts/opcache-gui * @link https://github.com/amnuts/opcache-gui
* @license MIT, https://acollington.mit-license.org/ * @license MIT, https://acollington.mit-license.org/
*/ */

View file

@ -6,7 +6,7 @@
* A simple but effective single-file GUI for the OPcache PHP extension. * A simple but effective single-file GUI for the OPcache PHP extension.
* *
* @author Andrew Collington, andy@amnuts.com * @author Andrew Collington, andy@amnuts.com
* @version 3.5.3 * @version 3.5.4
* @link https://github.com/amnuts/opcache-gui * @link https://github.com/amnuts/opcache-gui
* @license MIT, https://acollington.mit-license.org/ * @license MIT, https://acollington.mit-license.org/
*/ */

View file

@ -6,7 +6,7 @@
* A simple but effective single-file GUI for the OPcache PHP extension. * A simple but effective single-file GUI for the OPcache PHP extension.
* *
* @author Andrew Collington, andy@amnuts.com * @author Andrew Collington, andy@amnuts.com
* @version 3.5.3 * @version 3.5.4
* @link https://github.com/amnuts/opcache-gui * @link https://github.com/amnuts/opcache-gui
* @license MIT, https://acollington.mit-license.org/ * @license MIT, https://acollington.mit-license.org/
*/ */
@ -59,7 +59,7 @@ header('Pragma: no-cache');
class Service class Service
{ {
public const VERSION = '3.5.3'; public const VERSION = '3.5.4';
protected $tz; protected $tz;
protected $data; protected $data;
@ -417,7 +417,7 @@ class Service
]; ];
} }
if ($overview && !empty($status['jit'])) { if ($overview && !empty($status['jit']['enabled'])) {
$overview['jit_buffer_used_percentage'] = ($status['jit']['buffer_size'] $overview['jit_buffer_used_percentage'] = ($status['jit']['buffer_size']
? round(100 * (($status['jit']['buffer_size'] - $status['jit']['buffer_free']) / $status['jit']['buffer_size'])) ? round(100 * (($status['jit']['buffer_size'] - $status['jit']['buffer_free']) / $status['jit']['buffer_size']))
: 0 : 0
@ -488,9 +488,30 @@ class Service
'preload' => $preload, 'preload' => $preload,
'directives' => $directives, 'directives' => $directives,
'blacklist' => $config['blacklist'], 'blacklist' => $config['blacklist'],
'functions' => get_extension_funcs('Zend OPcache') 'functions' => get_extension_funcs('Zend OPcache'),
'jitState' => $this->jitState($status, $config['directives']),
]; ];
} }
protected function jitState(array $status, array $directives): array
{
$state = [
'enabled' => $status['jit']['enabled'],
'reason' => ''
];
if (!$state['enabled']) {
if (empty($directives['opcache.jit']) || $directives['opcache.jit'] === 'disable') {
$state['reason'] = $this->txt('disabled due to <i>opcache.jit</i> setting');
} elseif (!$directives['opcache.jit_buffer_size']) {
$state['reason'] = $this->txt('the <i>opcache.jit_buffer_size</i> must be set to fully enable JIT');
} else {
$state['reason'] = $this->txt('incompatible with extensions that override <i>zend_execute_ex()</i>, such as <i>xdebug</i>');
}
}
return $state;
}
} }
$opcache = (new Service($options))->handle(); $opcache = (new Service($options))->handle();
@ -659,6 +680,7 @@ function MainNavigation(props) {
start: props.opstate.overview && props.opstate.overview.readable.start_time || null, start: props.opstate.overview && props.opstate.overview.readable.start_time || null,
reset: props.opstate.overview && props.opstate.overview.readable.last_restart_time || null, reset: props.opstate.overview && props.opstate.overview.readable.last_restart_time || null,
version: props.opstate.version, version: props.opstate.version,
jit: props.opstate.jitState,
txt: props.txt txt: props.txt
}), /*#__PURE__*/React.createElement(Directives, { }), /*#__PURE__*/React.createElement(Directives, {
directives: props.opstate.directives, directives: props.opstate.directives,
@ -896,7 +918,11 @@ function GeneralInfo(props) {
className: "tables general-info-table" className: "tables general-info-table"
}, /*#__PURE__*/React.createElement("thead", null, /*#__PURE__*/React.createElement("tr", null, /*#__PURE__*/React.createElement("th", { }, /*#__PURE__*/React.createElement("thead", null, /*#__PURE__*/React.createElement("tr", null, /*#__PURE__*/React.createElement("th", {
colSpan: "2" colSpan: "2"
}, props.txt('General info')))), /*#__PURE__*/React.createElement("tbody", null, /*#__PURE__*/React.createElement("tr", null, /*#__PURE__*/React.createElement("td", null, "Zend OPcache"), /*#__PURE__*/React.createElement("td", null, props.version.version)), /*#__PURE__*/React.createElement("tr", null, /*#__PURE__*/React.createElement("td", null, "PHP"), /*#__PURE__*/React.createElement("td", null, props.version.php)), /*#__PURE__*/React.createElement("tr", null, /*#__PURE__*/React.createElement("td", null, props.txt('Host')), /*#__PURE__*/React.createElement("td", null, props.version.host)), /*#__PURE__*/React.createElement("tr", null, /*#__PURE__*/React.createElement("td", null, props.txt('Server Software')), /*#__PURE__*/React.createElement("td", null, props.version.server)), props.start ? /*#__PURE__*/React.createElement("tr", null, /*#__PURE__*/React.createElement("td", null, props.txt('Start time')), /*#__PURE__*/React.createElement("td", null, props.start)) : null, props.reset ? /*#__PURE__*/React.createElement("tr", null, /*#__PURE__*/React.createElement("td", null, props.txt('Last reset')), /*#__PURE__*/React.createElement("td", null, props.reset)) : null)); }, props.txt('General info')))), /*#__PURE__*/React.createElement("tbody", null, /*#__PURE__*/React.createElement("tr", null, /*#__PURE__*/React.createElement("td", null, "Zend OPcache"), /*#__PURE__*/React.createElement("td", null, props.version.version)), /*#__PURE__*/React.createElement("tr", null, /*#__PURE__*/React.createElement("td", null, "PHP"), /*#__PURE__*/React.createElement("td", null, props.version.php)), /*#__PURE__*/React.createElement("tr", null, /*#__PURE__*/React.createElement("td", null, props.txt('Host')), /*#__PURE__*/React.createElement("td", null, props.version.host)), /*#__PURE__*/React.createElement("tr", null, /*#__PURE__*/React.createElement("td", null, props.txt('Server Software')), /*#__PURE__*/React.createElement("td", null, props.version.server)), props.start ? /*#__PURE__*/React.createElement("tr", null, /*#__PURE__*/React.createElement("td", null, props.txt('Start time')), /*#__PURE__*/React.createElement("td", null, props.start)) : null, props.reset ? /*#__PURE__*/React.createElement("tr", null, /*#__PURE__*/React.createElement("td", null, props.txt('Last reset')), /*#__PURE__*/React.createElement("td", null, props.reset)) : null, /*#__PURE__*/React.createElement("tr", null, /*#__PURE__*/React.createElement("td", null, props.txt('JIT enabled')), /*#__PURE__*/React.createElement("td", null, props.txt(props.jit.enabled ? "Yes" : "No"), props.jit.reason && /*#__PURE__*/React.createElement("span", {
dangerouslySetInnerHTML: {
__html: ` (${props.jit.reason})`
}
})))));
} }
function Directives(props) { function Directives(props) {

View file

@ -1,7 +1,7 @@
{ {
"name": "opcache-gui", "name": "opcache-gui",
"description": "A clean and responsive interface for Zend OPcache information, showing statistics, settings and cached files, and providing a real-time update for the information (using jQuery and React).", "description": "A clean and responsive interface for Zend OPcache information, showing statistics, settings and cached files, and providing a real-time update for the information (using jQuery and React).",
"version": "3.5.3", "version": "3.5.4",
"main": "index.js", "main": "index.js",
"devDependencies": { "devDependencies": {
"@babel/cli": "^7.12.8", "@babel/cli": "^7.12.8",

View file

@ -8,7 +8,7 @@ use Exception;
class Service class Service
{ {
public const VERSION = '3.5.3'; public const VERSION = '3.5.4';
protected $tz; protected $tz;
protected $data; protected $data;
@ -366,7 +366,7 @@ class Service
]; ];
} }
if ($overview && !empty($status['jit'])) { if ($overview && !empty($status['jit']['enabled'])) {
$overview['jit_buffer_used_percentage'] = ($status['jit']['buffer_size'] $overview['jit_buffer_used_percentage'] = ($status['jit']['buffer_size']
? round(100 * (($status['jit']['buffer_size'] - $status['jit']['buffer_free']) / $status['jit']['buffer_size'])) ? round(100 * (($status['jit']['buffer_size'] - $status['jit']['buffer_free']) / $status['jit']['buffer_size']))
: 0 : 0
@ -437,7 +437,28 @@ class Service
'preload' => $preload, 'preload' => $preload,
'directives' => $directives, 'directives' => $directives,
'blacklist' => $config['blacklist'], 'blacklist' => $config['blacklist'],
'functions' => get_extension_funcs('Zend OPcache') 'functions' => get_extension_funcs('Zend OPcache'),
'jitState' => $this->jitState($status, $config['directives']),
]; ];
} }
protected function jitState(array $status, array $directives): array
{
$state = [
'enabled' => $status['jit']['enabled'],
'reason' => ''
];
if (!$state['enabled']) {
if (empty($directives['opcache.jit']) || $directives['opcache.jit'] === 'disable') {
$state['reason'] = $this->txt('disabled due to <i>opcache.jit</i> setting');
} elseif (!$directives['opcache.jit_buffer_size']) {
$state['reason'] = $this->txt('the <i>opcache.jit_buffer_size</i> must be set to fully enable JIT');
} else {
$state['reason'] = $this->txt('incompatible with extensions that override <i>zend_execute_ex()</i>, such as <i>xdebug</i>');
}
}
return $state;
}
} }