Skip to content

coins: cache CCoinsMap outpoint hashes - #162

Draft
l0rinc wants to merge 2 commits into
masterfrom
detached521
Draft

l0rinc wants to merge 2 commits into
masterfrom
detached521

Conversation

@l0rinc

@l0rinc l0rinc commented May 6, 2026

Copy link
Copy Markdown
Owner

Keep SaltedOutpointHasher noexcept so normal unordered containers do not ask libstdc++ to store hash codes in every node.

CCoinsMap still benefits from avoiding repeated salted outpoint hashing. Cache the hash in COutPoint and let CCoinsMap use a map-specific hasher id so copied cache entries do not reuse a hash from a different map salt.

The cached hash is now part of the key object itself, so restore the pool allocator budget to four pointer-sized fields.

l0rinc added 2 commits May 7, 2026 15:23
PoolAllocator's node budget should only reserve space for implementation-defined std::unordered_map node-link overhead before the key caches any hash value.

Drop the stale wording about standard-library hash-code storage and use 3 * sizeof(void*) consistently across the PoolAllocator unordered-map examples.
Keep SaltedOutpointHasher noexcept so normal unordered containers do not ask libstdc++ to store hash codes in every node.

CCoinsMap still benefits from avoiding repeated salted outpoint hashing. Add a CCoinsMap-specific hasher that caches the hash in COutPoint and fills it through std::atomic_ref, so concurrent lookups can race only by recomputing and publishing the same cached value.

Bump the CCoinsMap PoolAllocator slack back to four pointer-sized fields. CCoinsMap is the dominant memory consumer, so keep a conservative allowance for implementation-defined std::unordered_map node overhead instead of risking fall-through allocations on stdlibs with larger nodes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant