← Back to Pull requests

objectfs: in-memory LRU read cache for SQLite metadata store #157

Closed
unknown closed this pull request without merging on Oct 03, 2026 19:36 UTC
View on GitHub
unknown unknown commented on Oct 03, 2026 18:44 UTC
Author

Phase 1 of #155: in-memory read cache in front of SQLite Get operations.

Overview

  • Bounded $O(1)$ LRU Cache: Upgrades LRUCache in metadata_cache.go to use an intrusive doubly-linked list with entry count bounding, byte size bounding (sizeFn), and access stats (Hits, Misses, HitRate).

  • Decoded Row Caching: Caches decoded Inode and DirEntry rows keyed by (table, canonical_key).

  • Negative Caching: Caches missing keys (ENOENT) so repeat lookups for non-existent files do not hit SQLite.

  • Cache Coherence: When mutations commit in applyTxChangesLocked, the cache entries for created, updated, or deleted rows are updated or marked negative in the same critical section as v.sqliteDB.ApplyBatch.

  • Configurable Limits: Adds --metadata-cache-entries (default 65,536) and --metadata-cache-bytes (default 64 MiB) flags and WithMetadataCacheLimits volume/server options.
  • ---

    Benchmark & Scale Measurements

    1. Per-Operation Benchmark Comparison (BenchmarkMetadataStoreOperations)

    | Operation | Legacy Store | SQLite (Cache ON) | SQLite (Cache OFF) | Speedup (Cache ON vs OFF) |
    | :--- | :--- | :--- | :--- | :--- |
    | Stat | 167 ns/op | 1,331 ns/op | 5,233 ns/op | 3.9x faster |
    | Lookup | 229 ns/op | 2,383 ns/op | 10,215 ns/op | 4.3x faster |
    | ReadDir | 27,902 ns/op | 257,127 ns/op | 697,821 ns/op | 2.7x faster |
    | Create | 849,997 ns/op | 1,748,359 ns/op | 1,731,882 ns/op | ~1.0x (write path) |
    | Rename | 812,011 ns/op | 1,673,111 ns/op | 1,718,968 ns/op | ~1.0x (write path) |

    2. Scale & Cache Hit Rate Analysis (TestBenchmarkMetricsReport)

  • 10,000 files:

  • - cache ON: Stat 5k: 1.75µs/op | Lookup 5k: 2.85µs/op | ENOENT 1k: 6.78µs/op | Hit Rate: 93.75% | Memory: 7,017 KB / 65,536 KB bound (31,001 entries)
    - cache OFF: Stat 5k: 5.80µs/op | Lookup 5k: 11.19µs/op | ENOENT 1k: 4.34µs/op | Hit Rate: 0.00%
  • 50,000 files:

  • - cache ON: Stat 5k: 6.99µs/op | Lookup 5k: 8.93µs/op | Memory: 15,138 KB / 65,536 KB bound (65,536 entries bounded)
    - cache OFF: Stat 5k: 5.70µs/op | Lookup 5k: 11.35µs/op | Memory: unbounded
  • Scale (15,000 files across 100 dirs):

  • - legacy: Stat 1,000 evicted inodes: 232.9µs/op | Lookup 10 dirs: 215.8µs/op
    - sqlite (cache ON): Stat 1,000 inodes: 2.0µs/op | Lookup 10 dirs: 3.9µs/op (100% cache hit rate)
    - sqlite (cache OFF): Stat 1,000 inodes: 5.7µs/op | Lookup 10 dirs: 23.8µs/op

    ---

    Fixes #155

    Diff: 313 lines (+234 / -79) across 3 files Reviewer: justinsb Review duration: 51m
    All Vouch review confidence checks passed
    Residual risk 0.16 = Change Risk (0.40) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.40 · 313 lines diff across 3 files
    0.40
    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.344
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #157"
    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: 40.3% (MEDIUM) · Higher = larger blast radius
    40.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: 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: 15.9% · Safe to merge
    15.9%