-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
perf: cache x11 block header hash, reduce reindex hashes from 4->2 per block #6610
base: develop
Are you sure you want to change the base?
perf: cache x11 block header hash, reduce reindex hashes from 4->2 per block #6610
Conversation
WalkthroughThe changes implement and propagate caching of computed block header hashes. A mutable variable, 📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (3)
✅ Files skipped from review due to trivial changes (1)
⏰ Context from checks skipped due to timeout of 90000ms (6)
🔇 Additional comments (6)
✨ Finishing Touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
Nice! 👍 Could also avoid resetting diff --git a/src/primitives/block.h b/src/primitives/block.h
index 158c42b2c1..d80fb30215 100644
--- a/src/primitives/block.h
+++ b/src/primitives/block.h
@@ -41,7 +41,7 @@ public:
SERIALIZE_METHODS(CBlockHeader, obj) {
READWRITE(obj.nVersion, obj.hashPrevBlock, obj.hashMerkleRoot, obj.nTime, obj.nBits, obj.nNonce);
- obj.cached_hash.SetNull();
+ SER_READ(obj, obj.cached_hash.SetNull());
}
void SetNull() develop: This PR: This PR with the patch above: |
Issue being fixed or feature implemented
We currently hash the header up to 4 times per block we are loading from disk; drop this down to 2 times
before:

./src/dashd --printtoconsole --testnet --nowallet --reindex --stopatheight=1 76.34s user 6.15s system 95% cpu 1:25.98 total
after:
./src/dashd --printtoconsole --testnet --nowallet --reindex --stopatheight=1 62.87s user 5.70s system 95% cpu 1:11.52 total

Shaves ~20-25% off of header reindex times.
Calculated as ((76.34-62.87)/76.34)=17.6%, but this includes the overhead of startup / shutdown, so it's likely higher.
What was done?
How Has This Been Tested?
Reindex headers; should probably do a full reindex
Breaking Changes
Checklist:
Go over all the following points, and put an
x
in all the boxes that apply.