-
Couldn't load subscription status.
- Fork 1.4k
Reduce metadata mutation overhead via second-byte dispatch #12479
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
Closed
dlambrig
wants to merge
2
commits into
apple:main
from
dlambrig:optimize-resolver-metadata-mutations
Closed
Reduce metadata mutation overhead via second-byte dispatch #12479
dlambrig
wants to merge
2
commits into
apple:main
from
dlambrig:optimize-resolver-metadata-mutations
Conversation
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
Result of foundationdb-pr-macos on macOS Ventura 13.x
|
d38eb7a to
abf2458
Compare
Result of foundationdb-pr on Linux RHEL 9
|
Result of foundationdb-pr-cluster-tests on Linux RHEL 9
|
Result of foundationdb-pr-clang-ide on Linux RHEL 9
|
Result of foundationdb-pr-macos on macOS Ventura 13.x
|
Result of foundationdb-pr-macos-m1 on macOS Ventura 13.x
|
Result of foundationdb-pr-cluster-tests on Linux RHEL 9
|
Result of foundationdb-pr on Linux RHEL 9
|
Result of foundationdb-pr-clang-arm on Linux CentOS 7
|
Result of foundationdb-pr-clang-ide on Linux RHEL 9
|
Result of foundationdb-pr-clang on Linux RHEL 9
|
Result of foundationdb-pr-clang-arm on Linux CentOS 7
|
Result of foundationdb-pr-clang on Linux RHEL 9
|
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.
applyMetadataMutations()is called for each transaction containing system key mutations. The original implementation calls 23+ check* functions for system key mutation, even though most mutations only match 1-2 prefixes. For a transaction with N system mutations, this creates ~22N wasted function calls and string comparisons.This PR groups check* functions based on the second byte of system keys and use a switch statement to dispatch to the appropriate subset:
'/'(0x2F): Most common -\xff/keyServers/,\xff/serverKeys/,\xff/conf/, etc. (17 functions)'\x02'(0x02): Less common -\xff\x02/feed/,\xff\x02/cacheKeys/(4 functions)'\xff'(0xFF): Private keys -\xff\xff/cf/,\xff\xff/cc/(1 function)This reduces the average function calls per mutation from 23 to 10-17 depending on key pattern.
After some tests. The second-byte dispatch adds:
And saves nothing when there's only 1 mutation since all the check* functions would return quickly anyway on mismatched prefixes.
This seems to be the common case. I do not think the optimization is worth it.
Code-Reviewer Section
The general pull request guidelines can be found here.
Please check each of the following things and check all boxes before accepting a PR.
For Release-Branches
If this PR is made against a release-branch, please also check the following:
release-branchormainif this is the youngest branch)