← Back to Pull requests

statedb: Minor WriteTxn optimizations #205

Closed
unknown closed this pull request without merging on Oct 05, 2026 08:26 UTC
View on GitHub
unknown unknown commented on Sep 25, 2026 10:19 UTC
Author

  • statedb.New now defaults to NopMetrics instead of ExpVarMetrics

  • Avoid expvar.Int allocation in ExpVarMetrics

  • Use the slice in the txn handle as the new root to avoid allocating a new one (WriteTxn_1 allocs 13 -> 12)

  • As we're starting to have tens of tables in Cilium keep track of locked tables instead of iterating over all tables when committing (CommitOnly_100 695ns/op -> 542ns/op (-22%))

  • Reduce the number of calls to time.Now in write transactions (WriteTxn_1 742ns/op -> 703ns/op (-5%))

  • Speed up "tableIndex" lookup by avoiding going via TableMeta interface
  • Benchstat highlights:

    ┌─────────────────────────────────────────┬────────┬────────┬───────────────┬─────────┐
    │                Benchmark                │  main  │  head  │    Δ time     │ allocs  │
    ├─────────────────────────────────────────┼────────┼────────┼───────────────┼─────────┤
    │ DB_WriteTxn_CommitOnly_100Tables        │ 749.8n │ 507.0n │ −32.4%        │ 4 → 3   │
    ├─────────────────────────────────────────┼────────┼────────┼───────────────┼─────────┤
    │ DB_WriteTxnCommit100                    │ 738.7n │ 502.3n │ −32.0%        │ 4 → 3   │
    ├─────────────────────────────────────────┼────────┼────────┼───────────────┼─────────┤
    │ DB_WriteTxn_CommitOnly_1Table           │ 425.8n │ 359.3n │ −15.6%        │ 4 → 3   │
    ├─────────────────────────────────────────┼────────┼────────┼───────────────┼─────────┤
    │ DB_PropagationDelay                     │ 863.6n │ 755.5n │ −12.5%        │ 15 → 13 │
    ├─────────────────────────────────────────┼────────┼────────┼───────────────┼─────────┤
    │ DB_NewWriteTxn                          │ 374.4n │ 330.2n │ −11.8%        │ 3 → 3   │
    ├─────────────────────────────────────────┼────────┼────────┼───────────────┼─────────┤
    │ DB_WriteTxn_1                           │ 760.5n │ 689.8n │ −9.3%         │ 13 → 12 │
    ├─────────────────────────────────────────┼────────┼────────┼───────────────┼─────────┤
    │ DB_WriteTxn_1_LPMIndex                  │ 8.293µ │ 7.685µ │ −7.3%         │ 80 → 68 │
    ├─────────────────────────────────────────┼────────┼────────┼───────────────┼─────────┤
    │ DB_LPMIndex_Get                         │ 2.500m │ 2.379m │ −4.8%         │ 0 → 0   │
    ├─────────────────────────────────────────┼────────┼────────┼───────────────┼─────────┤
    │ DB_WriteTxn_10                          │ 332.4n │ 319.8n │ −3.8%         │ 6 → 5   │
    ├─────────────────────────────────────────┼────────┼────────┼───────────────┼─────────┤
    │ DB_RandomLookup                         │ 30.70µ │ 29.77µ │ −3.0%         │ 0 → 0   │
    ├─────────────────────────────────────────┼────────┼────────┼───────────────┼─────────┤
    │ DB_Changes                              │ 705.9µ │ 685.2µ │ −2.9%         │ ≈       │
    ├─────────────────────────────────────────┼────────┼────────┼───────────────┼─────────┤
    │ DB_WriteTxn_1000                        │ 309.1n │ 302.0n │ −2.3%         │ =       │
    ├─────────────────────────────────────────┼────────┼────────┼───────────────┼─────────┤
    │ DB_RandomReplace                        │ 600.8µ │ 592.4µ │ −1.4%         │ ≈       │
    ├─────────────────────────────────────────┼────────┼────────┼───────────────┼─────────┤
    │ DB_WriteTxn_100_SecondaryIndex          │ 459.8n │ 453.6n │ −1.3%         │ =       │
    └─────────────────────────────────────────┴────────┴────────┴───────────────┴─────────┘
    


    AIL:3

    Diff: 425 lines (+318 / -107) across 5 files Reviewer: bimmlerd Review duration: 14287m
    All Vouch review confidence checks passed
    Residual risk 0.18 = Change Risk (0.45) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.45 · 425 lines diff across 5 files
    0.45
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    60%
    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
    Diff Size diff_size
    0.362
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #205"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 60.5% reviewed
    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: 45.1% (MEDIUM) · Higher = larger blast radius
    45.1%
    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: 60.5% · Lower = rushed or shallow review
    60.5%
    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: 17.8% · Safe to merge
    17.8%
    Repository