- Notifications
You must be signed in to change notification settings - Fork5.2k
Delete DateTime FCalls and switch to fully managed implementation#46690
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
Dotnet-GitSync-Bot commentedJan 7, 2021
I couldn't figure out the best area label to add to this PR. If you have write-permissions please help me learn by adding exactly onearea label. |
jkotas commentedJan 7, 2021
Now that we have On Windows without leap time second support, this change makes DateTime.UtcNow about 5% faster. On Windows with lead time second support, the performance impact of this change is in the noise range. This change includes the straightforward parts from#44771. One of my motivation for doing this sooner rather than later is to start getting real-world millage on |
| FullSystemTimetime; | ||
| GetSystemTimeWithLeapSecondsHandling(&time); | ||
| if(Interop.Kernel32.FileTimeToSystemTime(&fileTime,&time.systemTime)!=Interop.BOOL.FALSE) |
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.
Some of the methods were split into multiple parts to make the FCalls work. I have undone the split since it is no longer needed.
| #if!CORECLR | ||
| internalstaticreadonlybools_systemSupportsPreciseSystemTime=SystemSupportsPreciseSystemTime(); | ||
| privatestaticunsafereadonlydelegate* unmanaged[SuppressGCTransition]<long*,void>s_pfnGetSystemTimeAsFileTime=GetGetSystemTimeAsFileTimeFnPtr(); |
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.
I admit when support was added for function pointers I was not expecting us to be able to make such extensive use of it. Cool.
| if(time->systemTime.Second>59) | ||
| // Retry this check several times to reduce chance of false negatives due to thread being rescheduled | ||
| // at wrong time. | ||
| for(inti=0;i<10;i++) |
stephentoubJan 7, 2021 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
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.
This retry loop wasn't present previously, was it? You're just adding it proactively as you expect it could be an issue?
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, I am adding it proactively to make this check more robust. I think we are incorrectly falling back to imprecise UtcNow like one in million runtime startups without this loop. The loop will exit in first iteration on well-behaving systems.
tarekgh left a comment
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.
jkotas commentedJan 7, 2021
tarekgh commentedJan 7, 2021
I am seeing the PR has very minor such micro optimization (converting some long to ulong). would it make sense just to added these here instead? it is not much and also I will expect the perf gain from these would be small to justify the change. no pushing here though. |
srxqds commentedJan 7, 2021
what effect on monovm? |
jkotas commentedJan 8, 2021
I have actually started doing that originally, but then the delta kept growing and the PR got harder to review. I prefer to take it smaller step at a time.
MonoVM has been on the managed implementation already. This change is basically switching CoreCLR to the implementation that MonoVM has been using. #46690 (comment) should improve the performance for MonoVM a bit. The improvement is likely in the noise range. |
No description provided.