Skip to content

Commit f3a8fe4

Browse files
authored
Merge pull request #106 from amnuts/105-jit-disabled
Updated for better JIT handling
2 parents edbcbbe + 32828b7 commit f3a8fe4

File tree

9 files changed

+84
-14
lines changed

9 files changed

+84
-14
lines changed

README.md

+3
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,9 @@ So to get started with a new language, copy the `example.json` to the language y
231231

232232
## Releases
233233

234+
**Version 3.5.4**\
235+
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.
236+
234237
**Version 3.5.3**\
235238
Worked around some inconsistencies with links in the opcache documentation on php.net.
236239

build/_frontend/interface.jsx

+8
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ function MainNavigation(props) {
114114
start={props.opstate.overview && props.opstate.overview.readable.start_time || null}
115115
reset={props.opstate.overview && props.opstate.overview.readable.last_restart_time || null}
116116
version={props.opstate.version}
117+
jit={props.opstate.jitState}
117118
txt={props.txt}
118119
/>
119120
<Directives
@@ -347,6 +348,13 @@ function GeneralInfo(props) {
347348
<tr><td>{props.txt('Server Software')}</td><td>{props.version.server}</td></tr>
348349
{ props.start ? <tr><td>{props.txt('Start time')}</td><td>{props.start}</td></tr> : null }
349350
{ props.reset ? <tr><td>{props.txt('Last reset')}</td><td>{props.reset}</td></tr> : null }
351+
<tr>
352+
<td>{props.txt('JIT enabled')}</td>
353+
<td>
354+
{props.txt(props.jit.enabled ? "Yes" : "No")}
355+
{props.jit.reason && (<span dangerouslySetInnerHTML={{__html: ` (${props.jit.reason})` }} />)}
356+
</td>
357+
</tr>
350358
</tbody>
351359
</table>
352360
);

build/_languages/example.json

+7-1
Original file line numberDiff line numberDiff line change
@@ -103,5 +103,11 @@
103103
"{0} files cached": "",
104104
"{0} files cached, {1} showing due to filter '{2}'": "",
105105
"{0} ignore file locations": "",
106-
"{0} preloaded files": ""
106+
"{0} preloaded files": "",
107+
"JIT enabled": "",
108+
"disabled due to <i>opcache.jit</i> setting": "",
109+
"the <i>opcache.jit_buffer_size</i> must be set to fully enable JIT": "",
110+
"incompatible with extensions that override <i>zend_execute_ex()</i>, such as <i>xdebug</i>": "",
111+
"Yes": "",
112+
"No": ""
107113
}

build/_languages/fr.json

+8-2
Original file line numberDiff line numberDiff line change
@@ -103,5 +103,11 @@
103103
"{0} files cached": "{0} fichiers mis en cache",
104104
"{0} files cached, {1} showing due to filter '{2}'": "{0} fichiers mis en cache, {1} s'affichent en raison du filtre '{2}'",
105105
"{0} ignore file locations": "{0} ignore les fichiers en fonction de l'emplacement",
106-
"{0} preloaded files": "{0} fichiers préchargés"
107-
}
106+
"{0} preloaded files": "{0} fichiers préchargés",
107+
"JIT enabled": "JIT activé",
108+
"disabled due to <i>opcache.jit</i> setting": "désactivé en raison du paramètre <i>opcache.jit</i>",
109+
"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",
110+
"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>",
111+
"Yes": "Oui",
112+
"No": "Non"
113+
}

build/build.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
* OPcache GUI - build script
55
*
66
* @author Andrew Collington, andy@amnuts.com
7-
* @version 3.5.3
7+
* @version 3.5.4
88
* @link https://github.com/amnuts/opcache-gui
99
* @license MIT, https://acollington.mit-license.org/
1010
*/

build/template.phps

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* A simple but effective single-file GUI for the OPcache PHP extension.
77
*
88
* @author Andrew Collington, andy@amnuts.com
9-
* @version 3.5.3
9+
* @version 3.5.4
1010
* @link https://github.com/amnuts/opcache-gui
1111
* @license MIT, https://acollington.mit-license.org/
1212
*/

index.php

+31-5
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
* A simple but effective single-file GUI for the OPcache PHP extension.
77
*
88
* @author Andrew Collington, andy@amnuts.com
9-
* @version 3.5.3
9+
* @version 3.5.4
1010
* @link https://github.com/amnuts/opcache-gui
1111
* @license MIT, https://acollington.mit-license.org/
1212
*/
@@ -59,7 +59,7 @@
5959

6060
class Service
6161
{
62-
public const VERSION = '3.5.3';
62+
public const VERSION = '3.5.4';
6363

6464
protected $tz;
6565
protected $data;
@@ -417,7 +417,7 @@ protected function compileState(): array
417417
];
418418
}
419419

420-
if ($overview && !empty($status['jit'])) {
420+
if ($overview && !empty($status['jit']['enabled'])) {
421421
$overview['jit_buffer_used_percentage'] = ($status['jit']['buffer_size']
422422
? round(100 * (($status['jit']['buffer_size'] - $status['jit']['buffer_free']) / $status['jit']['buffer_size']))
423423
: 0
@@ -488,9 +488,30 @@ protected function compileState(): array
488488
'preload' => $preload,
489489
'directives' => $directives,
490490
'blacklist' => $config['blacklist'],
491-
'functions' => get_extension_funcs('Zend OPcache')
491+
'functions' => get_extension_funcs('Zend OPcache'),
492+
'jitState' => $this->jitState($status, $config['directives']),
492493
];
493494
}
495+
496+
protected function jitState(array $status, array $directives): array
497+
{
498+
$state = [
499+
'enabled' => $status['jit']['enabled'],
500+
'reason' => ''
501+
];
502+
503+
if (!$state['enabled']) {
504+
if (empty($directives['opcache.jit']) || $directives['opcache.jit'] === 'disable') {
505+
$state['reason'] = $this->txt('disabled due to <i>opcache.jit</i> setting');
506+
} elseif (!$directives['opcache.jit_buffer_size']) {
507+
$state['reason'] = $this->txt('the <i>opcache.jit_buffer_size</i> must be set to fully enable JIT');
508+
} else {
509+
$state['reason'] = $this->txt('incompatible with extensions that override <i>zend_execute_ex()</i>, such as <i>xdebug</i>');
510+
}
511+
}
512+
513+
return $state;
514+
}
494515
}
495516

496517
$opcache = (new Service($options))->handle();
@@ -659,6 +680,7 @@ className: "tab-content-overview-info"
659680
start: props.opstate.overview && props.opstate.overview.readable.start_time || null,
660681
reset: props.opstate.overview && props.opstate.overview.readable.last_restart_time || null,
661682
version: props.opstate.version,
683+
jit: props.opstate.jitState,
662684
txt: props.txt
663685
}), /*#__PURE__*/React.createElement(Directives, {
664686
directives: props.opstate.directives,
@@ -896,7 +918,11 @@ function GeneralInfo(props) {
896918
className: "tables general-info-table"
897919
}, /*#__PURE__*/React.createElement("thead", null, /*#__PURE__*/React.createElement("tr", null, /*#__PURE__*/React.createElement("th", {
898920
colSpan: "2"
899-
}, 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));
921+
}, 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", {
922+
dangerouslySetInnerHTML: {
923+
__html: ` (${props.jit.reason})`
924+
}
925+
})))));
900926
}
901927

902928
function Directives(props) {

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "opcache-gui",
33
"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).",
4-
"version": "3.5.3",
4+
"version": "3.5.4",
55
"main": "index.js",
66
"devDependencies": {
77
"@babel/cli": "^7.12.8",

src/Opcache/Service.php

+24-3
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
class Service
1010
{
11-
public const VERSION = '3.5.3';
11+
public const VERSION = '3.5.4';
1212

1313
protected $tz;
1414
protected $data;
@@ -366,7 +366,7 @@ protected function compileState(): array
366366
];
367367
}
368368

369-
if ($overview && !empty($status['jit'])) {
369+
if ($overview && !empty($status['jit']['enabled'])) {
370370
$overview['jit_buffer_used_percentage'] = ($status['jit']['buffer_size']
371371
? round(100 * (($status['jit']['buffer_size'] - $status['jit']['buffer_free']) / $status['jit']['buffer_size']))
372372
: 0
@@ -437,7 +437,28 @@ protected function compileState(): array
437437
'preload' => $preload,
438438
'directives' => $directives,
439439
'blacklist' => $config['blacklist'],
440-
'functions' => get_extension_funcs('Zend OPcache')
440+
'functions' => get_extension_funcs('Zend OPcache'),
441+
'jitState' => $this->jitState($status, $config['directives']),
441442
];
442443
}
444+
445+
protected function jitState(array $status, array $directives): array
446+
{
447+
$state = [
448+
'enabled' => $status['jit']['enabled'],
449+
'reason' => ''
450+
];
451+
452+
if (!$state['enabled']) {
453+
if (empty($directives['opcache.jit']) || $directives['opcache.jit'] === 'disable') {
454+
$state['reason'] = $this->txt('disabled due to <i>opcache.jit</i> setting');
455+
} elseif (!$directives['opcache.jit_buffer_size']) {
456+
$state['reason'] = $this->txt('the <i>opcache.jit_buffer_size</i> must be set to fully enable JIT');
457+
} else {
458+
$state['reason'] = $this->txt('incompatible with extensions that override <i>zend_execute_ex()</i>, such as <i>xdebug</i>');
459+
}
460+
}
461+
462+
return $state;
463+
}
443464
}

0 commit comments

Comments
 (0)