From 3a6a85ed2cd00f8a50807d3a77a1150e110f5057 Mon Sep 17 00:00:00 2001 From: Dieter Plaetinck Date: Thu, 9 Mar 2017 22:49:28 +0100 Subject: [PATCH] Revert "hit/miss stats for matchcache" This reverts commit 3bae47fc22680c07ff5a9764061b77333a66fc42. They consume about 1% cpu (flat and cumul) under heavy ingest load and they basically just confirm it works exactly like it should. But the commit is here in case someone ever wants to re-apply it. --- mdata/init.go | 4 ++-- mdata/matchcache/matchcache.go | 14 ++------------ 2 files changed, 4 insertions(+), 14 deletions(-) diff --git a/mdata/init.go b/mdata/init.go index 054ff32a9c..388fba630e 100644 --- a/mdata/init.go +++ b/mdata/init.go @@ -91,6 +91,6 @@ func ConfigProcess() { } func Cache(cleanInterval, expireAfter time.Duration) { - schemasCache = matchcache.New("schemas", cleanInterval, expireAfter) - aggsCache = matchcache.New("aggs", cleanInterval, expireAfter) + schemasCache = matchcache.New(cleanInterval, expireAfter) + aggsCache = matchcache.New(cleanInterval, expireAfter) } diff --git a/mdata/matchcache/matchcache.go b/mdata/matchcache/matchcache.go index 62663db7a7..3805d32a23 100644 --- a/mdata/matchcache/matchcache.go +++ b/mdata/matchcache/matchcache.go @@ -1,11 +1,8 @@ package matchcache import ( - "fmt" "sync" "time" - - "github.com/raintank/metrictank/stats" ) // Cache caches key to uint16 lookups (for schemas and aggregations) @@ -18,8 +15,6 @@ type Cache struct { cleanInterval time.Duration expireAfter time.Duration - hits *stats.Counter32 - miss *stats.Counter32 } type Item struct { @@ -27,13 +22,11 @@ type Item struct { seen int64 } -func New(name string, cleanInterval, expireAfter time.Duration) *Cache { +func New(cleanInterval, expireAfter time.Duration) *Cache { m := &Cache{ data: make(map[string]Item), cleanInterval: cleanInterval, expireAfter: expireAfter, - hits: stats.NewCounter32(fmt.Sprintf("idx.matchcache.%s.ops.hit", name)), - miss: stats.NewCounter32(fmt.Sprintf("idx.matchcache.%s.ops.miss", name)), } go m.maintain() return m @@ -45,10 +38,7 @@ type AddFunc func(key string) uint16 func (m *Cache) Get(key string, fn AddFunc) uint16 { m.Lock() item, ok := m.data[key] - if ok { - m.hits.Inc() - } else { - m.miss.Inc() + if !ok { item.val = fn(key) } item.seen = time.Now().Unix()