database, btcd: make the ffldb block cache configurable #2695
All Vouch review confidence checks passed
Residual risk 0.33 = Change Risk (0.59) × (1 − Review Confidence (0.44)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.59 · 198 lines diff across 2 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.02 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Shallow Review Depth
shallow_review_depth
0.344
Diff Size
diff_size
0.317
Sensitive Paths
sensitive_paths
0.059
Real PR Conversation Timeline
1 comments
"Review active on #2695"
general
weight: 0.35
allocz
Implements the ffldb block-cache option proposed in #2692. Operators can set
--dbblockcachesizein MiB when creating or reopening the database. Leaving it unset keeps LevelDB’s current default of 8 MiB. The setting is independent of the UTXO write cache. The existing two-argument driver API still works.The regression test fills a table, reads the same keys twice, reopens the database with a different capacity, and checks LevelDB’s file-read counter. The CLI also rejects a MiB value that would overflow LevelDB’s byte capacity on the host architecture.
Repeated metadata reads
On linux/amd64 with Go 1.26.11, each measured pass visits the same 32,768 keys in a fixed interleaved order after one warm-up pass. Each value contains 512 bytes.
| Cache | LevelDB bytes read per pass |
| --- | ---: |
| 8 MiB | 69,914,880 |
| 32 MiB | 69,140,480 |
| 64 MiB | 0 |
In three local runs with five timed passes each and
GOMAXPROCS=2, the median pass took 195.7 ms, 193.4 ms and 123.5 ms respectively. These are file reads requested by LevelDB. The OS page cache can satisfy them. A mainnet catch-up run is still needed to measure blocks per second and total RSS on the node in the issue.Tests
Also checked a simnet daemon creating the database at the default capacity, shutting down, and reopening it at 32 MiB. An out-of-range capacity exits with an error.