Claude/investigate digibyte performance regression in the getblockchaininfo RPC call
#349
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #345 - This PR addresses a critical 3× performance regression in the
getblockchaininfoRPC call (from ~1s to ~3s) introduced in v8.26.1.Root Cause
The
GetDifficulty()function insrc/rpc/blockchain.cppwas using an inefficient O(n) chain-walking algorithm (GetLastBlockIndexForAlgo()) instead of the available O(1) cached lookup (GetLastBlockIndexForAlgoFast()).With DigiByte's ~23 million blocks and 6-7 difficulty calculations per
getblockchaininfocall, this resulted in 120-350 block lookups per RPC request.The Fix
Changed one line in
src/rpc/blockchain.cpp:87:Performance Impact
This should bring performance well below even the v7.17.3 baseline reported by the user.
Why This is Safe
The
GetLastBlockIndexForAlgoFast()function:lastAlgoBlocks[]cache array that's properly maintained during block loadingWhy The Regression Occurred
Files Changed
src/rpc/blockchain.cpp- One-line performance fixISSUE_345_ANALYSIS.md- Comprehensive technical analysisGITHUB_ISSUE_345_RESPONSE.md- User-facing explanationTesting Needed
Please test the performance improvement:
Expected result: Dramatically faster response times (~0.3-0.5s)
Additional Documentation
See
ISSUE_345_ANALYSIS.mdfor complete technical details including:Type: Bug Fix / Performance Improvement
Priority: High (user-facing performance regression)
Breaking Changes: None
Risk Level: Low (uses existing well-tested infrastructure)