From 97be5573aff20600cc35e582415fffab73a0e3e6 Mon Sep 17 00:00:00 2001 From: buffer <1045931706@qq.com> Date: Fri, 22 Jul 2022 14:39:09 +0800 Subject: [PATCH] core: clean some remain code about deviation filter. (#5329) close tikv/pd#5328 Signed-off-by: bufferflies <1045931706@qq.com> --- server/core/store_stats.go | 28 ++------------------------- server/core/store_stats_test.go | 3 --- server/statistics/store_collection.go | 2 -- 3 files changed, 2 insertions(+), 31 deletions(-) diff --git a/server/core/store_stats.go b/server/core/store_stats.go index 2cc8099ce49..2416c4c4678 100644 --- a/server/core/store_stats.go +++ b/server/core/store_stats.go @@ -15,8 +15,6 @@ package core import ( - "math" - "github.com/pingcap/kvproto/pkg/pdpb" "github.com/tikv/pd/pkg/movingaverage" "github.com/tikv/pd/pkg/syncutil" @@ -28,20 +26,12 @@ type storeStats struct { // avgAvailable is used to make available smooth, aka no sudden changes. avgAvailable *movingaverage.HMA - // Following two fields are used to trace the deviation when available - // records' deviation range to make scheduling able to converge. - // Here `MaxFilter` is used to make the scheduling more conservative, and - // `HMA` is used to make it smooth. - maxAvailableDeviation *movingaverage.MaxFilter - avgMaxAvailableDeviation *movingaverage.HMA } func newStoreStats() *storeStats { return &storeStats{ - rawStats: &pdpb.StoreStats{}, - avgAvailable: movingaverage.NewHMA(60), // take 10 minutes sample under 10s heartbeat rate - maxAvailableDeviation: movingaverage.NewMaxFilter(120), // take 20 minutes sample under 10s heartbeat rate - avgMaxAvailableDeviation: movingaverage.NewHMA(60), // take 10 minutes sample under 10s heartbeat rate + rawStats: &pdpb.StoreStats{}, + avgAvailable: movingaverage.NewHMA(60), // take 10 minutes sample under 10s heartbeat rate } } @@ -53,11 +43,7 @@ func (ss *storeStats) updateRawStats(rawStats *pdpb.StoreStats) { if ss.avgAvailable == nil { return } - ss.avgAvailable.Add(float64(rawStats.GetAvailable())) - deviation := math.Abs(float64(rawStats.GetAvailable()) - ss.avgAvailable.Get()) - ss.maxAvailableDeviation.Add(deviation) - ss.avgMaxAvailableDeviation.Add(ss.maxAvailableDeviation.Get()) } // GetStoreStats returns the statistics information of the store. @@ -157,16 +143,6 @@ func (ss *storeStats) GetAvgAvailable() uint64 { return climp0(ss.avgAvailable.Get()) } -// GetAvailableDeviation returns approximate magnitude of available in the recent period. -func (ss *storeStats) GetAvailableDeviation() uint64 { - ss.mu.RLock() - defer ss.mu.RUnlock() - if ss.avgMaxAvailableDeviation == nil { - return 0 - } - return climp0(ss.avgMaxAvailableDeviation.Get()) -} - func climp0(v float64) uint64 { if v <= 0 { return 0 diff --git a/server/core/store_stats_test.go b/server/core/store_stats_test.go index bf12e12d78c..9f2969cd81f 100644 --- a/server/core/store_stats_test.go +++ b/server/core/store_stats_test.go @@ -36,7 +36,6 @@ func TestStoreStats(t *testing.T) { re.Equal(uint64(50*units.GiB), store.GetUsedSize()) re.Equal(uint64(150*units.GiB), store.GetAvailable()) re.Equal(uint64(150*units.GiB), store.GetAvgAvailable()) - re.Equal(uint64(0), store.GetAvailableDeviation()) store = store.Clone(SetStoreStats(&pdpb.StoreStats{ Capacity: uint64(200 * units.GiB), @@ -47,6 +46,4 @@ func TestStoreStats(t *testing.T) { re.Equal(uint64(160*units.GiB), store.GetAvailable()) re.Greater(store.GetAvgAvailable(), uint64(150*units.GiB)) re.Less(store.GetAvgAvailable(), uint64(160*units.GiB)) - re.Greater(store.GetAvailableDeviation(), uint64(0)) - re.Less(store.GetAvailableDeviation(), uint64(10*units.GiB)) } diff --git a/server/statistics/store_collection.go b/server/statistics/store_collection.go index aa98561c044..416d23916cb 100644 --- a/server/statistics/store_collection.go +++ b/server/statistics/store_collection.go @@ -119,8 +119,6 @@ func (s *storeStatistics) Observe(store *core.StoreInfo, stats *StoresStats) { storeStatusGauge.WithLabelValues(storeAddress, id, "store_available").Set(float64(store.GetAvailable())) storeStatusGauge.WithLabelValues(storeAddress, id, "store_used").Set(float64(store.GetUsedSize())) storeStatusGauge.WithLabelValues(storeAddress, id, "store_capacity").Set(float64(store.GetCapacity())) - storeStatusGauge.WithLabelValues(storeAddress, id, "store_available_avg").Set(float64(store.GetAvgAvailable())) - storeStatusGauge.WithLabelValues(storeAddress, id, "store_available_deviation").Set(float64(store.GetAvailableDeviation())) // Store flows. storeFlowStats := stats.GetRollingStoreStats(store.GetID())