Perl_hv_common - don't call share_hek_flags when (keysv_hek != NULL)#24149
Open
richardleach wants to merge 1 commit intoPerl:bleadfrom
Open
Perl_hv_common - don't call share_hek_flags when (keysv_hek != NULL)#24149richardleach wants to merge 1 commit intoPerl:bleadfrom
richardleach wants to merge 1 commit intoPerl:bleadfrom
Conversation
9639875 to
bcafa29
Compare
Contributor
Author
|
A rough comparison: blead: patched: Worth doing, but I'm not sure it warrants a perldelta entry. |
Contributor
|
Need to get |
Contributor
|
I believe the porting tests are only failing because there are some tags missing from this fork. The tests would probably succeed in the main repository. |
When creating a new `HE` for insertion into a hash that supports shared
keys, `Perl_hv_common` always achieves this via `S_share_hek_flags`.
`S_share_hek_flags` searches the shared string table - `PL_strtab` -
for a matching entry and inserts one if needs be, returning the
relevant `HEK*`.
However, if `Perl_hv_common`'s `keysv` is a "HEK in disguise" to begin
with, `keysv_hek` _already_ contains the resulting `HEK*` - and we
are able to bump the refcount on it. So this commit checks for that
case and branches accordingly.
gcov counts from a perl build and test_harness run suggest that having
a valid `keysv_hek` is already very common.
```
129097943: 996: if (LIKELY(HvSHAREKEYS(hv))) {
129097941: 997: entry = new_HE();
129097941: 998: if (keysv_hek) {
50255991: 999: HeKEY_hek(entry) = keysv_hek;
50255991: 1000: share_hek_hek(keysv_hek);
-: 1001: } else {
78841950: 1002: HeKEY_hek(entry) = share_hek_flags(key, klen, hash, flags);
-: 1003: }
-: 1004: }
```
If greater use is made of `PL_strtab` in the future, such as for
OP_CONST SVs, the `keysv_hek` is likely to become correspondingly
hotter.
bcafa29 to
ef3a6e7
Compare
Contributor
Author
|
I've rebased and pushed. |
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.
When creating a new
HEfor insertion into a hash that supports shared keys,Perl_hv_commonalways achieves this viaS_share_hek_flags.S_share_hek_flagssearches the shared string table -PL_strtab- for a matching entry and inserts one if needs be, returning the relevantHEK*.However, if
Perl_hv_common'skeysvis a "HEK in disguise" to begin with,keysv_hekalready contains the resultingHEK*- and we are able to bump the refcount on it. So this commit checks for that case and branches accordingly.gcov counts from a perl build and test_harness run suggest that having a valid
keysv_hekis already very common.If greater use is made of
PL_strtabin the future, such as for OP_CONST SVs, thekeysv_hekis likely to become correspondingly hotter.(If someone points out a compelling reason why this isn't already done, I'll add comments to that effect instead.)