You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
ActivitySource started activities aren't using an accurate utcnow on framework. #45111
internalstaticDateTimeGetUtcNow(){// DateTime.UtcNow accuracy on .NET Framework is ~16ms, this method// uses combination of Stopwatch and DateTime to calculate accurate UtcNow.vartmp=timeSync;// Timer ticks need to be converted to DateTime tickslongdateTimeTicksDiff=(long)((Stopwatch.GetTimestamp()-tmp.SyncStopwatchTicks)*10000000L/(double)Stopwatch.Frequency);// DateTime.AddSeconds (or Milliseconds) rounds value to 1 ms, use AddTicks to prevent itreturntmp.SyncUtcNow.AddTicks(dateTimeTicksDiff);}
... My first question is going to be "are we sure this is still the case"? The comment implies that netfx is still pulling from a lower-accuracy clock in Windows (since this used to be a common limitation for all OSs/languages). Is switching to the better clock something on the table for netfx, if it is?
@cg110 although we maintain and support the Full Framework, but we are not actively doing any development there. Also, I don't think Activity timestamps is meant to be accurate to leas than 1 milliseconds.
@Clockwork-Muse we know on Windows UtcNow is taking sometime to execute, this is because we have to ensure the time is syned with the system when having a leap seconds. Otherwise it'll be shifted.
@cg110 I don't think this will make much difference. I have pointed at what is the cause of that. Also, as I mentioned this is unlikely to be fixed in the full framework but we are looking at that in the .NET future releases. Thanks!
I'm puzzled, I'd just like the DateTime.utcnow changed to GetUtcNow() to match the diagnosticsource behaviour. Is that not doable to give better accuracy? It's already used in the stop/dispose.
Is that not going to be fixed because it's framework? Utcnow is inaccurate to 16ms so bad for timing things
@cg110 in general it depends on where we can fix this. If we need to fix UtcNow, then the fix will not be in Full Framework. If the fix would be in System.Diagnostics.DiagnosticSource, then the fix will be spanned all frameworks and you'll get it as this is NuGet package which can be used in the Full Framework too. I'll reactivate this issue to track if anything can be done in System.Diagnostics.DiagnosticSource not depending on UtcNow.
Activity
cijothomas commentedon Nov 23, 2020
Clockwork-Muse commentedon Nov 23, 2020
On corefx:
On netfx:
... My first question is going to be "are we sure this is still the case"? The comment implies that netfx is still pulling from a lower-accuracy clock in Windows (since this used to be a common limitation for all OSs/languages). Is switching to the better clock something on the table for netfx, if it is?
tarekgh commentedon Nov 23, 2020
@cg110 although we maintain and support the Full Framework, but we are not actively doing any development there. Also, I don't think Activity timestamps is meant to be accurate to leas than 1 milliseconds.
@Clockwork-Muse we know on Windows UtcNow is taking sometime to execute, this is because we have to ensure the time is syned with the system when having a leap seconds. Otherwise it'll be shifted.
Closing it as a duplicate to #13091
cg110 commentedon Nov 23, 2020
Reference source suggests that fx is still using the less accurate https://docs.microsoft.com/en-us/windows/win32/api/sysinfoapi/nf-sysinfoapi-getsystemtimeasfiletime
There is https://docs.microsoft.com/en-us/windows/win32/api/sysinfoapi/nf-sysinfoapi-getsystemtimepreciseasfiletime but it's unclear if it's good enough.
DateTime.utcnow is documented as being inaccurate see https://docs.microsoft.com/en-us/dotnet/api/system.datetime.utcnow?view=net-5.0#remarks
Some discussion here: #5883
And the fix to core: dotnet/coreclr#9736
tarekgh commentedon Nov 23, 2020
@cg110 I don't think this will make much difference. I have pointed at what is the cause of that. Also, as I mentioned this is unlikely to be fixed in the full framework but we are looking at that in the .NET future releases. Thanks!
cg110 commentedon Nov 23, 2020
I'm puzzled, I'd just like the DateTime.utcnow changed to GetUtcNow() to match the diagnosticsource behaviour. Is that not doable to give better accuracy? It's already used in the stop/dispose.
Is that not going to be fixed because it's framework? Utcnow is inaccurate to 16ms so bad for timing things
tarekgh commentedon Nov 23, 2020
@cg110 in general it depends on where we can fix this. If we need to fix UtcNow, then the fix will not be in Full Framework. If the fix would be in System.Diagnostics.DiagnosticSource, then the fix will be spanned all frameworks and you'll get it as this is NuGet package which can be used in the Full Framework too. I'll reactivate this issue to track if anything can be done in System.Diagnostics.DiagnosticSource not depending on UtcNow.
28 remaining items
ericstj commentedon Dec 11, 2020
Looks like the package wasn't added to the build for servicing. @Anipik can you do this for 5.0.2?
Anipik commentedon Dec 11, 2020
yep i will add that
Anipik commentedon Dec 14, 2020
I added the package, we can keep this open until we ship the package
cijothomas commentedon Dec 15, 2020
@Anipik When does 5.0.2 gets released to nuget?
Anipik commentedon Dec 15, 2020
It will be shipped around second week of january
tarekgh commentedon Jan 20, 2021
The package is now released. https://www.nuget.org/packages/System.Diagnostics.DiagnosticSource/5.0.1