Skip to content

Commit

Permalink
Merge pull request #106 from amnuts/105-jit-disabled
Browse files Browse the repository at this point in the history
Updated for better JIT handling
  • Loading branch information
amnuts committed Oct 25, 2023
2 parents edbcbbe + 32828b7 commit f3a8fe4
Show file tree
Hide file tree
Showing 9 changed files with 84 additions and 14 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
8 changes: 8 additions & 0 deletions build/_frontend/interface.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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}
/>
<Directives
Expand Down Expand Up @@ -347,6 +348,13 @@ function GeneralInfo(props) {
<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.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>
</table>
);
Expand Down
8 changes: 7 additions & 1 deletion build/_languages/example.json
Original file line number Diff line number Diff line change
Expand Up @@ -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 <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": ""
}
10 changes: 8 additions & 2 deletions build/_languages/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
"{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"
}
2 changes: 1 addition & 1 deletion build/build.php
Original file line number Diff line number Diff line change
Expand Up @@ -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/
*/
Expand Down
2 changes: 1 addition & 1 deletion build/template.phps
Original file line number Diff line number Diff line change
Expand Up @@ -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/
*/
Expand Down
36 changes: 31 additions & 5 deletions index.php
Original file line number Diff line number Diff line change
Expand Up @@ -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/
*/
Expand Down Expand Up @@ -59,7 +59,7 @@

class Service
{
public const VERSION = '3.5.3';
public const VERSION = '3.5.4';

protected $tz;
protected $data;
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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 <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();
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
27 changes: 24 additions & 3 deletions src/Opcache/Service.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

class Service
{
public const VERSION = '3.5.3';
public const VERSION = '3.5.4';

protected $tz;
protected $data;
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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 <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;
}
}

0 comments on commit f3a8fe4

Please sign in to comment.