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: Lazy init reconnect lock when needed #379

Merged
merged 1 commit into from
Feb 5, 2020

Conversation

Wraith2
Copy link
Contributor

@Wraith2 Wraith2 commented Jan 12, 2020

In ideal situations the reconnection lock isn't needed most of the time but it currently always allocated unused and then cleaned up by the GC. This PR defers the creation of the lock object used in reconnections until just before it is needed. It uses interlocked to ensure that only one concurrent call can assign to the variable and the semantics of compareexchange mean that all of them will observe the same value once one has assigned it.

Copy link
Contributor

@David-Engel David-Engel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@cheenamalhotra cheenamalhotra merged commit ce76eb0 into dotnet:master Feb 5, 2020
@cheenamalhotra cheenamalhotra added this to the 2.0.0-preview2 milestone Feb 5, 2020
@cheenamalhotra cheenamalhotra added the 📈 Performance Issues that are targeted to performance improvements. label Feb 5, 2020
@Wraith2 Wraith2 deleted the perf-lazyinitreconnectlock branch February 5, 2020 23:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
📈 Performance Issues that are targeted to performance improvements.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants