-
Notifications
You must be signed in to change notification settings - Fork 573
[MOD-9694] Trie prefixes iterator #6119
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
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
26bce67
Prefixes iterator
LukeMathWalker 3ad277d
Align with C: do not track keys in the prefixes iterator
LukeMathWalker ebba978
Compile arr.h as a standalone static library
LukeMathWalker c37c2fb
Fix memory issue in bench
LukeMathWalker a65b7da
Add license header
LukeMathWalker cbc264c
Re-add tests for values iterator
LukeMathWalker cbcccba
Add another prefix benchmark using the full Gutenberg dataset.
LukeMathWalker File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| /* | ||
| * Copyright (c) 2006-Present, Redis Ltd. | ||
| * All rights reserved. | ||
| * | ||
| * Licensed under your choice of the Redis Source Available License 2.0 | ||
| * (RSALv2); or (b) the Server Side Public License v1 (SSPLv1); or (c) the | ||
| * GNU Affero General Public License v3 (AGPLv3). | ||
| */ | ||
|
|
||
| //! Benchmark the iterators exposed by a trie map. | ||
|
|
||
| use criterion::{Criterion, criterion_group, criterion_main}; | ||
| use trie_bencher::OperationBencher; | ||
|
|
||
| use trie_bencher::corpus::CorpusType; | ||
|
|
||
| fn iter_benches_wiki1k(c: &mut Criterion) { | ||
| let corpus = CorpusType::RedisBench1kWiki; | ||
| let terms = corpus.create_terms(true); | ||
|
|
||
| let bencher = OperationBencher::new("Wiki-1K".to_owned(), terms, None); | ||
| // Matches "A" and "Abacus" | ||
| bencher.find_prefixes_group(c, "Abacuses", "Find prefixes"); | ||
| } | ||
|
|
||
| fn iter_benches_gutenberg(c: &mut Criterion) { | ||
| let corpus = CorpusType::GutenbergEbook(true); | ||
| let terms = corpus.create_terms(true); | ||
|
|
||
| let bencher = OperationBencher::new("Gutenberg".to_owned(), terms, None); | ||
| // Matches "ever", "everlasting" and "everlastingly". | ||
| bencher.find_prefixes_group(c, "everlastingly", "Find prefixes"); | ||
| } | ||
|
|
||
| criterion_group!(wiki_1k_iter, iter_benches_wiki1k); | ||
| criterion_group!(gutenberg_iter, iter_benches_gutenberg); | ||
| criterion_main!(wiki_1k_iter, gutenberg_iter); |
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
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
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
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
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
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
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a comment: Not sure what is the strategy to do the benchmarking. I wonder if we should be using more than one key as a query to the
operationsto benchmark.Ignore my comment if this has been the case for other operations.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We generally try to exercise all the different "modes" of the operation.
If you look at the
operations.rsfile, you can see how we classify inputs based on what part of the algorithm they "hit".For prefixes, we could add inputs that exit earlier as an additional data point.
Alternatively, we can add a dedicated corpus with a higher opportunity for matches, but it may be overkill.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've added another bench in 58a4161 using the full Gutenberg dataset, which is ~10x the size.
We can see that the timing scales (roughly) with the depth of the traversal, which is what we expect.