Skip to content
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

Trigger JIT tracing&compilation more often in tests #12250

Closed
wants to merge 29 commits into from

Conversation

danog
Copy link
Contributor

@danog danog commented Sep 20, 2023

In my understanding, this should catch more issues (actually, running the amphp/parallel tests with this JIT config locally already causes a hang...).
I've also considered adding Psalm and PHPUnit to the nightly tests, would you be OK with that?

@danog danog changed the title Trigger JIT tracing&compilation more often, enable JIT for ASAN Trigger JIT tracing&compilation more often in tests, enable JIT for ASAN Sep 20, 2023
@danog danog changed the title Trigger JIT tracing&compilation more often in tests, enable JIT for ASAN Trigger JIT tracing&compilation more often in tests Sep 20, 2023
Copy link
Member

@iluuu1994 iluuu1994 left a comment

Choose a reason for hiding this comment

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

Thanks for investigating! In terms of the specific flags, @dstogov should judge whether they make sense.

I've also considered adding Psalm and PHPUnit to the nightly tests, would you be OK with that?

We already have PHPUnit in the COMMUNITY job. Adding Psalm is ok if it doesn't unreasonably increase build-time. Although adding PHPStan would likely make more sense given its popularity.

.github/workflows/nightly.yml Outdated Show resolved Hide resolved
@danog
Copy link
Contributor Author

danog commented Sep 20, 2023

Sorry, meant to say phpseclib instead of phpunit :)
Sure, I can add both psalm and phpstan, just running a scan on the project itself ought to be enough to trigger eventual JIT bugs, without running the phpunit testsuites to avoid raising test times too much.

@danog
Copy link
Contributor Author

danog commented Sep 20, 2023

Also, would you be OK with adding https://github.com/amphp/ext-uv to the amphp tests?

Comment on lines 112 to 118
-d opcache.jit_max_root_traces=10000000
-d opcache.jit_max_side_traces=10000000
-d opcache.jit_max_exit_counters=1000000
-d opcache.jit_hot_loop=1
-d opcache.jit_hot_func=1
-d opcache.jit_hot_return=1
-d opcache.jit_hot_side_exit=1
Copy link
Member

Choose a reason for hiding this comment

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

These are probably not the best settings, because they will trigger JIT compilation on the first function entry or loop iteration and this sometime may lead to very unnatural traces that will never executed.

Anyway, I think it make sense to start with these settings and then change them to a bit less aggressive. (e.g. 2 or 3).

Note, that these settings may increase the tests time.

Copy link
Contributor Author

@danog danog Sep 20, 2023

Choose a reason for hiding this comment

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

I am aware they increase test times, JIT compilation on first function entry/loop iteration is precisely why I chose those values, any other value (even 2) already breaks reproduction of bugs like #12249

Copy link
Member

@dstogov dstogov left a comment

Choose a reason for hiding this comment

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

Looks fine. Just remove jit_prof_threshold.

@@ -198,7 +205,14 @@ jobs:
${{ matrix.run_tests_parameters }}
-d zend_extension=opcache.so
-d opcache.enable_cli=1
-d opcache.jit_buffer_size=16M
-d opcache.jit_buffer_size=64M
Copy link
Member

Choose a reason for hiding this comment

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

We should probably move this to a common place, e.g. directly in .github/actions/test-linux/action.yml and enable it via parameter.

Copy link
Contributor Author

@danog danog Sep 20, 2023

Choose a reason for hiding this comment

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

Actually, all JIT parameters can directly be moved unconditionally in .github/actions/test-linux/action.yml, and here we can just provide the -d zend_extension=opcache.so, let me do that...

@iluuu1994
Copy link
Member

iluuu1994 commented Sep 20, 2023

@danog Can you please also make the changes in push.yml? I'd like to see how much this adds to the build time. I'm also worried it will make the COMMUNITY job much slower. It may even be counterproductive if too many things fill the cache quickly.

@danog
Copy link
Contributor Author

danog commented Sep 20, 2023

Done!

@danog
Copy link
Contributor Author

danog commented Sep 20, 2023

@iluuu1994 Seems the build times are OK, they're somehow even better than on master?

https://github.com/danog/php-src/actions/runs/6253638654/job/16979522694

@danog
Copy link
Contributor Author

danog commented Sep 21, 2023

Added phpseclib, psalm and phpstan JIT nightly tests, and added ext-uv to the AMP tests since that's generally the best driver for AMP.

Also changed the JIT config in all other CIs.

Copy link
Member

@iluuu1994 iluuu1994 left a comment

Choose a reason for hiding this comment

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

Thanks @danog!

.github/workflows/nightly.yml Outdated Show resolved Hide resolved
echo opcache.jit_hot_side_exit=1 >> /etc/php.d/opcache.ini
echo memory_limit=-1 >> /etc/php.d/opcache.ini
php -v
- name: Test PHPSeclib
Copy link
Member

Choose a reason for hiding this comment

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

Can you please split this into a separate PR? Can you also temporarily copy this to push.yml to show that the tests are succeeding? It would be great if we could trigger this on-demand, but we don't have that currently...

Copy link
Contributor Author

@danog danog Sep 22, 2023

Choose a reason for hiding this comment

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

Will split this to a separate PR, actually most of the new nightly tests are failing under JIT, might be worth pinging @dstogov about this:

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Split to #12270

Copy link
Member

Choose a reason for hiding this comment

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

Will split this to a separate PR, actually most of the new nightly tests are failing under JIT, might be worth pinging @dstogov about this:

Thanks. I've assigned these three issues to myself.

@@ -129,7 +129,7 @@ jobs:
runTestsParameters: >-
-d zend_extension=opcache.so
-d opcache.enable_cli=1
${{ !matrix.asan && '-d opcache.jit_buffer_size=16M' || '' }}
${{ matrix.asan && '-d opcache.jit=disable' || '-d opcache.jit=tracing' }}
Copy link
Member

Choose a reason for hiding this comment

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

This would result in opcache.jit=tracing twice for non-asan, as it's already added in the test action.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hmm, where? I see only two instances of opcache.jit=tracing in this workflow, one here and the other in the mac OS tests...

ext/opcache/tests/jit/bug11917.phpt Outdated Show resolved Hide resolved
@danog
Copy link
Contributor Author

danog commented Sep 22, 2023

btw @iluuu1994 what do you think about #12263, do you think I could add the new workflow files for RISC-V tests directly in this PR?

@danog
Copy link
Contributor Author

danog commented Sep 29, 2023

Ping @iluuu1994, is this OK to merge? :)

@iluuu1994
Copy link
Member

@danog I'm on vacation, I'll check next week.

Copy link
Member

@iluuu1994 iluuu1994 left a comment

Choose a reason for hiding this comment

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

@danog The changes look good to me, thank you! However, I would prefer merging this after the JIT issues have been fixed. A failing build is annoying, but can also hide new problems.

@danog
Copy link
Contributor Author

danog commented Oct 3, 2023

Thank you @iluuu1994!
I agree that it's not a good idea to merge PRs with failing tests, even if they were not caused by that PR, but the tests in this PR are passing since I split the failing ones in another PR, why can't this be merged?

@iluuu1994
Copy link
Member

@danog From what I understand this causes the COMMUNITY build to fail at least for Psalm and amp-parallel, is that not correct?

@danog
Copy link
Contributor Author

danog commented Oct 3, 2023

@iluuu1994 Nope, amp-parallel only fails if the uv extension is installed with JIT (and I don't install it in this PR anymore), and I didn't add Psalm this this PR.

@iluuu1994
Copy link
Member

@danog For some reason I misremembered and thought we already had Psalm in CI ^^ Thanks, I will merge this then.

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.

3 participants