This repository was archived by the owner on Jan 23, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
make DateTime.UtcNow 5% faster to minimize the leap second performance impact #26046
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
…ap second performance regression impact, related to #25728
EgorBo
reviewed
Aug 7, 2019
tarekgh
approved these changes
Aug 7, 2019
jkotas
reviewed
Aug 7, 2019
danmoseley
reviewed
Aug 7, 2019
gfoidl
reviewed
Aug 8, 2019
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 more micro-optimizations.
Thanks for all the suggested micro-optimizations, I was able to improve the time by 0.5% |
Given the regression from 2.2 was so much larger, my assumption is that it is not worth porting this into 3.0. |
May be it is worth to track this for 3.1? |
Our bar right now is a little bit lower or the same as the bar we will use for 3.1. So if we don't take it for 3.0 we would not take it for 3.1. |
@danmosemsft thanks for the clarification. |
picenka21
pushed a commit
to picenka21/runtime
that referenced
this pull request
Feb 18, 2022
…e impact (dotnet/coreclr#26046) * make few methods used by DateTime.UtcNow inlinable to minimize the leap second performance regression impact, related to dotnet/coreclr#25728 * apply suggested micro-optimizations Commit migrated from dotnet/coreclr@4450e5c
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Today I've again profiled #25728 and was looking for some ways of lowering the regression.
I started with reading the source code of
FileTimeToSystemTime
andRtlpTimeToTimeFields
methods. TheRtlpTimeToTimeFields
takes care of leap second support, it knows all leap seconds and knows how to handle the positive and negative ones. Copying this logic from OS to .NET makes obviously no sense, it's too complex and too expensive to maintain.By inlining some small methods that are called by
DateTime.UtcNow
I was able to make it 5% faster. It ain't much, but that's all I could do.Before:
After:
And yes, all the
[MethodImpl(MethodImplOptions.AggressiveInlining)]
were really needed. Moving the throws toThrowHelper
was not enough to get those methods inlined./cc @danmosemsft