From 32828b70ef37da7c5b1eb5102e3220720154912f Mon Sep 17 00:00:00 2001 From: Andrew Collington Date: Wed, 25 Oct 2023 20:03:44 +0100 Subject: [PATCH] Updated for better JIT handling * JIT status now shows in 'General info' section * JIT memory stats hide if disabled for any reason * Shows reason why JIT might be disabled * Language files updated for new text --- README.md | 3 +++ build/_frontend/interface.jsx | 8 ++++++++ build/_languages/example.json | 8 +++++++- build/_languages/fr.json | 10 ++++++++-- build/build.php | 2 +- build/template.phps | 2 +- index.php | 36 ++++++++++++++++++++++++++++++----- package.json | 2 +- src/Opcache/Service.php | 27 +++++++++++++++++++++++--- 9 files changed, 84 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index b001e7b..45879bb 100644 --- a/README.md +++ b/README.md @@ -231,6 +231,9 @@ So to get started with a new language, copy the `example.json` to the language y ## 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**\ Worked around some inconsistencies with links in the opcache documentation on php.net. diff --git a/build/_frontend/interface.jsx b/build/_frontend/interface.jsx index 56a07a4..878a361 100644 --- a/build/_frontend/interface.jsx +++ b/build/_frontend/interface.jsx @@ -114,6 +114,7 @@ function MainNavigation(props) { start={props.opstate.overview && props.opstate.overview.readable.start_time || null} reset={props.opstate.overview && props.opstate.overview.readable.last_restart_time || null} version={props.opstate.version} + jit={props.opstate.jitState} txt={props.txt} /> {props.txt('Server Software')}{props.version.server} { props.start ? {props.txt('Start time')}{props.start} : null } { props.reset ? {props.txt('Last reset')}{props.reset} : null } + + {props.txt('JIT enabled')} + + {props.txt(props.jit.enabled ? "Yes" : "No")} + {props.jit.reason && ()} + + ); diff --git a/build/_languages/example.json b/build/_languages/example.json index 973ac58..ccac484 100644 --- a/build/_languages/example.json +++ b/build/_languages/example.json @@ -103,5 +103,11 @@ "{0} files cached": "", "{0} files cached, {1} showing due to filter '{2}'": "", "{0} ignore file locations": "", - "{0} preloaded files": "" + "{0} preloaded files": "", + "JIT enabled": "", + "disabled due to opcache.jit setting": "", + "the opcache.jit_buffer_size must be set to fully enable JIT": "", + "incompatible with extensions that override zend_execute_ex(), such as xdebug": "", + "Yes": "", + "No": "" } diff --git a/build/_languages/fr.json b/build/_languages/fr.json index 52776a6..a808a1c 100644 --- a/build/_languages/fr.json +++ b/build/_languages/fr.json @@ -103,5 +103,11 @@ "{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} ignore file locations": "{0} ignore les fichiers en fonction de l'emplacement", - "{0} preloaded files": "{0} fichiers préchargés" -} \ No newline at end of file + "{0} preloaded files": "{0} fichiers préchargés", + "JIT enabled": "JIT activé", + "disabled due to opcache.jit setting": "désactivé en raison du paramètre opcache.jit", + "the opcache.jit_buffer_size must be set to fully enable JIT": "le opcache.jit_buffer_size doit être défini pour activer complètement JIT", + "incompatible with extensions that override zend_execute_ex(), such as xdebug": "incompatible avec les extensions qui remplacent zend_execute_ex(), telles que xdebug", + "Yes": "Oui", + "No": "Non" +} diff --git a/build/build.php b/build/build.php index ca627b6..1b69f63 100644 --- a/build/build.php +++ b/build/build.php @@ -4,7 +4,7 @@ * OPcache GUI - build script * * @author Andrew Collington, andy@amnuts.com - * @version 3.5.3 + * @version 3.5.4 * @link https://github.com/amnuts/opcache-gui * @license MIT, https://acollington.mit-license.org/ */ diff --git a/build/template.phps b/build/template.phps index f3af19a..fe26295 100644 --- a/build/template.phps +++ b/build/template.phps @@ -6,7 +6,7 @@ * A simple but effective single-file GUI for the OPcache PHP extension. * * @author Andrew Collington, andy@amnuts.com - * @version 3.5.3 + * @version 3.5.4 * @link https://github.com/amnuts/opcache-gui * @license MIT, https://acollington.mit-license.org/ */ diff --git a/index.php b/index.php index 9ecc9d0..e237275 100644 --- a/index.php +++ b/index.php @@ -6,7 +6,7 @@ * A simple but effective single-file GUI for the OPcache PHP extension. * * @author Andrew Collington, andy@amnuts.com - * @version 3.5.3 + * @version 3.5.4 * @link https://github.com/amnuts/opcache-gui * @license MIT, https://acollington.mit-license.org/ */ @@ -59,7 +59,7 @@ class Service { - public const VERSION = '3.5.3'; + public const VERSION = '3.5.4'; protected $tz; protected $data; @@ -417,7 +417,7 @@ protected function compileState(): array ]; } - if ($overview && !empty($status['jit'])) { + if ($overview && !empty($status['jit']['enabled'])) { $overview['jit_buffer_used_percentage'] = ($status['jit']['buffer_size'] ? round(100 * (($status['jit']['buffer_size'] - $status['jit']['buffer_free']) / $status['jit']['buffer_size'])) : 0 @@ -488,9 +488,30 @@ protected function compileState(): array 'preload' => $preload, 'directives' => $directives, '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 opcache.jit setting'); + } elseif (!$directives['opcache.jit_buffer_size']) { + $state['reason'] = $this->txt('the opcache.jit_buffer_size must be set to fully enable JIT'); + } else { + $state['reason'] = $this->txt('incompatible with extensions that override zend_execute_ex(), such as xdebug'); + } + } + + return $state; + } } $opcache = (new Service($options))->handle(); @@ -659,6 +680,7 @@ className: "tab-content-overview-info" start: props.opstate.overview && props.opstate.overview.readable.start_time || null, reset: props.opstate.overview && props.opstate.overview.readable.last_restart_time || null, version: props.opstate.version, + jit: props.opstate.jitState, txt: props.txt }), /*#__PURE__*/React.createElement(Directives, { directives: props.opstate.directives, @@ -896,7 +918,11 @@ function GeneralInfo(props) { className: "tables general-info-table" }, /*#__PURE__*/React.createElement("thead", null, /*#__PURE__*/React.createElement("tr", null, /*#__PURE__*/React.createElement("th", { 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) { diff --git a/package.json b/package.json index 160dfe2..28adff7 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "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).", - "version": "3.5.3", + "version": "3.5.4", "main": "index.js", "devDependencies": { "@babel/cli": "^7.12.8", diff --git a/src/Opcache/Service.php b/src/Opcache/Service.php index ab785ee..8f09bd2 100644 --- a/src/Opcache/Service.php +++ b/src/Opcache/Service.php @@ -8,7 +8,7 @@ class Service { - public const VERSION = '3.5.3'; + public const VERSION = '3.5.4'; protected $tz; protected $data; @@ -366,7 +366,7 @@ protected function compileState(): array ]; } - if ($overview && !empty($status['jit'])) { + if ($overview && !empty($status['jit']['enabled'])) { $overview['jit_buffer_used_percentage'] = ($status['jit']['buffer_size'] ? round(100 * (($status['jit']['buffer_size'] - $status['jit']['buffer_free']) / $status['jit']['buffer_size'])) : 0 @@ -437,7 +437,28 @@ protected function compileState(): array 'preload' => $preload, 'directives' => $directives, '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 opcache.jit setting'); + } elseif (!$directives['opcache.jit_buffer_size']) { + $state['reason'] = $this->txt('the opcache.jit_buffer_size must be set to fully enable JIT'); + } else { + $state['reason'] = $this->txt('incompatible with extensions that override zend_execute_ex(), such as xdebug'); + } + } + + return $state; + } }