mirror of
https://github.com/bitcoin/bitcoin
synced 2026-12-04 15:11:38 +00:00
Improve loadtxoutset performance #36603
No reviewers
Labels
No labels
Android
Backport
Block storage
Brainstorming
Bug
Build system
CI failed
Consensus
Data corruption
Descriptors
Docs
DrahtBot Guix build requested
Feature
Fuzzing
GUI
Good First Review
IPC
Insufficient Review
Kernel
Linux/Unix
Mempool
Mining
Needs Backport (31.x)
Needs Backport (32.x)
Needs Benchmark
Needs Conceptual Review
Needs backport (30.x)
Needs rebase
Needs release note
Net
P2P
PSBT
Privacy
Private Broadcast
Questions and Help
RPC/REST/ZMQ
Refactoring
Resource usage
Review club
Scripts and tools
Settings
TX fees and policy
Tests
Tracking Issue
UTXO Db and Indexes
Up for grabs
Upstream
Utils/log/libs
Validation
Waiting for author
Wallet
Windows
good first issue
interfaces
macOS
No milestone
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
bitcoin/bitcoin!36603
Loading…
Reference in a new issue
No description provided.
Delete branch "202610-loadtxoutset-speedy"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Significantly improves loadtxoutset performance via a number of changes:
Also adds a subcommand to bitcoin-util for getting a snapshot's hash_serialized_3, muhash, coin count and total amount values without importing to leveldb first.
On my systems, performance ends up bottlenecked by leveldb CPU usage.
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.
External sites
Reviews
See the guideline and AI policy for information on the review process.
If your review is incorrectly listed, please copy-paste
<!--meta-tag:bot-skip-->into the comment that the bot should ignore.Conflicts
Reviewers, this pull request conflicts with the following ones:
loadtxoutsetRPC with a startup arg by l0rinc)-Wunusedby fanquake)If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.
LLM Linter (✨ experimental)
Possible places where named args for integral literals may be used (e.g.
func(x, /*named_arg=*/0)in C++, andfunc(x, named_arg=0)in Python):src/test/validation_chainstatemanager_tests.cpp:Coin coin{CTxOut{1, CScript{} << OP_TRUE}, 1, false}src/test/validation_chainstatemanager_tests.cpp:cache.AddCoin(item.outpoint, Coin{item.coin}, false)src/test/validation_chainstatemanager_tests.cpp:Coin large_coin{CTxOut{1, large_script}, 1, false}2026-11-27 08:45:40
The performance change I see on a Ryzen 9 3900X system with RAID HDD storage is ~11minutes with master to ~1m35s with this pr for a load, consisting of ~1m15s of CPU time followed by ~20s of disk flushing; with SSD and a slightly faster CPU, total time is reduced from ~5m30s to ~50s (no significant flush delay after the CPU work is completed here). These numbers are with the block 965000 utxo set.
9 additional verified findings in the Review report.
Earlier concerns neither republished nor resolved: 2 major findings · 1 minor finding · 3 suggestions. See the Run archive linked from the Review report for their assessments.
🔴 Major · A database write error can hang
loadtxoutsetindefinitelyDuring a large import, a local LevelDB write failure can leave the reader blocked in
serialize_queue.Push(), preventingloadtxoutsetfrom returning even after an interrupt.Location:
src/node/utxo_snapshot.cpp:162(head).🔴 Major · Non-seekable snapshot input terminates the process
Piped
txoutsetsummaryinput aborts;loadtxoutsetwould also terminatebitcoindfor a FIFO, although no current caller supplying one was found.Location:
src/utxo_snapshot.h:228(head).🟠 Minor · Partial snapshot-worker startup can terminate
bitcoindIf thread-resource exhaustion lets one worker start but prevents a later one from starting,
loadtxoutsetterminatesbitcoindrather than reporting an RPC error.Location:
src/node/utxo_snapshot.cpp:252(head).🟠 Minor ·
txoutsetsummaryleaves Windowsstdinin text modeWith the Windows CRT's default text-mode
stdin, redirected binary snapshots can be translated or truncated; this platform-specific failure is inferred from source, not an observed Windows run.Location:
src/bitcoin-util.cpp:255(head).🟠 Minor · Structured fuzz snapshots fail the new txid-order requirement
The structured branch still writes coinbases in height order, so it no longer provides the txid-sorted input needed to cover successful activation and the intended late invalid-record rejection.
Location:
src/utxo_snapshot.h:150(head).🟠 Minor · The existing-directory refusal deletes the directory it refuses
Retrying after an interrupted load deletes the leftover
chainstate_snapshotdirectory, yet returns instructions to delete it manually and requires another RPC attempt.Location:
src/node/utxo_snapshot.cpp:300(head).Review coverage was incomplete.
Reviewed:
1b1f929c77b1· Review report · Previous reportspermalink
🚧 At least one of the CI tasks failed.
Task
tidy: https://github.com/bitcoin/bitcoin/actions/runs/39762952091/job/119771350806LLM reason (✨ experimental): CI failed because clang-tidy flagged a mismatched argument comment (
moveoutinstead ofmoveto) intest/coinsviewoverlay_tests.cpp; warnings are treated as errors.Hints
Try to run the tests locally, according to the documentation. However, a CI failure may still
happen due to a number of reasons, for example:
Possibly due to a silent merge conflict (the changes in this pull request being
incompatible with the current code in the target branch). If so, make sure to rebase on the latest
commit of the target branch.
A sanitizer issue, which can only be found by compiling with the sanitizer and running the
affected test.
An intermittent issue.
Leave a comment here, if you need help tracking down a confusing failure.
Can you please give us more context? Why do you consider an 11-minute load too slow? Is there a reason to think this is what's preventing people from using it - enough to justify yet more complexity in the most "load-bearing" parts of the code? Or is this just a demo to explore the possibilities?
Over the past years we've discussed how relying on someone else's UTXO set makes us uncomfortable (see https://github.com/bitcoin/bitcoin/issues/32377 and https://github.com/bitcoin/bitcoin/pull/36598).
This change adds even more AssumeUTXO-specific complexity, which is exactly why we're considering removing it completely. I wouldn't object to adding it back later through IPC and the Kernel if there's still demand and doesn't add complexity - but there's no indication of that, especially since https://github.com/bitcoin/bitcoin/issues/36476 (possibly combined with SwiftSync) would already speed up actual UTXO set construction by an order of magnitude on resource-constrained nodes. Quickly loading someone else's UTXO set could still be a useful academic pursuit, but many of us are not comfortable polluting the code with multiple chainstates, which make consensus-critical paths harder to reason about.
In bips#2137 Sjors suggested splitting up the snapshot by coin to improve performance, which didn't seem sensible to me.
I don't consider it too slow; though it's possible it could be on slower systems than the ones I test on. But the reason it is that slow is because the database gets compacted multiple times, and it also seems to use excessive amounts of memory while loading, and there isn't really a good reason to do that. The difference between checking whether better performance is possible and actually making it available to users isn't that large.
As I've said on the list, I think the assumeutxo approach is a much better approach to resolving the "fast startup of a new node" challenge than trying to get a few extra percent out of IBD performance (which introduces its own large sets of complexities). If it's been decided that that's not one of this project's goals, that's fine I guess, but I haven't seen a project statement along those lines.
Making assumeutxo a reasonable default, rather than something for experts, does require significantly more complexity (ie, the various stuff for the BIP above, cf #35054). Likewise if we want to do FEC encoding so pruned nodes can help share utxo snapshots or support IBD.
🚧 At least one of the CI tasks failed.
Task
iwyu: https://github.com/bitcoin/bitcoin/actions/runs/40163823354/job/121080686219LLM reason (✨ experimental): CI failed because the IWYU check modified includes in
src/node/utxo_snapshot.cpp, leaving a diff that caused the check to exit with code 1.Hints
Try to run the tests locally, according to the documentation. However, a CI failure may still
happen due to a number of reasons, for example:
Possibly due to a silent merge conflict (the changes in this pull request being
incompatible with the current code in the target branch). If so, make sure to rebase on the latest
commit of the target branch.
A sanitizer issue, which can only be found by compiling with the sanitizer and running the
affected test.
An intermittent issue.
Leave a comment here, if you need help tracking down a confusing failure.
🐙 This pull request conflicts with the target branch and needs rebase.
🐙 This pull request conflicts with the target branch and needs rebase.
Concept ACK
It would be great to get some testing from the people that have reported these extremely long load times. ~10 minutes is about the worst I have seen locally so I will try to ping the people I remember who reported it.