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

Handle early wakeup of counter loop #57170

Merged
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ internal sealed class CounterGroup
private readonly EventSource _eventSource;
private readonly List<DiagnosticCounter> _counters;
private static readonly object s_counterGroupLock = new object();
private static readonly TimeSpan s_minimumPollingInterval = TimeSpan.FromSeconds(1);
josalem marked this conversation as resolved.
Show resolved Hide resolved

internal CounterGroup(EventSource eventSource)
{
Expand Down Expand Up @@ -252,7 +253,8 @@ private void OnTimer()
{
_timeStampSinceCollectionStarted = now;
TimeSpan delta = now - _nextPollingTimeStamp;
if (delta > TimeSpan.Zero && _pollingIntervalInMilliseconds > 0)
delta = s_minimumPollingInterval > delta ? s_minimumPollingInterval : delta;
josalem marked this conversation as resolved.
Show resolved Hide resolved
if (_pollingIntervalInMilliseconds > 0)
_nextPollingTimeStamp += TimeSpan.FromMilliseconds(_pollingIntervalInMilliseconds * Math.Ceiling(delta.TotalMilliseconds / _pollingIntervalInMilliseconds));
}
}
Expand Down