From 120bd3ad36c3fd77e4efa0e8146c24f8d01195e1 Mon Sep 17 00:00:00 2001 From: Tooshi Date: Sat, 25 Apr 2026 02:48:01 +0800 Subject: [PATCH] core: add code cache hit/miss meters MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - register `codeCacheHitMeter` / `codeCacheMissMeter` under `chain/code/reads/cache/process/{hit,miss}`, mirroring the account/storage pair - wire them from `StateReadCacheStats.CodeStats` in `reportMetrics()` so the data already exposed in the slow-block JSON is also scrapable from Prometheus - code cache efficiency matters — bytecode misses can be tens of KB each, so operators need a live meter, not just slow-block postmortems --- core/blockchain.go | 2 ++ core/blockchain_stats.go | 2 ++ 2 files changed, 4 insertions(+) diff --git a/core/blockchain.go b/core/blockchain.go index 296ef6bc16..a9bcd8cfa1 100644 --- a/core/blockchain.go +++ b/core/blockchain.go @@ -84,6 +84,8 @@ var ( accountCacheMissMeter = metrics.NewRegisteredMeter("chain/account/reads/cache/process/miss", nil) storageCacheHitMeter = metrics.NewRegisteredMeter("chain/storage/reads/cache/process/hit", nil) storageCacheMissMeter = metrics.NewRegisteredMeter("chain/storage/reads/cache/process/miss", nil) + codeCacheHitMeter = metrics.NewRegisteredMeter("chain/code/reads/cache/process/hit", nil) + codeCacheMissMeter = metrics.NewRegisteredMeter("chain/code/reads/cache/process/miss", nil) accountCacheHitPrefetchMeter = metrics.NewRegisteredMeter("chain/account/reads/cache/prefetch/hit", nil) accountCacheMissPrefetchMeter = metrics.NewRegisteredMeter("chain/account/reads/cache/prefetch/miss", nil) diff --git a/core/blockchain_stats.go b/core/blockchain_stats.go index d753b0b700..7bddb3d5d3 100644 --- a/core/blockchain_stats.go +++ b/core/blockchain_stats.go @@ -101,6 +101,8 @@ func (s *ExecuteStats) reportMetrics() { accountCacheMissMeter.Mark(s.StateReadCacheStats.StateStats.AccountCacheMiss) storageCacheHitMeter.Mark(s.StateReadCacheStats.StateStats.StorageCacheHit) storageCacheMissMeter.Mark(s.StateReadCacheStats.StateStats.StorageCacheMiss) + codeCacheHitMeter.Mark(s.StateReadCacheStats.CodeStats.CacheHit) + codeCacheMissMeter.Mark(s.StateReadCacheStats.CodeStats.CacheMiss) } // slowBlockLog represents the JSON structure for slow block logging.