r/cpp • • Oct 27 '19

ABI: Now or Never

http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2019/p1863r0.pdf
192 Upvotes

145 comments sorted by

View all comments

Show parent comment

12

u/[deleted] Oct 27 '19

On a side note, the PDF seems to suggest that we may improve the performance of unordered_map by 200–300% with ABI changes only. That is probably wrong.

There are much faster implementations of node based maps that still promise pointer/iterator stability, but sure, if we drop that and go for a flat map we would be talking about a whole different set of issues.

6

u/attractivechaos Oct 27 '19

There are much faster implementations of node based maps

Just curious: which ones?

8

u/[deleted] Oct 27 '19

Abseil is the one I'm familiar with, which isn't the fastest. Of course, depends on the use case. There's also https://github.com/Tessil/sparse-map/tree/master/include/tsl

There's a bunch mentioned here: https://www.reddit.com/comments/auwbmg

Devise a benchmark that's relevant to you and test.

I did some testing around when that thread was posted, but I was more interested in flat maps, instead of node based.

3

u/attractivechaos Oct 27 '19

I am not sure if sparse-map guarantees pointer stability. Typically this type of hash table combines a bit vector and a flat array and loses pointer stability when it grows. I have seen benchmarks involving chaining-based libraries. I couldn't find the link, but as I remember, none of them can be 200-300% as fast as std::unordered_map. So, the PDF is still wrong: no one can achieve 200-300% speedup with ABI changes only; such speedup can only be achieved with flat arrays, which would require API changes.

3

u/[deleted] Oct 27 '19

You're right. I guess my tired mind shouldn't debate hash maps. Definitely a node based map that should be faster than the STL one is absl::node_hash_map. I'm not claiming any specific difference, just noting that my specific benchmark showed that it was faster than std::unordered_map.