From d6660f4dc5be0b9c3758ee8a36c6412620e01977 Mon Sep 17 00:00:00 2001 From: xuyifan <675434007@qq.com> Date: Thu, 25 May 2023 16:54:06 +0800 Subject: [PATCH] show stats mem usage even if stats mem quota is not set --- statistics/handle/handle.go | 3 +-- statistics/handle/lru_cache.go | 5 ----- statistics/handle/statscache.go | 6 ------ 3 files changed, 1 insertion(+), 13 deletions(-) diff --git a/statistics/handle/handle.go b/statistics/handle/handle.go index ce340bcffe715..18b467fc23be0 100644 --- a/statistics/handle/handle.go +++ b/statistics/handle/handle.go @@ -1010,7 +1010,6 @@ func (h *Handle) GetPartitionStats(tblInfo *model.TableInfo, pid int64, opts ... func (h *Handle) updateStatsCache(newCache statsCache) (updated bool) { h.statsCache.Lock() oldCache := h.statsCache.Load().(statsCache) - enableQuota := oldCache.EnableQuota() newCost := newCache.Cost() if oldCache.version < newCache.version || (oldCache.version == newCache.version && oldCache.minorVersion < newCache.minorVersion) { h.statsCache.memTracker.Consume(newCost - oldCache.Cost()) @@ -1018,7 +1017,7 @@ func (h *Handle) updateStatsCache(newCache statsCache) (updated bool) { updated = true } h.statsCache.Unlock() - if updated && enableQuota { + if updated { handle_metrics.CostGauge.Set(float64(newCost)) } return diff --git a/statistics/handle/lru_cache.go b/statistics/handle/lru_cache.go index 701b0f1168a77..786df0fdebfbd 100644 --- a/statistics/handle/lru_cache.go +++ b/statistics/handle/lru_cache.go @@ -291,11 +291,6 @@ func (s *statsInnerCache) SetCapacity(c int64) { s.lru.setCapacity(c) } -// EnableQuota implements statsCacheInner -func (s *statsInnerCache) EnableQuota() bool { - return true -} - // Front implements statsCacheInner func (s *statsInnerCache) Front() int64 { s.RLock() diff --git a/statistics/handle/statscache.go b/statistics/handle/statscache.go index 1eabab981e7a7..ebf04eb0b7302 100644 --- a/statistics/handle/statscache.go +++ b/statistics/handle/statscache.go @@ -35,7 +35,6 @@ type statsCacheInner interface { FreshMemUsage() Copy() statsCacheInner SetCapacity(int64) - EnableQuota() bool // Front returns the front element's owner tableID, only used for test Front() int64 } @@ -237,11 +236,6 @@ func (m *mapCache) Copy() statsCacheInner { // SetCapacity implements statsCacheInner func (m *mapCache) SetCapacity(int64) {} -// EnableQuota implements statsCacheInner -func (m *mapCache) EnableQuota() bool { - return false -} - // Front implements statsCacheInner func (m *mapCache) Front() int64 { return 0