-
Notifications
You must be signed in to change notification settings - Fork 957
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
DenseSet::Grow optimization #3894
Open
BorysTheDev
wants to merge
5
commits into
main
Choose a base branch
from
DenseSet_Grow_optimization
base: main
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.
Open
Conversation
This file contains 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
BorysTheDev
force-pushed
the
DenseSet_Grow_optimization
branch
4 times, most recently
from
October 14, 2024 16:43
6a3f8e8
to
990fc48
Compare
BorysTheDev
changed the title
DenseSet::Grow optimization (not ready for review)
DenseSet::Grow optimization
Oct 14, 2024
BorysTheDev
force-pushed
the
DenseSet_Grow_optimization
branch
from
October 15, 2024 09:20
ecfd002
to
c74bc66
Compare
TLDR: on my machine, the original code:
This PR:
In more detail:
void BM_Grow(benchmark::State& state) {
vector<string> strs;
mt19937 generator(0);
StringSet src;
unsigned elems = 1 << 18;
for (size_t i = 0; i < elems; ++i) {
src.Add(random_string(generator, 16), UINT32_MAX);
strs.push_back(random_string(generator, 16));
}
while (state.KeepRunning()) {
state.PauseTiming();
StringSet tmp;
src.Fill(&tmp);
CHECK_EQ(tmp.BucketCount(), elems);
state.ResumeTiming();
for (const auto& str : strs) {
tmp.Add(str);
if (tmp.BucketCount() > elems) {
break; // we grew
}
}
CHECK_GT(tmp.BucketCount(), elems);
}
}
BENCHMARK(BM_Grow);
|
And I still think that cached links is unnecessary over complication. |
We already use FreeLink and NewLink, we can create a small class that incapsulate this logic and cached links. it's very smooth and really good for performance even for ADD/REM operations |
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.
fixes: #3870
Before BM_Grow 721975 ns 721914 ns 1020
Now BM_Grow 598066 ns 597285 ns 1237