Skip to content

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

Merged
Stephan T. Lavavej (StephanTLavavej) merged 4 commits into
microsoft:mainfrom
fsb4000:fix2085
Aug 17, 2021
Merged

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

Conversation

@fsb4000

@fsb4000 Igor Zhukov (fsb4000) commented Jul 30, 2021

Copy link
Copy Markdown
Contributor

Closes #2085

Co-authored-by:  Bruce Dawson <brucedawson@chromium.org>
@fsb4000
Igor Zhukov (fsb4000) requested a review from a team as a code owner July 30, 2021 02:14
@fsb4000 Igor Zhukov (fsb4000) changed the title optimize chrono:steady_clock::now() <chrono>: optimize chrono::steady_clock::now() Jul 30, 2021
Igor Zhukov (fsb4000) and others added 2 commits July 30, 2021 12:21
Co-authored-by:  Bruce Dawson <brucedawson@chromium.org>
@randomascii

Copy link
Copy Markdown
Contributor

Looks good. Land it!

@fsb4000

Copy link
Copy Markdown
Contributor Author

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 <gutenev@gmail.com>
@StephanTLavavej

Copy link
Copy Markdown
Member

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

@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

Charlie Barto (@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
Stephan T. Lavavej (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
Igor Zhukov (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