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

index-parser: get the time in a cheaper way #1798

Merged

Conversation

neerajsi-msft
Copy link

DateTime.UtcNow spends a lot of time getting a very precise system time, including leap seconds and interpolation through
QueryPerformanceCounter.

Use Environment.TickCount (milliseconds since boot) instead, since that just retrieves a value in shared memory that the kernel keeps up to date. This value is still suitable for controlling how much log output index parsing produces.

This UtcNow call consumes 15% of the time under GitIndexParser.ParseIndex.

See the UtcNow implementation at:
See https://github.com/dotnet/runtime/blob/master/src/libraries/System.Private.CoreLib/src/System/DateTime.Windows.cs.

UtcNow spends a lot of time getting a very precise system time,
including leap seconds and interpolation through
QueryPerformanceCounter.

Use Environment.TickCount (milliseconds since boot) instead, since that
just retrieves a value in shared memory that the kernel keeps up to
date. This value is still suitable for controlling how much log output
index parsing produces.

This UtcNow call consumes 15% of the time under
GitIndexParser.ParseIndex.

See https://github.com/dotnet/runtime/blob/master/src/libraries/System.Private.CoreLib/src/System/DateTime.Windows.cs.
@derrickstolee derrickstolee merged commit 3790eb0 into microsoft:master Feb 13, 2023
@neerajsi-msft neerajsi-msft deleted the neerajsi/read-index-tickcount branch February 13, 2023 19:26
@vdye vdye mentioned this pull request Mar 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants