-
Notifications
You must be signed in to change notification settings - Fork 21.4k
metrics: Synchronous metrics #29775
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
Open
Open
metrics: Synchronous metrics #29775
+155
−246
Conversation
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
@zeim839
zeim839
force-pushed
the
synchronous-metrics
branch
from
May 14, 2024 12:15
e061514 to
25d2746
Compare
@zeim839
zeim839
changed the title
(削除) Synchronous metrics (削除ここまで)
(追記) metrics: Synchronous metrics (追記ここまで)
May 14, 2024
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.
Uh oh!
There was an error while loading. Please reload this page.
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.