metrics: Synchronous metrics#29775
Closed
zeim839 wants to merge 4 commits intoethereum:masterfrom
Closed
Conversation
e061514 to
25d2746
Compare
Contributor
|
Closing as stale. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull-request is based on #27918, which was not accepted because go-ethereum/metrics was being refactored at the time.
It removes concurrent EWMAs and Meters; rates are synchronously computed whenever
Update()orSnapshot()are called. We introduce sampling periods to imitate clock ticks: events arriving within a 5s period are accumulated in an 'uncounted' variable, which is used to calculate the EWMA per-second rate once the 5s period elapses.Consequently, Timer and Meter (which use EWMAs)
Stop()'s are removed because they are not handled by a concurrent routine. To maintain consistency,Meteris also modified so that its rateMean is updated only once per 5s (i.e. it changes in tandem with the underlying EWMAs):Testing has also been modified, such that expected EWMA values are calculated by unit tests instead of having to cross-check hardcoded values.
Why?
In the worst case, complexity remains the same and you're computing EWMAs every 5 seconds (but without a separate goroutine).
In the best case, stale EWMAs are garbage collected (you dont have to worry about calling
Stop()) and you've saved yourself some processing power.