svector
robin-hood-hashing
svector | robin-hood-hashing | |
---|---|---|
3 | 23 | |
95 | 1,465 | |
- | - | |
0.0 | 0.0 | |
6 months ago | over 1 year ago | |
C++ | C++ | |
MIT License | MIT License |
Stars - the number of stars that a project has on GitHub. Growth - month over month growth in stars.
Activity is a relative number indicating how actively a project is being developed. Recent commits have higher weight than older ones.
For example, an activity of 9.0 indicates that a project is amongst the top 10% of the most actively developed projects that we are tracking.
svector
-
If you limit an std::string in a class to be < 15 characters, can you assume that any time the string is read it will stay on the stack due to SSO?
It would be possible to do a much more compact SSO, but I think they've done it this way for performance reason. E g. I've implemented a vector with SSO, and there i only have 1 byte overhead: https://github.com/martinus/svector
- GitHub - martinus/svector: Small Vector optimization
robin-hood-hashing
- Factor is faster than Zig
-
If this isn't the perfect data structure, why?
From your other comments, it seems like your knowledge of hash tables might be limited to closed-addressing/separate-chaining hash tables. The current frontrunners in high-performance, memory-efficient hash table design all use some form of open addressing, largely to avoid pointer chasing and limit cache misses. In this regard, you want to check our SSE-powered hash tables (such as Abseil, Boost, and Folly/F14), Robin Hood hash tables (such as Martinus and Tessil), or Skarupke (I've recently had a lot of success with a similar design that I will publish here soon and is destined to replace my own Robin Hood hash tables). Also check out existing research/benchmarks here and here. But we a little bit wary of any benchmarks you look at or perform because there are a lot of factors that influence the result (e.g. benchmarking hash tables at a maximum load factor of 0.5 will produce wildly different result to benchmarking them at a load factor of 0.95, just as benchmarking them with integer keys-value pairs will produce different results to benchmarking them with 256-byte key-value pairs). And you need to familiarize yourself with open addressing and different probing strategies (e.g. linear, quadratic) first.
-
boost::unordered standalone
Also, FYI there is robin_hood::unordered_{map,set} which has very high performance, and is header-only and standalone.
-
Solving “Two Sum” in C with a tiny hash table
std::unordered_map is notoriously slow, several times slower than a "proper" hashmap implementation like Google's absl or Martin's robin-hood-hashing [1]. That said, std::sort is not the fastest sort implementation, either. It is hard to say which will win.
[1]: https://github.com/martinus/robin-hood-hashing
-
Convenient Containers v1.0.3: Better compile speed, faster maps and sets
The main advantage of the latest version is that it reduces build time by about 53% (GCC 12.1), based on the comprehensive test suit found in unit_tests.c. This improvement is significant because compile time was previously a drawback of this library, with maps and sets—in particular—compiling slower than their C++ template-based counterparts. I achieved it by refactoring the library to do less work inside API macros and, in particular, use fewer _Generic statements, which seem to be a compile-speed bottleneck. A nice side effect of the refactor is that the library can now more easily be extended with the planned dynamic strings and ordered maps and sets. The other major improvement concerns the performance of maps and sets. Here are some interactive benchmarks[1] comparing CC’s maps to two popular implementations of Robin Hood hash maps in C++ (as well as std::unordered_map as a baseline). They show that CC maps perform roughly on par with those implementations.
-
Effortless Performance Improvements in C++: std:unordered_map
For anyone in a situation where a set/map (or unordered versions) is in a hot part of the code, I'd also highly recommend Robin Hood: https://github.com/martinus/robin-hood-hashing
It made a huge difference in one of the programs I was running.
- Inside boost::unordered_flat_map
-
What are some cool modern libraries you enjoy using?
Oh my bad. Still thought -- your name.. it looks very familiar to me. Are you the robin_hood hashing guy perhaps? Yes you are! My bad -- https://github.com/martinus/robin-hood-hashing.
-
Performance comparison: counting words in Python, C/C++, Awk, Rust, and more
Got a bit better C++ version here which uses a couple libraries instead of std:: stuff - https://gist.github.com/jcelerier/74dfd473bccec8f1bd5d78be5a... ; boost, fmt and https://github.com/martinus/robin-hood-hashing
$ g++ -I robin-hood-hashing/src/include -O2 -flto -std=c++20 -fno-exceptions -fno-unwind-tables -fno-asynchronous-unwind-tables -lfmt
-
A fast & densely stored hashmap and hashset based on robin-hood backward shift deletion
The implementation is mostly inspired by this comment and lessons learned from my older robin-hood-hashing hashmap.
What are some alternatives?
small_vector - A fully featured single header library implementing a vector container with a small buffer optimization.
parallel-hashmap - A family of header-only, very fast and memory-friendly hashmap and btree containers.
refl-cpp - Static reflection for C++17 (compile-time enumeration, attributes, proxies, overloads, template functions, metaprogramming).
STL - MSVC's implementation of the C++ Standard Library.
Magic Enum C++ - Static reflection for enums (to string, from string, iteration) for modern C++, work with any enum type without any macro or boilerplate code
robin-map - C++ implementation of a fast hash map and hash set using robin hood hashing
Nameof C++ - Nameof operator for modern C++, simply obtain the name of a variable, type, function, macro, and enum
xxHash - Extremely fast non-cryptographic hash algorithm
tomlplusplus - Header-only TOML config file parser and serializer for C++17.
{fmt} - A modern formatting library
entt - Gaming meets modern C++ - a fast and reliable entity component system (ECS) and much more
tracy - Frame profiler