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

Perf: Remove double fetch of domain name #366

Merged
merged 1 commit into from
Jan 6, 2020

Conversation

Wraith2
Copy link
Contributor

@Wraith2 Wraith2 commented Jan 3, 2020

While profiling the managed SNI implementation I got distracted by the amount of time it takes to get a connection from the pool. I found this simple change which on windows removes 2 pinvokes and a string allocation by getting the user domain name only once and reusing it.

comparison

If we were doing direct invokes instead of using System.Environment wrappers we could do it in 2-3 pinvokes and avoid a couple of string allocations. We would have to be platform specific though and I'd prefer to keep this implementation fully portable if possible. Note that the Environment.UserName and UseDomainName functions do not read environment variables the pinvoke directly so they are compatible with impersonation, any replacement would need to have the same property.

@cheenamalhotra cheenamalhotra added this to the 2.0.0-preview1 milestone Jan 6, 2020
@cheenamalhotra cheenamalhotra merged commit c636056 into dotnet:master Jan 6, 2020
@Wraith2 Wraith2 deleted the perf-managedpoolspeed branch January 8, 2020 19:13
@cheenamalhotra cheenamalhotra added the 📈 Performance Use this label for performance improvement activities label Jan 20, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
📈 Performance Use this label for performance improvement activities
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants