Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.

Use Environment.TickCount instead of DateTime{Offset}.UtcNow in SocketsHttpHandler #35401

Merged
merged 1 commit into from
Feb 19, 2019

Conversation

stephentoub
Copy link
Member

We don't need the accuracy of UtcNow nor the absolute time when getting a time stamp in order to determine whether a connection should be retired; rather, we only need an approximate difference in time. This means the resolution of TickCount is fine, and the worst that happens if a connection happens to be alive for more than its ~49 day period is we may allow the connection to then live even longer than we otherwise would. In exchange, we get a much cheaper mechanism (~20x on Windows) mechanism for computing the connection age.

cc: @geoffkizer

…tsHttpHandler

We don't need the accuracy of UtcNow nor the absolute time when getting a time stamp in order to determine whether a connection should be retired; rather, we only need an approximate difference in time.  This means the resolution of TickCount is fine, and the worst that happens if a connection happens to be alive for more than its ~49 day period is we may allow the connection to then live even longer than we otherwise would.  In exchange, we get a much cheaper mechanism (~20x on Windows) mechanism for computing the connection age.
@geoffkizer
Copy link

Related: It seems like Environment should expose a LongTickCount that calls https://docs.microsoft.com/en-us/windows/desktop/api/sysinfoapi/nf-sysinfoapi-gettickcount64

@geoffkizer
Copy link

@stephentoub stephentoub merged commit dca3972 into dotnet:master Feb 19, 2019
@stephentoub stephentoub deleted the httptickcount branch February 19, 2019 05:38
picenka21 pushed a commit to picenka21/runtime that referenced this pull request Feb 18, 2022
…tsHttpHandler (dotnet/corefx#35401)

We don't need the accuracy of UtcNow nor the absolute time when getting a time stamp in order to determine whether a connection should be retired; rather, we only need an approximate difference in time.  This means the resolution of TickCount is fine, and the worst that happens if a connection happens to be alive for more than its ~49 day period is we may allow the connection to then live even longer than we otherwise would.  In exchange, we get a much cheaper mechanism (~20x on Windows) mechanism for computing the connection age.

Commit migrated from dotnet/corefx@dca3972
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants