From f066f52b04028bc380531954ed54578fd1d16ee9 Mon Sep 17 00:00:00 2001 From: "alex.sharov" Date: Tue, 12 Oct 2021 15:16:25 +0700 Subject: [PATCH] add codeEvict list metric --- kv/kvcache/cache.go | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/kv/kvcache/cache.go b/kv/kvcache/cache.go index fe05f822e..5da3d7b49 100644 --- a/kv/kvcache/cache.go +++ b/kv/kvcache/cache.go @@ -88,6 +88,7 @@ type Coherent struct { hits, miss, timeout *metrics.Counter keys, evict *metrics.Counter codeHits, codeMiss, codeKeys *metrics.Counter + codeEvictLen *metrics.Counter latestStateView *CoherentRoot roots map[ViewID]*CoherentRoot stateEvict, codeEvict *ThreadSafeEvictionList @@ -149,19 +150,20 @@ func New(cfg CoherentConfig) *Coherent { panic("empty config passed") } return &Coherent{ - roots: map[ViewID]*CoherentRoot{}, - stateEvict: &ThreadSafeEvictionList{l: NewList()}, - codeEvict: &ThreadSafeEvictionList{l: NewList()}, - hasher: sha3.NewLegacyKeccak256(), - cfg: cfg, - miss: metrics.GetOrCreateCounter(fmt.Sprintf(`cache_total{result="miss",name="%s"}`, cfg.MetricsLabel)), - hits: metrics.GetOrCreateCounter(fmt.Sprintf(`cache_total{result="hit",name="%s"}`, cfg.MetricsLabel)), - timeout: metrics.GetOrCreateCounter(fmt.Sprintf(`cache_timeout_total{name="%s"}`, cfg.MetricsLabel)), - keys: metrics.GetOrCreateCounter(fmt.Sprintf(`cache_keys_total{name="%s"}`, cfg.MetricsLabel)), - evict: metrics.GetOrCreateCounter(fmt.Sprintf(`cache_list_total{name="%s"}`, cfg.MetricsLabel)), - codeMiss: metrics.GetOrCreateCounter(fmt.Sprintf(`cache_code_total{result="miss",name="%s"}`, cfg.MetricsLabel)), - codeHits: metrics.GetOrCreateCounter(fmt.Sprintf(`cache_code_total{result="hit",name="%s"}`, cfg.MetricsLabel)), - codeKeys: metrics.GetOrCreateCounter(fmt.Sprintf(`cache_code_keys_total{name="%s"}`, cfg.MetricsLabel)), + roots: map[ViewID]*CoherentRoot{}, + stateEvict: &ThreadSafeEvictionList{l: NewList()}, + codeEvict: &ThreadSafeEvictionList{l: NewList()}, + hasher: sha3.NewLegacyKeccak256(), + cfg: cfg, + miss: metrics.GetOrCreateCounter(fmt.Sprintf(`cache_total{result="miss",name="%s"}`, cfg.MetricsLabel)), + hits: metrics.GetOrCreateCounter(fmt.Sprintf(`cache_total{result="hit",name="%s"}`, cfg.MetricsLabel)), + timeout: metrics.GetOrCreateCounter(fmt.Sprintf(`cache_timeout_total{name="%s"}`, cfg.MetricsLabel)), + keys: metrics.GetOrCreateCounter(fmt.Sprintf(`cache_keys_total{name="%s"}`, cfg.MetricsLabel)), + evict: metrics.GetOrCreateCounter(fmt.Sprintf(`cache_list_total{name="%s"}`, cfg.MetricsLabel)), + codeMiss: metrics.GetOrCreateCounter(fmt.Sprintf(`cache_code_total{result="miss",name="%s"}`, cfg.MetricsLabel)), + codeHits: metrics.GetOrCreateCounter(fmt.Sprintf(`cache_code_total{result="hit",name="%s"}`, cfg.MetricsLabel)), + codeKeys: metrics.GetOrCreateCounter(fmt.Sprintf(`cache_code_keys_total{name="%s"}`, cfg.MetricsLabel)), + codeEvictLen: metrics.GetOrCreateCounter(fmt.Sprintf(`cache_code_list_total{name="%s"}`, cfg.MetricsLabel)), } } @@ -222,6 +224,7 @@ func (c *Coherent) advanceRoot(viewID ViewID) (r *CoherentRoot) { c.keys.Set(uint64(c.latestStateView.cache.Len())) c.codeKeys.Set(uint64(c.latestStateView.codeCache.Len())) c.evict.Set(uint64(c.stateEvict.Len())) + c.codeEvictLen.Set(uint64(c.codeEvict.Len())) return r }