-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
Optimize System.DateTime #45479
Optimize System.DateTime #45479
Conversation
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 one area label. |
Related to #44771 |
src/coreclr/src/System.Private.CoreLib/src/System/DateTime.Windows.CoreCLR.cs
Outdated
Show resolved
Hide resolved
{ | ||
throw new InvalidCastException(SR.Format(SR.InvalidCast_FromTo, "DateTime", "Double")); | ||
} | ||
bool IConvertible.ToBoolean(IFormatProvider? provider) => throw InvalidCast(nameof(Boolean)); |
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 do not think it is worth optimizing these using ThrowHelper.
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 isn't an optimization but just reducing code size/duplication.
@pentp I am off properly will not be able to go deeper in this review. I am seeing you are touching the leap seconds handling in the code and I am not sure if the changes would affect that. did you test with a leap seconds on in any system? |
@jkotas would be good to not merge this till it is carefully reviewed and tested with leap seconds. |
Agree. I won't merge this before you and @GrabYourPitchforks sign off on this. |
// Auto-generated message 69e114c which was merged 12/7 removed the intermediate src/coreclr/src/ folder. This PR needs to be updated as it touches files in that directory which causes conflicts. To update your commits you can use this bash script: https://gist.github.com/ViktorHofer/6d24f62abdcddb518b4966ead5ef3783. Feel free to use the comment section of the gist to improve the script for others. |
Hi @pentp, do you have a chance to resolve the merge conflict? |
Yes, I'll rebase and fix the conflicts. |
Thanks a lot.
I didn't closely review your original changes so I am not clear why need to intercept the calls to IsValidTimeWithLeapSeconds? is it part of the optimization we are trying to do here? or this is just to do some validation? If this is not related to the optimization, then I would say let's focus to get the optimization first and have some perf numbers how much we are gaining. |
@pentp sorry to ping you again. Would you be able to get this soon? I am asking because we are trying to close long opened PR's. Thanks! |
Rebased and resolved conflicts. Test failures seem to be #47374. |
Thanks @pentp. I'll take a look soon. |
src/libraries/System.Private.CoreLib/src/System/DateTime.Windows.cs
Outdated
Show resolved
Hide resolved
@pentp thanks a lot. The changes LGTM. As it looks this changes will give us some perf gain. do we have some perf numbers for that. (at least in the basic scenarios with DateTime)? |
For |
src/libraries/System.Private.CoreLib/src/System/DateTime.Windows.cs
Outdated
Show resolved
Hide resolved
I got through about half of this so far, and will review further tomorrow. |
@pentp did you have time to address the remaining comments? I think we should be good to go after that. |
@pentp thanks for getting this done. this is amazing. |
Makes DateTime.UtcNow about 5% faster (over 90% time is spent in OS calls now).
Also changed most of DateTime calculations to use unsigned integers.