Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Remove cache slot from ZEND_VERIFY_RETURN_TYPE and arg RECV opcodes #18258

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

Merged
nielsdos merged 1 commit into php:master from nielsdos:tmp-cache-slot-1
Apr 7, 2025

Conversation

Copy link
Member

@nielsdos nielsdos commented Apr 5, 2025
edited
Loading

Since #7336 the CE cache is always used even if Opcache is not loaded.
This means that the cache slot is almost fully redundant, except for self/parent/static. Removing this was hinted at in #7336 (review) but was never done. This patch removes this finally.

Valgrind in CI shows a I-count reduction of 0.13% without JIT and 0.08% with JIT for Symfony. 0.06% and 0.08% reduction for Wordpress respectively without and with JIT.

Real-time benchmarks on an i7-1185G7:

Symfony Benchmark (public/index.php)

Ran with -T 10,45

JIT Version Mean Time (ms) Std Dev (ms) Min Time (ms) Max Time (ms) Speedup
Disabled Original PHP 490.7 ±1.4 488.3 493.3 ×ばつ
Disabled Patched PHP 486.4 ±1.3 484.6 488.8 ×ばつ
Tracing Original PHP 618.9 ±1.8 617.2 623.1 ×ばつ
Tracing Patched PHP 614.7 ±3.4 610.6 622.1 ×ばつ

WordPress Benchmark (index.php)

Ran with -T 5,20

JIT Version Mean Time (ms) Std Dev (ms) Min Time (ms) Max Time (ms) Speedup
Disabled Original PHP 637.8 ±2.7 633.0 641.8 ×ばつ
Disabled Patched PHP 633.1 ±3.0 630.3 639.5 ×ばつ
Tracing Original PHP 763.3 ±4.0 757.8 770.8 ×ばつ
Tracing Patched PHP 758.2 ±3.7 754.4 766.2 ×ばつ

So I see very slight improvements and no regressions.
Note that tracing run has a higher baseline due to initial JIT overhead, but increasing the number of runs made the machine throttle which ruined the stability of the benchmark.

iluuu1994 and arnaud-lb reacted with thumbs up emoji ddevsr reacted with heart emoji
@nielsdos nielsdos changed the title (削除) Remove cache slot from ZEND_VERIFY_TYPE and arg RECV opcodes (削除ここまで) (追記) Remove cache slot from ZEND_VERIFY_RETURN_TYPE and arg RECV opcodes (追記ここまで) Apr 6, 2025
Copy link
Member

This is essentially redundant since adding the interned string CE cache, right?

Copy link
Member Author

nielsdos commented Apr 6, 2025

This is essentially redundant since adding the interned string CE cache, right?

Indeed. I'm currently benching and will update the OP when I have results.

Copy link
Member

iluuu1994 commented Apr 6, 2025
edited
Loading

Nice simplification. We've briefly mentioned the possibility of adding a class cache for RECV and VERIFY_RETURN_TYPES in another issue. This would require a single slot, where the CE of the last value successfully type checked would be stored. This is mostly useful for union and intersection types, improving consecutive calls with the same class type. If there are concerns of slowing down non-union/intersection type checks, we could create a custom specialized handler that is only used when a cache slot is actually allocated. This might be worth exploring as well.

arnaud-lb reacted with thumbs up emoji

Copy link
Member Author

nielsdos commented Apr 6, 2025

Nice simplification. We've briefly mentioned the possibility of adding a class cache for RECV and VERIFY_RETURN_TYPES in another issue. This would require a single slot, where the CE of the last value successfully type checked would be stored. This is mostly useful for union and intersection types, improving consecutive calls with the same class type. If there are concerns of slowing down non-union/intersection type checks, we could create a custom specialized handler that is only used when a cache slot is actually allocated. This might be worth exploring as well.

That should be done separately from this PR.
Where can I find the discussion? Is it a situation that really occurs a lot in practice?

@nielsdos nielsdos marked this pull request as ready for review April 6, 2025 11:53
Copy link
Member

#18189 (comment) mentions it. It would likely be a small optimization.

Copy link
Member Author

nielsdos commented Apr 6, 2025
edited
Loading

#18189 (comment) mentions it. It would likely be a small optimization.

Oh right, I can take a look at that after this goes through. (The implementation and handling of cache slots would be different to this anyway)

arnaud-lb reacted with thumbs up emoji

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.

I can't do a deep review now, but since this removes more than adds, I support this.

Copy link
Member

@arnaud-lb arnaud-lb left a comment

Choose a reason for hiding this comment

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

Nice!

This looks good to me.

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.

LGTM as well

@nielsdos nielsdos force-pushed the tmp-cache-slot-1 branch 2 times, most recently from 9a691fe to be0132e Compare April 7, 2025 17:04
@nielsdos nielsdos merged commit a32f491 into php:master Apr 7, 2025
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Reviewers

@arnaud-lb arnaud-lb arnaud-lb approved these changes

@iluuu1994 iluuu1994 iluuu1994 approved these changes

@dstogov dstogov dstogov approved these changes

Assignees
No one assigned
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

AltStyle によって変換されたページ (->オリジナル) /