Skip to content
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

Make trie structure less memory-hogging #33668

Merged
merged 29 commits into from
Jun 12, 2024
Merged
Changes from 1 commit
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
ddb0b72
Make trie structure less memory-hogging
ravenblackx Apr 18, 2024
5a9d39c
Spelling
ravenblackx Apr 19, 2024
ca28226
Embarrassing off-by-one error, and remove unnecessary c_str
ravenblackx Apr 19, 2024
d227b72
Initialize min_child_ to satisfy msan, reorder branch to hint likely …
ravenblackx Apr 19, 2024
151142c
Trie can support non-pointer value types.
ravenblackx Apr 25, 2024
02a6c2c
Benchmarks
ravenblackx Apr 25, 2024
4d41919
Spelling and expand range
ravenblackx Apr 26, 2024
70fddd3
Merge branch 'main' into trie_space
ravenblackx Apr 29, 2024
e3a9d5e
Split TrieEntry implementation into Fast/Small
ravenblackx Apr 29, 2024
f03ea15
Fix warning - Value passed to --benchmark_min_time should have a suff…
ravenblackx Apr 29, 2024
1fa7ee9
Rename to Big, add benchmarks specifically for static headers
ravenblackx Apr 30, 2024
e5e1d36
Make speed test capable of testing any lookups
ravenblackx Apr 30, 2024
54b417a
Spelling
ravenblackx May 2, 2024
f02e4ed
const
ravenblackx May 6, 2024
8a07a4c
not const
ravenblackx May 6, 2024
638e8d6
Const and non-const versions (though only the non-const is ever used)
ravenblackx May 7, 2024
b8e653c
Merge branch 'main' into trie_space
ravenblackx May 23, 2024
1c47849
Unify the implementation
ravenblackx May 23, 2024
7281ca8
Comment nit
ravenblackx May 30, 2024
bc5439e
Empty to trigger CI
ravenblackx May 31, 2024
f7ce79d
Explicit parens
ravenblackx Jun 3, 2024
a0fc01e
==nullptr rather than !
ravenblackx Jun 3, 2024
bb0a24e
Add comment about type of Value
ravenblackx Jun 3, 2024
03e5101
The nittiest spelling correction ever
ravenblackx Jun 4, 2024
29b69d0
Empty commit because Amazon sucks at agents
ravenblackx Jun 6, 2024
f681a4d
Improve names, private TrieNode, improve comments
ravenblackx Jun 10, 2024
f296e98
Clarify description of findLongestPrefix too
ravenblackx Jun 10, 2024
7f965cd
Child character c instead of child key
ravenblackx Jun 10, 2024
3939544
c => child_index
ravenblackx Jun 11, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions source/common/common/utility.h
Original file line number Diff line number Diff line change
Expand Up @@ -655,7 +655,8 @@ class WelfordStandardDeviation {
// performance is not critical, or where the contents may be large.
template <class Value> class BigTrieEntry {
public:
BigTrieEntry* operator[](uint8_t i) const { return entries_[i].get(); }
const BigTrieEntry* operator[](uint8_t i) const { return entries_[i].get(); }
BigTrieEntry* operator[](uint8_t i) { return entries_[i].get(); }
void set(uint8_t branch, std::unique_ptr<BigTrieEntry<Value>> entry) {
entries_[branch] = std::move(entry);
}
Expand Down Expand Up @@ -687,12 +688,15 @@ template <class Value> class BigTrieEntry {
template <class Value> class SmallTrieEntry {
public:
Value value_{};
SmallTrieEntry* operator[](uint8_t i) const {
const SmallTrieEntry* operator[](uint8_t i) const {
Copy link
Contributor

Choose a reason for hiding this comment

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

If this is never used, what happens if you comment it out?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh yeah, of course it's used because the find() is const, I'm totally wrong.

if (i >= min_child_ && i < min_child_ + children_.size()) {
ravenblackx marked this conversation as resolved.
Show resolved Hide resolved
return children_[i - min_child_].get();
}
return nullptr;
}
SmallTrieEntry* operator[](uint8_t i) {
return const_cast<SmallTrieEntry*>(std::as_const(*this)[i]);
}

void set(uint8_t branch, std::unique_ptr<SmallTrieEntry<Value>> entry) {
if (children_.empty()) {
Expand Down
Loading