4 comments

  • nly1 hour ago
    My goto these days (and afaik the state of the art) is boost::unordered_flat_set paired with rapidhash for hashing (since the GNU std::hash functions based on murmurhash are ridiculously slow)<p>The cacheline performance is pretty hard to beat (SIMD optimised linear scan before hopping), which is where all the wins come in the real world.<p>But basically any of the faster hash maps from absl, boost or folly are going to wreck the standard library in terms of perf
  • jll296 hours ago
    google::dense_hash_map is faster than this new implementation according to their benchmark&#x27;s diagram (google::dense_hash_map has the lowest runtime of all tested methods).
  • mgaunard9 hours ago
    How does it compare to boost unordered flat map?<p>Looks like the benchmarks were last updated in 2019.
    • compiler-guy8 hours ago
      <a href="https:&#x2F;&#x2F;tessil.github.io&#x2F;2016&#x2F;08&#x2F;29&#x2F;benchmark-hopscotch-map.html" rel="nofollow">https:&#x2F;&#x2F;tessil.github.io&#x2F;2016&#x2F;08&#x2F;29&#x2F;benchmark-hopscotch-map....</a><p>Has some older benchmarks, including those two.
      • mgaunard5 hours ago
        boost unordered <i>flat</i> map didn&#x27;t exist in 2016 (nor 2019).
      • jeffbee8 hours ago
        A more recent benchmark is <a href="https:&#x2F;&#x2F;martin.ankerl.com&#x2F;2022&#x2F;08&#x2F;27&#x2F;hashmap-bench-01&#x2F;" rel="nofollow">https:&#x2F;&#x2F;martin.ankerl.com&#x2F;2022&#x2F;08&#x2F;27&#x2F;hashmap-bench-01&#x2F;</a><p>However, it lacks the newer Boost stuff which is very fast.<p>The Hopscotch map was interesting at the time but due to unfortunate timing was immediately outshone by absl::unordered_flat_map A.K.A. &quot;Swiss tables&quot;, and there&#x27;s been even more water under the bridge since then.
        • RossBencina7 hours ago
          Abseil Swiss Tables carefully avoids intermediate allocations&#x2F;copy constructor calls.[1] I&#x27;d be wary about inferring underlying <i>algorithm</i> performance from benchmarks that don&#x27;t explicitly control for these optimisations. (Or maybe everyone is using them and I&#x27;m out of touch.)<p>[1] <a href="https:&#x2F;&#x2F;abseil.io&#x2F;about&#x2F;design&#x2F;swisstables" rel="nofollow">https:&#x2F;&#x2F;abseil.io&#x2F;about&#x2F;design&#x2F;swisstables</a>
          • jeffbee6 hours ago
            Algorithmically hopscotch has a better strict worst case whereas swiss tables have a degenerate O(N) lookup. But there are a lot of maps like that. robin_hood::flat_hash_map is very fast but I can create insert sequences under which it will call std::abort, which I feel is ridiculous. But if your hash map isn&#x27;t exposed to hostile inputs then you might not be concerned.
        • utopcell2 hours ago
          You probably mean absl::flat_hash_map&lt;&gt;.
        • quadrature8 hours ago
          Is there something better than Swiss tables ?.
          • reinitctxoffset7 hours ago
            On modern super wide znver5 or SBSA with full-clock scalar 256 or 512 ALUs &#x2F; SIMD lanes deep pipelines hight BTB pressure eyc. it&#x27;s just really difficult to make a priori statements about performance for a given workload.<p>absl::flat_hash_map (or folly::F14) are great defaults if you can eat the invalidation semantics.<p>But if it&#x27;s really hot you measure by workload and have infrastructure to flag the right ones in.<p>This seems promising. I&#x27;ll start benching it alongside the other likely lads.
          • szmarczak7 hours ago
            No. Fundamentally it&#x27;s not possible to be faster.
            • infamouscow7 hours ago
              This is not true. It is fast as a general purpose hash table, but claiming it&#x27;s the fastest across all datasets and workloads is silly.
  • teo_zero3 hours ago
    The concept is very similar to robin hood. In fact most of the performance charts show that the curves of hopscotch and robin hood are very close. I think I&#x27;d prefer robin hood as it&#x27;s well known.