-
Notifications
You must be signed in to change notification settings - Fork 1k
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
.NET 6: PeriodicTimer
scheduler replacement for dedicated thread
#6435
.NET 6: PeriodicTimer
scheduler replacement for dedicated thread
#6435
Conversation
Testing this on the build server first to see if the .NET 6 impl falls apart compared to .NET Framework and .NET Core 3.1 |
Measured clock drift for
|
I must have written something wrong in this implementation of the timer - it is taking an eternity for ticks to be processed. |
* Fix implementation and code cleanup * Fix clock drift calculation
Measured clock drift on old code path in this PR:
|
Measured clock drift on new code path in this PR:
|
@Arkatufus have approximately 20 test failures on this PR - can you run locally? |
will do |
@@ -52,6 +52,9 @@ public HashedWheelTimerScheduler(Config scheduler, ILoggingAdapter log) : base(s | |||
if (SchedulerConfig.IsNullOrEmpty()) | |||
throw ConfigurationException.NullOrEmptyConfig<HashedWheelTimerScheduler>(); | |||
|
|||
if (!Util.MonotonicClock.IsHighResolution) | |||
Log.Warning("HashedWheelTimerScheduler depends on the availability of high resolution performance counter which is not available in this system"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When would the high resolution timer not be available?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When the runtime could not provide one
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it not able to provide one on the build server?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No idea, but its there as a preventative measures, just in case this happens in the future
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Feedback for @Arkatufus
|
||
_shutdownTimeout = SchedulerConfig.GetTimeSpan("akka.scheduler.shutdown-timeout", null); | ||
_shutdownTimeout = SchedulerConfig.GetTimeSpan("akka.scheduler.shutdown-timeout", TimeSpan.Zero); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So this will result in an instant shutdown?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, it would, because TimeSpan.Zero
is an illegal value
|
||
static MonotonicClock() | ||
{ | ||
TicksFrequency = (double)TicksInSecond / Stopwatch.Frequency; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this here? Please add a comment in the code to explain, as it's non-obvious why this is needed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TickFrequency
is a constant scaling value to normalize operating system reported performance counter clock tick to .NET internal definition of a "tick".
Stopwatch.ElapsedTicks
returns the raw operating system level performance clock ticks, which is not the same definition as .NET DateTime
or TimeSpan
definition.
.NET DateTime
or TimeSpan
definition of a "tick" is 100 nanosecond, which is true for all windows platforms that support performance counter clock (win8+). This is not true for linux platforms, their definition of a "tick" is 1 nanosecond.
…akka.net into threading-timer-scheduler
Can you run the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
RemotePingPong BenchmarkMedian value of 5 benchmark runs Benchmark ComputerOSVersion: Microsoft Windows NT 10.0.19045.0 Dev Branch
New Code
|
Benchmark numbers look good |
Changes
close #4031
Checklist
For significant changes, please ensure that the following have been completed (delete if not relevant):
Latest
dev
BenchmarksInclude data from the relevant benchmark prior to this change here.
This PR's Benchmarks
Include data from after this change here.