-
-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
Inline SKIPIF evaluation without side-effects #5974
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #5974 +/- ##
============================================
- Coverage 94.67% 94.63% -0.05%
- Complexity 6406 6413 +7
============================================
Files 694 694
Lines 19189 19212 +23
============================================
+ Hits 18167 18181 +14
- Misses 1022 1031 +9 ☔ View full report in Codecov by Sentry. |
57034fa
to
6f6390e
Compare
1e344b0
to
2f10d5e
Compare
ebf68db
to
4f3636a
Compare
To unlock PHPUnit side-effect-free in-process --SKIPIF-- evaluation, we use regular echo instead of die(). That way PHPunit can detect whether conditions may be evaluated in the main-process to reduce sub-process creation overhead. see sebastianbergmann/phpunit#5974
Tested this PR on a real world project with antecedent/patchwork#168 (and described the results in the PR) |
To unlock PHPUnit side-effect-free in-process --SKIPIF-- evaluation, we use regular echo instead of die(). That way PHPunit can detect whether conditions may be evaluated in the main-process to reduce sub-process creation overhead. see sebastianbergmann/phpunit#5974
} | ||
|
||
foreach ($sideEffects as $sideEffect) { | ||
if ($sideEffect === SideEffect::STANDARD_OUTPUT) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could even report a SkipIf condition to be broken, when it does not contain a standard-out side-effect
todo
|
retargeted in #5998 |
Proof of concept
while looking into PHPT performance, I realized that the
--SKIPIF--
condition is evaluated in a separate subprocess.this means a major overhead for a maybe pretty simple side-effect-less condition like:
I built a small class in which you can pass a string of source-code and it returns whether the given code would have side-effects when evaluated.
In PHPUnit I utilize the detected side-effect-free SKIPIF conditions and evaluate such code in the main-process instead of creating a new one. In case we cannot say with 100% certainty the code does not have side-effects we play save and run it in the subprocess.
when running
php ./phpunit tests/end-to-end/event/assert-failure.phpt
I can see the following results:macos:
after this PR:
00:00.070 - 00:00.077
before this PR:
00:00.092 - 00:00.098
-> which means ~20% faster on my mac m1pro on a single test-case.
on windows with
after this PR:
00:00.360 - 00:00.395
before this PR:
00:00.406 - 00:00.443
-> seems also roughly ~20% faster
(see how slow running the same test is on windows vs. macos)
Possible future idea
—CLEAN—
as long as the code cannot modify the parent process (e.g. file IO is fine within the parent process)I am pretty sure this needs more work but wanted to have opinions first, whether this is acceptable.
refs #5973