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

fix(ewma): reduce the chances of fake bandwidth spikes #8

Merged
merged 3 commits into from
Feb 13, 2024

Conversation

Stebalien
Copy link
Member

Ignore updates that are less than 100ms. Otherwise, we could attribute a large amount of bandwidth to a very short period of time and get a huge spike.

The next step will be to split writes up into chunks before we get to the meter.

An alternative is to record the amount of data sent and a time. However, the
current system was chosen precisely to avoid repeatedly asking for the time.

@raulk
Copy link
Member

raulk commented Oct 16, 2019

This makes me uneasy because it introduces a timing condition that summons another class of bugs. How about we break down the act of recording into two methods?

On Meter, a Prerecord() method that returns a pointerless Recording type that is just a time.Time of when the recording started.

On Recording (value receiver), a Record(float64) performs the actual recording.

The whole thing can incur in zero allocs and overcome the ugliness of asking for time with every recording.

@Stebalien
Copy link
Member Author

Stebalien commented Oct 17, 2019 via email

@Stebalien
Copy link
Member Author

Stebalien commented Oct 17, 2019 via email

@Stebalien
Copy link
Member Author

I've pushed a fix for non-monotonic clocks.

Copy link
Contributor

@marten-seemann marten-seemann left a comment

Choose a reason for hiding this comment

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

CI seems very unhappy with this change.

@@ -30,6 +30,9 @@ func SetClock(c clock.Clock) {
cl = c
}

// We tick every second.
var ewmaRate = time.Second
Copy link
Contributor

Choose a reason for hiding this comment

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

const?

Copy link
Member Author

Choose a reason for hiding this comment

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

CI is always unhappy.

ignore updates that are less than 100ms. Otherwise, we could attribute a large
amount of bandwidth to a very short period of time and get a _huge_ spike.
@Stebalien Stebalien merged commit 96a0603 into master Feb 13, 2024
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants