-
Notifications
You must be signed in to change notification settings - Fork 0
[IBD] coins: reduce lookups in dbcache layer propagation #34
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
Conversation
499baf5 to
f333bdf
Compare
4412abd to
0b0c329
Compare
0b0c329 to
067e314
Compare
Previously, when the parent coins cache had no entry and the child did, `BatchWrite` performed a find followed by `try_emplace`, which resulted in multiple `SipHash` computations and bucket traversals on the common insert path. This change uses a single leading `try_emplace` and branches on the returned `inserted` flag. In the `FRESH && SPENT` case (only exercised by tests), we erase the just-inserted placeholder (which is constant time with no rehash anyway). Semantics are unchanged for all valid parent/child state combinations. This change is a minimal version of bitcoin@723c49b and draws simplification ideas bitcoin@ae76ec7. Co-authored-by: Martin Ankerl <[email protected]> Co-authored-by: Andrew Toth <[email protected]>
A few temporary `CCoinsViewCache`'s are destructed right after the `Flush()`, therefore it is not necessary to call `ReallocateCache` to recreate them right before they're killed anyway. * `Flush(/*reallocate_cache=*/true)` - retains existing functionality; * `Flush(/*reallocate_cache=*/false)` - skips destruction and reallocation of the parent cache since it will soon go out of scope anyway; This change was based on a subset of bitcoin#28945. Co-authored-by: Martin Ankerl <[email protected]>
067e314 to
195fc2f
Compare
|
Concept ACK for try_emplace to reduce find() calls. b23c6a1 Concept NACK on the rest. why are we setting the release notes for Core 29.1? Shouldn't qt PRs be separate? I would refactor this into two commits focusing on the |
|
This is still on my own fork, i.e.
What makes you say that's simpler? |
|
oops. didn't realize.
|
|
That's deliberate, it's simpler to mentally parse |
Previously, when the parent coins cache had no entry and the child did,
BatchWriteperformed a find followed bytry_emplace, which resulted in multipleSipHashcomputations and bucket traversals on the common insert path.This change uses a single leading
try_emplaceand branches on the returnedinsertedflag. In theFRESH && SPENTcase (only exercised by tests), we erase the just-inserted placeholder (which is constant time with no rehash anyway). Semantics are unchanged for all valid parent/child state combinations.This change is a minimal version of bitcoin/bitcoin@
723c49b(#32128) and draws simplification ideas bitcoin/bitcoin@ae76ec7(#30673) and bitcoin#30326.Related to parent cache propagation, the second commit makes it possible to avoid destructuring-recreating-destructuring of these short-live parent caches created for each new block.
A few temporary
CCoinsViewCache's are destructed right after theFlush(), therefore it is not necessary to callReallocateCacheto recreate them right before they're killed anyway.This change was based on a subset of bitcoin#28945.
Reindex-chainstate indicates ~1% speedup.
Details