-
Notifications
You must be signed in to change notification settings - Fork 57
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
[Feature request] boost::unordered_flat_map variant with key and value stored separately #209
Comments
Hmm, do you have any concrete use-cases or data for this? We'd like to consider the idea but before dedicating the resources, we'd like to get a gauge on the effectiveness of including such a map. |
@holenno1 This design needs at least three arrays. Even it can save some memory in use-cases, but it's performance is not as good as you think so in most cases. |
Hi, sorry was busy all week. I've collected some data, A bit of context: We have an in-house open-addressing hash map implementation that is heavily based on LLVM's
In addition, we have another hash map variant that stores the keys and values in separate buffers - "split storage". Here's a memory usage experiment:
A real world usage scenario for this setup is object-to-id mapping - we have a large number of heap allocated objects, and we want to assign an ID to each of them. In fact, 100,000 entries is a little on the low side. Here are the results:
*Those numbers were measured by querying The "split storage" variant sees a 25% reduction in memory usage compared to the "pair storage" variant. Let's look at runtime. Yes @ktprime you are right, the "split storage" variant will have a performance disadvantage for insertion and erasure workloads. However, "split storage" does have a slight edge when it comes to unsuccessful lookups, as we don't have to visit the value buffer.
|
Couldn't you just create a custom key type (say with |
We can certainly do that, but I think the spirit of the feature request is so we don't have to actually do that :). |
Hello!
It would be great if we could have another variant of
boost::unordered_flat_map
where the keys and values are stored in separate arrays - "split" storage.The main motivation for this is to minimise memory wastage due to padding.
eg: key=
uint64_t
, value=float
would mean 4 bytes of padding per key-value pair.Obviously this will be a further divergence from
std::unordered_map
's interface.The main difference being that iterators will return
std::pair<const Key&, Value&>
instead ofstd::pair<const Key, Value>&
.However, we believe this will provide a tonne of value to fans of
boost::unordered_flat_map
.Thanks!
The text was updated successfully, but these errors were encountered: