Skip to content

JIT refactoring to allow run-time changes of JIT options #5580

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 3 commits into from

Conversation

dstogov
Copy link
Member

@dstogov dstogov commented May 15, 2020

This PR provides ability to change opcache.jit and opcache.jit_debug at run-time, to use different JIT triggers, optimization options and flags.

For now opcache.jit is kept as a numeric ABCD value with encoded flags, trigger and optimization level. In additional, it's possible to use 3 special value.

disable - may be used in php.ini to completely disable JIT
off - turn JIT off (it is possible to start PHP with jit=off and then enable it at run-time)
on - turn JIT on (with default options)

This PR makes a preparation for other improvement in JIT configuration options, like replacing numeric ABCD value, providing default value for opcache.jit_buffer_size, etc. See #5510

@dstogov
Copy link
Member Author

dstogov commented May 15, 2020

@beberlei @nikic please take a look

#define ZEND_JIT_TRACE_HOT_SIDE_COUNT 8 /* number of exits before taking side trace */
#define ZEND_JIT_TRACE_HOT_RETURN_COUNT 8 /* number of returns before taking continuation trace */

#define ZEND_JIT_TRACE_MAX_ROOT_FAILURES 16 /* number of attemts to record/compile a root trace */
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

attemts -> attempts

@nikic
Copy link
Member

nikic commented May 15, 2020

From a cursory look, this looks reasonable to me. The distinction between disable/off is not completely intuitive (that is, it's not really obvious which of them means "permanently disabled" and which "temporarily disabled"), but I don't have a good alternative suggestion.

There's a test failure in sapi/phpdbg/tests/exceptions_003.phpt, possibly due to whitespace difference.

|| zend_string_equals_literal_ci(jit, "on")
|| zend_string_equals_literal_ci(jit, "yes")
|| zend_string_equals_literal_ci(jit, "true")) {
JIT_G(enabled) = 1;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use zend_ini_parse_bool here instead?


if (ZSTR_LEN(jit) == 0
|| zend_string_equals_literal_ci(jit, "disable")
|| zend_string_equals_literal_ci(jit, "disabled")) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it’s better to stick to one valid value here, like “disable”

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK. This is not a problem. I expect mistakes, but we may improve the warning message

@laruence
Copy link
Member

laruence commented May 15, 2020

we could introduce some APIs to toggle the JIT setting in runtime instead of encourage people to use ini_set.
like

jit_enable(int level_flags, int trigger_flags);
jit_disable();

@dstogov
Copy link
Member Author

dstogov commented May 18, 2020

we could introduce some APIs to toggle the JIT setting in runtime instead of encourage people to use ini_set.
like

jit_enable(int level_flags, int trigger_flags);
jit_disable();

yeah, like this http://luajit.org/ext_jit.html

@dstogov
Copy link
Member Author

dstogov commented May 18, 2020

Merged as 0695048

@dstogov dstogov closed this May 18, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants