Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
perf: change zone positions to phmap::flat_hash_set (opentibiabr#3210)
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.
- Loading branch information