Repository navigation
Description
What
PredictiveCache computes PredictionAccuracy, PrefetchEfficiency, and CacheHitImprovement, and on a running mount there is no way to read any of them.
MultiLevelCache.initializeLevels (internal/cache/multilevel.go:358-381) wraps the L1 cache in a PredictiveCache whenever prefetch is enabled — internal/adapter/adapter.go:136 sets Prefetch: true unconditionally, so this is every mount — and stores it as a types.Cache in a CacheLevel. From there:
types.Cacheis six methods about bytes. No statistics beyondStats().MultiLevelCache.GetLevelStats("L1")returns atypes.CacheStats— hits, misses, size, hit ratio. None of the three predictive fields.- There is no exported accessor on
MultiLevelCachethat reaches a level's underlying cache.Closegets at it only through the unexportedCacheClosertype assertion.
So the numbers are computed on every read, aggregated on a 30-second ticker, and discarded at unmount.
How it surfaced
docs/features/read-ahead.md documented the way to read them:
predictiveCache := cache.GetPredictiveCache()
stats := predictiveCache.GetPredictiveStats()GetPredictiveCache does not exist under that or any other name — zero hits repo-wide. It was caught by TestDocumentedGoSymbolsExist (internal/config/docs_symbols_test.go), the #182 gate, on its first run. The documentation is now corrected to say the statistics are unreachable and to point here.
GetPredictiveStats itself is real (internal/cache/predictive.go:396). It is reachable only on a PredictiveCache the caller constructed, which observes that caller's accesses and nothing the filesystem does.
Options
- Export them through the metrics surface. The most useful outcome: these are exactly the numbers an operator wants when deciding whether prefetch is earning its bandwidth.
internal/metricsalready exportsobjectfs_cache_requests_totalandobjectfs_cache_size_bytes; three gauges alongside them would make prefetch effectiveness observable in Prometheus, which is where the rest of the cache telemetry already is. - An accessor on
MultiLevelCache. Cheaper — something likePredictiveStats() (PredictiveStats, bool), returning false when L1 is not wrapped. Makes them reachable in-process, but nothing currently in the tree would call it, so it risks being a second unexercised path. - Delete the three fields. Consistent with the argument in metrics: percentile fields are never assigned and the latency histogram is a modulo, not a bucketing #222: a statistic nothing can read is not a feature. Weaker here than there, though — unlike metrics: percentile fields are never assigned and the latency histogram is a modulo, not a bucketing #222's percentiles these are computed correctly, so the defect is plumbing rather than arithmetic.
Option 1 is the recommendation. Note the ordering against the ML predictor: docs/index.md's not-yet-wired-up table records that internal/analytics's Predictor field is never set on the mount path, so PredictionAccuracy today measures the pattern detector rather than the model the documentation attributes it to. Exporting the metric without that context would publish a number under a misleading name — the same shape of defect as #222's zero percentiles.
Activity
docs: three mechanical gates, and the 90 claims they found false (#225)
chore: a docs path that never existed, and four duplicate link defini…
chore: a docs path that never existed, and four duplicate link defini…
chore: a docs path that never existed, and four duplicate link defini…
lint: satisfy misspell, stringsseq and waitgroupgo on #223's new tests
feat(cache): the predictive cache's statistics reach a scrape (#223) (#…