Skip to content

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

Merged
StephanTLavavej merged 4 commits into
microsoft:mainfrom
fsb4000:fix2085
Aug 17, 2021
Merged

<chrono>: optimize chrono::steady_clock::now()#2086
StephanTLavavej merged 4 commits into
microsoft:mainfrom
fsb4000:fix2085

Conversation

@fsb4000
Copy link
Copy Markdown
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
Copy Markdown
Contributor

Looks good. Land it!

@fsb4000
Copy link
Copy Markdown
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.
изображение

Comment thread stl/inc/chrono Outdated
Comment thread stl/inc/chrono Outdated
Co-authored-by: Alex Guteniev <[email protected]>
@StephanTLavavej
Copy link
Copy Markdown
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
Copy Markdown
Contributor

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
Copy Markdown
Member

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

@StephanTLavavej
Copy link
Copy Markdown
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
Copy Markdown
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