pp_hot.c: shave off some CPU instructions in pp_const()#23215
Merged
mauke merged 1 commit intoPerl:bleadfrom Oct 18, 2025
Merged
pp_hot.c: shave off some CPU instructions in pp_const()#23215mauke merged 1 commit intoPerl:bleadfrom
mauke merged 1 commit intoPerl:bleadfrom
Conversation
CC is MSVC 2022 x64 -O1. Before, 0x67 bytes long. After, 0x5E bytes long. This savings obtained by not digging inside PL_op AKA my_perl->Iop->op_*** twice, and the CC not having save a C auto var around a function call. I profiled Perl_pp_const() to be between Perl#2 to Perl#4 most executed pp_*() function, per process on any workload. For extra details about this commit see the GH PR associated with this commit. There is an alternative I privately prototyped but I decided not to finish 3/4s of the way which is creating pre/post arg eval variants of function/macro rpp_xpush_1(). It was getting too invasive and complex by lines of src code modified to finish, so that conceptual fix isn't done here, and something best left for the future.
tonycoz
approved these changes
Apr 23, 2025
Contributor
tonycoz
left a comment
There was a problem hiding this comment.
This makes a noticeable improvement on Linux/gcc builds too.
Contributor
5.42.0 has been released; development on this p.r. may resume. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
FROM COMMIT
CC is MSVC 2022 x64 -O1. Before, 0x67 bytes long. After, 0x5E bytes long. This savings obtained by not digging inside PL_op AKA my_perl->Iop->op_*** twice, and the CC not having save a C auto var around a function call. I profiled Perl_pp_const() to be between #2 to #4 most executed pp_*() function, per process on any workload. For extra details about this commit see the GH PR associated with this commit.
There is an alternative I privately prototyped but I decided not to finish 3/4s of the way which is creating pre/post arg eval variants of function/macro rpp_xpush_1(). It was getting too invasive and complex by lines of src code modified to finish, so that conceptual fix isn't done here, and something best left for the future.
EXTRA INFO
Perl_pp_const()
before, 0x67 bytes long.
after, 0x5E bytes long.