Skip to content

perf(metrics): expose pre-warm cache hit / RPC-fetch counters - #179

Merged
0xfandom merged 1 commit into
developfrom
perf/cache-metrics
May 28, 2026
Merged

perf(metrics): expose pre-warm cache hit / RPC-fetch counters#179
0xfandom merged 1 commit into
developfrom
perf/cache-metrics

Conversation

@0xfandom

Copy link
Copy Markdown
Collaborator

Summary

The cache stack landed without Prometheus instrumentation — only a debug! log line per cycle. Adds five counters so shadow-mode dashboards can read RPC-reduction ratios directly instead of grepping logs.

  • aether_prewarm_bytecode_cache_hits_total
  • aether_prewarm_bytecode_rpc_fetches_total
  • aether_prewarm_v2_reserves_cache_hits_total
  • aether_prewarm_v2_reserves_cache_stale_total
  • aether_prewarm_v2_reserves_cache_missing_total

The headline panel is rate(cache_hits) / (rate(cache_hits) + rate(rpc_fetches)) — monotonic upward as cache warms.

Files Changed

File Change
crates/simulator/src/fork.rs PrewarmedState now carries a public PrewarmStats field; partition loop counts stale vs missing instead of bucketing both into None.
crates/simulator/src/v2_reserves_cache.rs New V2CacheLookup enum + get_fresh_status. get_fresh is now a thin wrapper so existing callers stay source-compatible.
crates/grpc-server/src/metrics.rs 5 new IntCounter fields + record_prewarm_stats(PrewarmStats) + 5 *_count() getters for tests.
crates/grpc-server/src/engine.rs Bumps counters from the block-driven pre-warm path.
crates/grpc-server/src/mempool_pipeline.rs Bumps counters from the mempool pre-warm refresher.

No behavioural change: the get_fresh_status enum is internal to the cache module; old get_fresh returns the same Option<ReserveSnapshot> as before.

Acceptance Criteria

  • All 5 counters registered in the shared Registry.
  • Both pre-warm call sites (Engine + mempool refresher) call record_prewarm_stats exactly once per cycle.
  • get_fresh external behaviour unchanged; get_fresh_status lights the new code path.
  • cargo clippy --all-targets -- -D warnings clean on touched crates.
  • cargo test --workspace --lib — 510 passed (was 510, +1 new test in metrics + 1 new in v2_reserves_cache).
  • cargo build --workspace --release — green.
  • go test ./... — green.

Test plan

  • Unit: record_prewarm_stats_bumps_all_five_counters — applies two synthetic PrewarmStats, asserts the counters accumulate, verifies the /metrics text output shows the right totals.
  • Unit: get_fresh_status_distinguishes_stale_from_missing — separate addresses for unseen / cached-stale / cached-fresh; matches the three enum variants.
  • Shadow run: confirm aether_prewarm_bytecode_cache_hits_total climbs across consecutive blocks and aether_prewarm_bytecode_rpc_fetches_total plateaus once the cache is warm.

Caches landed in #173/#174/#178 had no Prometheus instrumentation; only
a debug log line reported cycle outcomes. Adds five IntCounters so the
shadow-mode dashboard can read RPC-reduction ratios directly.

- aether_prewarm_bytecode_cache_hits_total
- aether_prewarm_bytecode_rpc_fetches_total
- aether_prewarm_v2_reserves_cache_hits_total
- aether_prewarm_v2_reserves_cache_stale_total
- aether_prewarm_v2_reserves_cache_missing_total

Implementation surfaces a PrewarmStats struct from prewarm_state and
splits V2ReservesCache::get_fresh into a V2CacheLookup enum so the
stale vs missing distinction reaches the counter without changing the
fast path. Engine and mempool refresher both call record_prewarm_stats
after every cycle.
@vercel

vercel Bot commented May 28, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
aether Ready Ready Preview, Comment May 28, 2026 11:09am
aether-63xv Ready Ready Preview, Comment May 28, 2026 11:09am

@0xfandom
0xfandom merged commit 95b8eff into develop May 28, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant