Skip to content

Commit

Permalink
show stats mem usage even if stats mem quota is not set
Browse files Browse the repository at this point in the history
  • Loading branch information
xuyifangreeneyes committed May 25, 2023
1 parent cd834ee commit d6660f4
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 13 deletions.
3 changes: 1 addition & 2 deletions statistics/handle/handle.go
Original file line number Diff line number Diff line change
Expand Up @@ -1010,15 +1010,14 @@ 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())
h.statsCache.Store(newCache)
updated = true
}
h.statsCache.Unlock()
if updated && enableQuota {
if updated {
handle_metrics.CostGauge.Set(float64(newCost))
}
return
Expand Down
5 changes: 0 additions & 5 deletions statistics/handle/lru_cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
6 changes: 0 additions & 6 deletions statistics/handle/statscache.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit d6660f4

Please sign in to comment.