#35195 coins: cache UTXO outpoint hash codes

full analysis

https://github.com/bitcoin/bitcoin/pull/35195 · l0rinc · +21/-7 in 2 files, 2 commits · labels: UTXO Db and Indexes, Needs rebase · draft

Goal

  • Speed up UTXO cache lookups during Initial Block Download and AssumeUTXO loading
  • Trade a small amount of memory to avoid recomputing hashes on table operations

Reverts the noexcept qualification on SaltedOutpointHasher by marking it noexcept(false), which prompts libstdc++ std::unordered_map implementations to cache hash codes in container nodes. This targets CCoinsMap lookups to avoid recomputing SipHash on table operations at the expense of an extra size_t per node in memory.

Problem: Since #16957 made SaltedOutpointHasher noexcept to save node memory, libstdc++ avoids caching hash codes, causing repeated hash recomputation during UTXO cache lookups and rehashing during IBD and AssumeUTXO sync.

Category: Utilities (logging, arguments, libraries) (#39 of 66)

P3 · speedup

  • P3 because benchmarks show clear speed improvements in utility hash map containers
  • Trades a modest increase in node memory to avoid repeated hashing

Modifies the exception specification of SaltedOutpointHasher to steer libstdc++ container node caching policies. The performance improvement is clear in benchmarks, though it trades away a modest amount of memory in utility containers.

Membership: Changes SaltedOutpointHasher in src/util/hasher.h and adds a unit test in src/test/hash_tests.cpp.

Factors: security/stability 0, bug 0, performance 2, user value 1, leverage 0

Category: Validation (#20 of 48)

P3 · speedup

  • P3 because it speeds up Initial Block Download and AssumeUTXO sync times
  • Yields modest validation performance gains by optimizing UTXO cache lookups

Directly impacts validation runtime by speeding up CCoinsMap operations, yielding ~2-3% faster IBD and up to ~11% faster AssumeUTXO loading. It is reasonably deferrable as an optimization reversing the trade-off made in #16957.

Membership: Changes the hash caching behavior of CCoinsMap, the core validation UTXO cache, impacting IBD and AssumeUTXO performance.

Factors: security/stability 0, bug 0, performance 2, user value 1, leverage 0

Reviewability: Stale: Needs rebase

  • Review is blocked by merge conflicts and author inactivity

The PR has merge conflicts (mergeable_state dirty) and the author has been silent for over 130 days without addressing the rebase or review comments.

Author status: silent since 2026-05-02

Open concerns:

  • optout21 asked whether hash caching could be controlled via __is_fast_hash rather than manipulating noexcept specifications.

Agreement: Strong

  • Concept approval because benchmarks show speedup justifies memory use (optout21)
  • Open question whether caching should use __is_fast_hash instead (optout21)

Concept ACK from optout21 based on benchmarks; open question on using __is_fast_hash.

optout21 provided a substantive Concept ACK agreeing that benchmarked speed improvements justify caching, while leaving code nits and an open question regarding __is_fast_hash.

  • optout21 Concept ACKed: 'benchmarks indicate that caching (more memory, less CPU) results in faster execution, therefore it should be applied.'
  • optout21 asked: 'Have you considered controlling hash-caching via __is_fast_hash... Seems more clear than abusing noexcept?'

Review verdicts (DrahtBot): 0

Files

17 lines under test/bench/ci.

  • src/test/hash_tests.cpp +17/-0
  • src/util/hasher.h +4/-7

Card

This PR modifies SaltedOutpointHasher to be noexcept(false) so libstdc++ std::unordered_map caches hash codes inside CCoinsMap nodes. The change trades one size_t per node of memory to gain 2-3% faster IBD and up to 11% faster AssumeUTXO loading. optout21 Concept ACKed the change based on benchmark data while inquiring whether __is_fast_hash would be a cleaner mechanism. The PR is currently a draft with merge conflicts and the author has been inactive for over four months.

Data

dossier JSON · extract JSON · model openrouter/google/gemini-3.8-flash, generated 2026-09-17T16:18, confidence high, input hash 531a342ef1b8e036