-
-
Notifications
You must be signed in to change notification settings - Fork 660
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
perf: change zone positions to phmap::flat_hash_set #3210
Merged
Merged
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
Maybe fixes #2568 |
This pr is only for better performance. The cause from issue is probably caused by reload or bad config. |
beats-dh
approved these changes
Jan 4, 2025
majestyotbr
approved these changes
Jan 4, 2025
Quality Gate passedIssues Measures |
vllworldbuilding
pushed a commit
to vllworldbuilding/canary
that referenced
this pull request
Jan 10, 2025
This replaces `std::unordered_set` with `phmap::flat_hash_set` in the `Zone` class to improve performance by reducing hash collisions and optimizing memory usage. Motivation: The use of `std::unordered_set` for the `positions` attribute caused performance issues due to hash collisions, especially when managing large datasets or heavily clustered data. Collisions result in increased lookup, insertion, and deletion times as the hash table degrades into a linked list traversal for conflicting buckets. Switching to `phmap::flat_hash_set` provides several benefits: 1. Reduced hash collisions: The hashing strategy used by `phmap::flat_hash_set` significantly reduces the likelihood of collisions, improving lookup and insertion performance. 2. Improved memory locality: Unlike `std::unordered_set`, which uses separate allocations for each bucket, `flat_hash_set` uses a contiguous memory layout, enhancing cache efficiency and reducing overhead. 3. Faster operations: Benchmarks show that `flat_hash_set` outperforms `std::unordered_set` in scenarios with frequent insertions, lookups, and deletions due to its optimized design.
lucas-caminha
pushed a commit
to lucas-caminha/canary
that referenced
this pull request
Jan 19, 2025
This replaces `std::unordered_set` with `phmap::flat_hash_set` in the `Zone` class to improve performance by reducing hash collisions and optimizing memory usage. Motivation: The use of `std::unordered_set` for the `positions` attribute caused performance issues due to hash collisions, especially when managing large datasets or heavily clustered data. Collisions result in increased lookup, insertion, and deletion times as the hash table degrades into a linked list traversal for conflicting buckets. Switching to `phmap::flat_hash_set` provides several benefits: 1. Reduced hash collisions: The hashing strategy used by `phmap::flat_hash_set` significantly reduces the likelihood of collisions, improving lookup and insertion performance. 2. Improved memory locality: Unlike `std::unordered_set`, which uses separate allocations for each bucket, `flat_hash_set` uses a contiguous memory layout, enhancing cache efficiency and reducing overhead. 3. Faster operations: Benchmarks show that `flat_hash_set` outperforms `std::unordered_set` in scenarios with frequent insertions, lookups, and deletions due to its optimized design.
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.
Description
This PR replaces
std::unordered_set
withphmap::flat_hash_set
in theZone
class to improve performance by reducing hash collisions and optimizing memory usage.Motivation
The use of
std::unordered_set
for thepositions
attribute caused performance issues due to hash collisions, especially when managing large datasets or heavily clustered data. Collisions result in increased lookup, insertion, and deletion times as the hash table degrades into a linked list traversal for conflicting buckets.Switching to
phmap::flat_hash_set
provides several benefits:phmap::flat_hash_set
significantly reduces the likelihood of collisions, improving lookup and insertion performance.std::unordered_set
, which uses separate allocations for each bucket,flat_hash_set
uses a contiguous memory layout, enhancing cache efficiency and reducing overhead.flat_hash_set
outperformsstd::unordered_set
in scenarios with frequent insertions, lookups, and deletions due to its optimized design.Behaviour
Actual
std::unordered_set
degrade performance, especially for large datasets or when hash functions produce similar values for certain inputs.Expected
phmap::flat_hash_set
improves performance by reducing collisions, enhancing memory locality, and speeding up operations.Type of change
How Has This Been Tested
Tests performed:
Checklist