-
Notifications
You must be signed in to change notification settings - Fork 15.2k
[SpecialCaseList] Flip RadixTree key order #164544
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
Draft
vitalybuka
wants to merge
9
commits into
users/vitalybuka/spr/main.specialcaselist-flip-radixtree-key-order
Choose a base branch
from
users/vitalybuka/spr/specialcaselist-flip-radixtree-key-order
base: users/vitalybuka/spr/main.specialcaselist-flip-radixtree-key-order
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
[SpecialCaseList] Flip RadixTree key order #164544
vitalybuka
wants to merge
9
commits into
users/vitalybuka/spr/main.specialcaselist-flip-radixtree-key-order
from
users/vitalybuka/spr/specialcaselist-flip-radixtree-key-order
+9
−8
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
Created using spr 1.3.7
Member
|
@llvm/pr-subscribers-llvm-support Author: Vitaly Buka (vitalybuka) ChangesThe RadixTree key order was Prefix then Suffix. This commit changes the Full diff: https://github.com/llvm/llvm-project/pull/164544.diff 2 Files Affected:
diff --git a/llvm/include/llvm/Support/SpecialCaseList.h b/llvm/include/llvm/Support/SpecialCaseList.h
index 471f8e779fa24..c077f8857c9c8 100644
--- a/llvm/include/llvm/Support/SpecialCaseList.h
+++ b/llvm/include/llvm/Support/SpecialCaseList.h
@@ -166,10 +166,10 @@ class SpecialCaseList {
std::vector<GlobMatcher::Glob> Globs;
- RadixTree<iterator_range<StringRef::const_iterator>,
- RadixTree<iterator_range<StringRef::const_reverse_iterator>,
+ RadixTree<iterator_range<StringRef::const_reverse_iterator>,
+ RadixTree<iterator_range<StringRef::const_iterator>,
SmallVector<const GlobMatcher::Glob *, 1>>>
- PrefixSuffixToGlob;
+ SuffixPrefixToGlob;
};
/// Represents a set of patterns and their line numbers
diff --git a/llvm/lib/Support/SpecialCaseList.cpp b/llvm/lib/Support/SpecialCaseList.cpp
index 9bd1c199695d1..15367afd91e72 100644
--- a/llvm/lib/Support/SpecialCaseList.cpp
+++ b/llvm/lib/Support/SpecialCaseList.cpp
@@ -94,8 +94,8 @@ void SpecialCaseList::GlobMatcher::preprocess(bool BySize) {
StringRef Prefix = G.Pattern.prefix();
StringRef Suffix = G.Pattern.suffix();
- auto &SToGlob = PrefixSuffixToGlob.emplace(Prefix).first->second;
- auto &V = SToGlob.emplace(reverse(Suffix)).first->second;
+ auto &PToGlob = SuffixPrefixToGlob.emplace(reverse(Suffix)).first->second;
+ auto &V = PToGlob.emplace(Prefix).first->second;
V.emplace_back(&G);
}
}
@@ -103,9 +103,10 @@ void SpecialCaseList::GlobMatcher::preprocess(bool BySize) {
void SpecialCaseList::GlobMatcher::match(
StringRef Query,
llvm::function_ref<void(StringRef Rule, unsigned LineNo)> Cb) const {
- if (!PrefixSuffixToGlob.empty()) {
- for (const auto &[_, SToGlob] : PrefixSuffixToGlob.find_prefixes(Query)) {
- for (const auto &[_, V] : SToGlob.find_prefixes(reverse(Query))) {
+ if (!SuffixPrefixToGlob.empty()) {
+ for (const auto &[_, PToGlob] :
+ SuffixPrefixToGlob.find_prefixes(reverse(Query))) {
+ for (const auto &[_, V] : PToGlob.find_prefixes(Query)) {
for (const auto *G : reverse(V)) {
if (G->Pattern.match(Query)) {
Cb(G->Name, G->LineNo);
|
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.
The RadixTree key order was Prefix then Suffix. This commit changes the
order to Suffix then Prefix. Assuming that, especially in case of
"src:", suffixes are often more diverse than prefixes. So filtering by
suffix first should be more efficient.
No noticeable improvement on benchmarks:
https://gist.github.com/vitalybuka/d6d394071a4d540a50a119f317bd4e5a