Replace Task.Delay, which has only 15ms or so resolution, with an alternative, high-performance timer #17
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.
Fixes #15.
It appears that the issue in #15 is caused by how
Task.Delay
is highly imprecise (with, depending on system, a 15ms resolution). Replacing it with what seems to be a possible high-resolution alternative (see this IoT helper code: dotnet/iot#235), which usesSpinWait
andSpinOnce
to delay the task, the "performance" issues disappeared as snow in the sun.The expected timings of these smoke-tests should be roughly the amount of tasks divided by the average random delay configured for each task (this is a test feature only!).
It brings the offending tests from 15s runtime or more down to 600ms, with double the amount of test-tasks.
There are still some questions, mainly why does the
spinwait.SpinOnce
cause a 15ms delay per task on average?TLDR: we now have a microsecond task-delay timer 😆!