- Notifications
You must be signed in to change notification settings - Fork2.6k
Leap Seconds Support#21420
Leap Seconds Support#21420
Uh oh!
There was an error while loading.Please reload this page.
Conversation
tarekgh commentedDec 6, 2018
@jkotas this is just porting what we have done in the full framework. Also, I have created a commit for corert we can use when we are mirroring this change theretarekgh/corert@f79f7c8 could you please take a look at both and let me know if you have any comment? I have tested this on coreclr, corert and ProjectN native and Win32. I did the testing on Windows version which support leaps seconds with inserting some fake leap seconds to the system. |
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
jkotas commentedDec 6, 2018
Is there going to be a matching PR with the tests in CoreFX? |
Uh oh!
There was an error while loading.Please reload this page.
tarekgh commentedDec 7, 2018
We already have tests for DateTime/DateTimeOffset exercise Now, UtcNow. Writing any test specific for testing with leap seconds will not have any effect because we'll have to run on a machine support leap seconds (i.e. RS5) and the system will have a leaps seconds which we don't have any so far. This will be interesting more when we get in the future a leap seconds. |
jkotas commentedDec 7, 2018
There are two separate problems:
|
tarekgh commentedDec 7, 2018
I'll write a test for that but I'll not expect this test will fail now and the possibility to fail in the future will be low. I understand your point and would be good to have it to catch if we would have a problem. |
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
| </ItemGroup> | ||
| <ItemGroupCondition="'$(TargetsWindows)' == 'true'"> | ||
| <CompileInclude="$(BclSourcesRoot)\System\DateTime.Windows.cs" /> | ||
| <CompileInclude="shared/Interop/Windows/NtDll/Interop.NtQuerySystemInformation.cs" /> |
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 should be in the project in the shared partition
| [MethodImplAttribute(MethodImplOptions.InternalCall)] | ||
| internalstaticexternboolSystemTimeToSystemFileTime(refFullSystemTimetime,reflongfileTime); | ||
| internalstaticexternboolSystemTimeToSystemFileTime(refInterop.Kernel32.SYSTEMTIMEtime,outlongfileTime); |
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.
The first argument can bein Interop.Kernel32.SYSTEMTIME
| [DllImport(JitHelpers.QCall,CharSet=CharSet.Unicode)] | ||
| internalstaticexternboolIsLeapSecondsSupportedSystem(); | ||
| internalstaticexternboolValidateSystemTime(refInterop.Kernel32.SYSTEMTIMEtime,boollocalTime); |
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.
The first argument can bein
| FullSystemTimetime=newFullSystemTime(); | ||
| if(SystemFileTimeToSystemTime(fileTime,reftime)) | ||
| FullSystemTimetime; | ||
| if(SystemFileTimeToSystemTime(fileTime,outtime)) |
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.
Nit:if (SystemFileTimeToSystemTime(fileTime, out FullSystemTime time))
| longfileTime; | ||
| FullSystemTimetime=newFullSystemTime(ticks); | ||
| if(SystemTimeToSystemFileTime(reftime,reffileTime)) | ||
| if(SystemTimeToSystemFileTime(reftime.systemTime,outfileTime)) |
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.
Nit:if (SystemTimeToSystemFileTime(ref time.systemTime, out long fileTime))
| internalstaticexternboolValidateSystemTime(refInterop.Kernel32.SYSTEMTIMEtime,boollocalTime); | ||
| [MethodImplAttribute(MethodImplOptions.InternalCall)] | ||
| internalstaticexternboolSystemFileTimeToSystemTime(longfileTime,outFullSystemTimetime); |
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 there a reason why we call some of these thingsSystemFileTime? There isSYSTEMTIME andFILETIME today, but there is no SystemFileTime today.
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 was trying to have it clear FILETIME is always a system file time. if you think this is confusing, I can change it.
| { | ||
| FCALL_CONTRACT; | ||
| if (::SystemTimeToFileTime(time, (LPFILETIME) pFileTime)) |
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 does not need if - can just return the value returned by SystemTimeToFileTime.
BOOL ret = ::SystemTimeToFileTime(...FC_RETURN_BOOL(ret);| returnnewDateTime(universalTicks,DateTimeKind.Utc); | ||
| } | ||
| publiclongToFileTimeUtc(){ |
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.
Nit:{ should be on a new line
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.
Those was a copy and paste from other file. I'll fix them.
| } | ||
| ticks-=FileTimeOffset; | ||
| if(ticks<0){ |
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.
Same
| hundredNanoSecond=0; | ||
| } | ||
| internalInterop.Kernel32.SYSTEMTIMEsystemTime; |
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.
The coding convention is to place the fields first.
| } | ||
| } | ||
| publicstaticDateTimeFromFileTimeUtc(longfileTime) |
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.
The only difference between Windows and Unix versions of FromFileTimeUtc and ToFileTimeUtc is the callout to the special method method for leap seconds. Should we have keep it in the shared and have a dummy method on Unix?
Also, it may be better to call InternalFromFileTime / InternalToFileTime something likeFromFileTimeUtcLeapSecondsAware / ToFileTimeUtcLeapSecondAware.
jkotas commentedDec 8, 2018
Do you have the number for performance hit that the methods like I think we had it in one of the offline conversations ... it would be useful to have the number on here too. |
jkotas commentedDec 8, 2018
Looks good to me otherwise |
tarekgh commentedDec 8, 2018
I don't have the exact numbers here and also I am using a VM for my leap seconds testing. but I have tested it and we always reporting the time on the same milliseconds boundary. Here example for what I was doing: SYSTEMTIMEst=newSYSTEMTIME();GetSystemTime(refst);DateTimedt=DateTime.UtcNow;Console.WriteLine($"<{st.wHour:D2}:{st.wMinute:D2}:{st.wSecond:D2}.{st.wMillisecond:D2}> .... [{dt.Hour:D2}:{dt.Minute:D2}:{dt.Second:D2}.{dt.Millisecond:D2}]"); Note that we still reporting the precise time as we used to do even in leap seconds system. the only extra perf is just the time we use till we return. I can do the measurements later to get the exact numbers. note that we already have a perf tests for this too. anyway, let me know if you want to wait not merging the change till we do that or we case merge and do the measurements later. if we want to wait, I'll hold this changes till next year. |
jkotas commentedDec 8, 2018
I do not think you need to block on this. |
tarekgh commentedDec 8, 2018
test Windows_NT x64 Checked Innerloop Build and Test (Jit - TieredCompilation=0) |
tarekgh commentedDec 8, 2018
thanks@jkotas for your review and comments. I will wait preparing the changes for corert too and test it so we'll be ready when we merge. I'll let you know when I have it ready to take a quick look there too. |
tarekgh commentedDec 8, 2018
here is the delta changes in corert repo tootarekgh/corert@b503742 i have tested it with PN too. after reviewing the delta, I'll squash moth commits in corert to one so it will be easy to use. |
tarekgh commentedDec 8, 2018
Thanks a lot@jkotas for your review. I have updated the corert too and squashed the commits into one committarekgh/corert@389615a |
* Leap Seconds Support* Address Feedback* More feedback addressingSigned-off-by: dotnet-bot <dotnet-bot@microsoft.com>
tarekgh commentedDec 8, 2018
I added a comment too on corert changetarekgh/corert@389615a#r31609074 may be we need to apply. |
* Leap Seconds Support* Address Feedback* More feedback addressingSigned-off-by: dotnet-bot <dotnet-bot@microsoft.com>
tarekgh commentedDec 9, 2018
@Anipik I am noticing there is no corert mirroring PR opened for this one. Is it expected? |
Anipik commentedDec 9, 2018
@tarekgh it is expected in the sense that there can be only one open mirror pr in a repo at any time. |
tarekgh commentedDec 9, 2018
Thanks@Anipik |
* Leap Seconds Support* Address Feedback* More feedback addressingSigned-off-by: dotnet-bot <dotnet-bot@microsoft.com>
* Leap Seconds Support* Address Feedback* More feedback addressingSigned-off-by: dotnet-bot <dotnet-bot@microsoft.com>
* Leap Seconds Support* Address Feedback* More feedback addressing
* Leap Seconds Support* Address Feedback* More feedback addressingSigned-off-by: dotnet-bot <dotnet-bot@microsoft.com>
* Leap Seconds Support* Address Feedback* More feedback addressingCommit migrated fromdotnet/coreclr@98e4995
Port the leap seconds changes done in the full framework to net core.