Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

statistics: abstract MovingAvg (rolling statistics) interface #1843

Merged
merged 3 commits into from
Oct 25, 2019

Conversation

Luffbee
Copy link
Contributor

@Luffbee Luffbee commented Oct 25, 2019

What problem does this PR solve?

There is a RollingStats struct which is actually used to calculate moving average. The new hotspot scheduler will use similar structs to denoise or estimate the cluster status, so it useful to abstract an interface for it.

What is changed and how it works?

Add an interface: MovingAvg. It provides the basic methods: Add() and Get(), and two function may be useful in test: Reset() and Set().
Rename the RollingStats to MedianFilter and modify it to satisfy MovingAvg.

Check List

Tests

  • Unit test

@Luffbee Luffbee added component/schedule Scheduling logic. type/design The issue is related to design. labels Oct 25, 2019
@Luffbee Luffbee requested a review from nolouch October 25, 2019 07:33
Copy link
Contributor

@lhy1024 lhy1024 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

// MedianFilter works as a median filter with specified window size.
// There are at most `size` data points for calculating.
// References: https://en.wikipedia.org/wiki/Median_filter.
type MedianFilter struct {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would we add other MovingAvg?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes.

@Luffbee Luffbee added the status/can-merge Indicates a PR has been approved by a committer. label Oct 25, 2019
@sre-bot
Copy link
Contributor

sre-bot commented Oct 25, 2019

/run-all-tests

@codecov-io
Copy link

Codecov Report

Merging #1843 into master will increase coverage by 0.01%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1843      +/-   ##
==========================================
+ Coverage   78.02%   78.04%   +0.01%     
==========================================
  Files         168      168              
  Lines       17004    17009       +5     
==========================================
+ Hits        13267    13274       +7     
+ Misses       2649     2645       -4     
- Partials     1088     1090       +2
Impacted Files Coverage Δ
server/statistics/store.go 96.07% <100%> (ø) ⬆️
server/statistics/hot_peer.go 100% <100%> (ø) ⬆️
server/statistics/hot_peer_cache.go 89.3% <100%> (ø) ⬆️
server/statistics/util.go 100% <100%> (ø) ⬆️
server/kv/etcd_kv.go 72.72% <0%> (-9.1%) ⬇️
server/tso/tso.go 76.11% <0%> (-1.5%) ⬇️
server/handler.go 53.17% <0%> (-0.49%) ⬇️
server/grpc_service.go 58.35% <0%> (+1.3%) ⬆️
server/schedulers/random_merge.go 62.79% <0%> (+4.65%) ⬆️
server/schedulers/shuffle_hot_region.go 61.79% <0%> (+5.61%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 4ff32a7...5801fb0. Read the comment docs.

@sre-bot sre-bot merged commit 65883ce into tikv:master Oct 25, 2019
@Luffbee Luffbee deleted the rolling-stat-interface branch October 25, 2019 12:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component/schedule Scheduling logic. status/can-merge Indicates a PR has been approved by a committer. type/design The issue is related to design.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants