← Back to Pull requests

database, btcd: make the ffldb block cache configurable #2695

Open
unknown opened this pull request with 198 lines diff across 2 files
View on GitHub
unknown unknown commented on Nov 21, 2026 10:08 UTC
Author

Implements the ffldb block-cache option proposed in #2692. Operators can set --dbblockcachesize in 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

go test ./...
go vet ./...
go test -race ./database/ffldb .
GOARCH=386 go test ./...
go vet ./...
GOMAXPROCS=2 go test ./database/ffldb -run '^$' -bench '^BenchmarkMetadataBlockCache$' -benchtime=5x -count=3

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.

Diff: 198 lines (+148 / -50) across 2 files Reviewer: allocz Review duration: 13556m
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
0.59
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.02 · 1 substantive comment(s)
0.02
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
44%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq
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
Reviewers
Assignees
Unassigned
Labels
risk: low confidence: 44.2% reviewed sensitive_module
Vouch Risk Breakdown
AI-powered review risk analysis
Change Risk
Change Risk · Model 1 (XGBoost)
Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
Score: 59.3% (MEDIUM) · Higher = larger blast radius
59.3%
Review Confidence
Review Confidence · Models 2 & 3
Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
Score: 44.2% · Lower = rushed or shallow review
44.2%
Residual Risk
Residual Risk · Core Equation
Residual = Change × (1 − Confidence)
Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
Score: 33.1% · Safe to merge
33.1%
Repository