Skip to content

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
edwardneal added a commit to edwardneal/SqlClient that referenced this pull request Sep 11, 2025
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