Skip to content
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

<chrono>: optimize chrono::steady_clock::now() #2086

Merged
merged 4 commits into from
Aug 17, 2021

Conversation

fsb4000
Copy link
Contributor

@fsb4000 fsb4000 commented Jul 30, 2021

Closes #2085

@fsb4000 fsb4000 requested a review from a team as a code owner July 30, 2021 02:14
@fsb4000 fsb4000 changed the title optimize chrono:steady_clock::now() <chrono>: optimize chrono::steady_clock::now() Jul 30, 2021
fsb4000 and others added 2 commits July 30, 2021 12:21
Co-authored-by:  Bruce Dawson <[email protected]>
@randomascii
Copy link
Contributor

Looks good. Land it!

@fsb4000
Copy link
Contributor Author

fsb4000 commented Jul 30, 2021

Sorry, I forgot about: https://docs.microsoft.com/en-us/cpp/error-messages/compiler-warnings/compiler-warning-level-3-c4640?view=msvc-160

It's not a big deal. Without static it works with almost same speed. Sometimes even faster.
изображение

stl/inc/chrono Outdated Show resolved Hide resolved
stl/inc/chrono Outdated Show resolved Hide resolved
Co-authored-by: Alex Guteniev <[email protected]>
@StephanTLavavej
Copy link
Member

I indeed observe QPF == 10M on my 4 physical machines, all Win10: #2085 (comment)

@StephanTLavavej StephanTLavavej removed their assignment Aug 10, 2021
@barcharcraz
Copy link
Member

Looks good to me.

I note that in this case the race on the static variable would seem benign, but we like to avoid even those races so since removing the static variable doesn't make much difference I prefer just keeping it removed.

@StephanTLavavej
Copy link
Member

@barcharcraz Magic statics would avoid data races, but we avoid magic statics in product code, see #673 (comment) .

@StephanTLavavej
Copy link
Member

I'm mirroring this to an MSVC-internal PR. Please notify me if any further changes are pushed.

@StephanTLavavej StephanTLavavej merged commit 331ecd5 into microsoft:main Aug 17, 2021
@StephanTLavavej
Copy link
Member

Thanks for optimizing this time-sensitive timing function! 😻 🚀 ⚡

@fsb4000 fsb4000 deleted the fix2085 branch August 17, 2021 02:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
performance Must go faster
Projects
None yet
Development

Successfully merging this pull request may close these issues.

<chrono>: steady_clock::now() is avoidably slow
5 participants