-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
Do ConfigureAwait(false) #10164
Comments
@davidfowl @roji It would be great to get your perspectives on this. |
For the Npgsql perspective... In general, libraries need run with a null synchronization context to allow their code to execute on the thread pool (and not, say, to be restricted to UI thread). Npgsql originally had There's actually a path inside Npgsql where code needs to execute on a special internal thread (to avoid a dependency on the threadpool, which sometimes creates deadlocks). In order to force this code to callback onto this internal thread, a special sync context is used (see SingleThreadSynchronizationContext.cs in case you're interested). This led to an odd situation: I need to be able to run the same code, sometimes with sync context null (the normal case) and sometimes with my own special sync context (the special case), but if you put Note that the need to run the same methods with both sync context null and a specific sync context seems quite unique to Npgsql and I don't expect many other libraries to require this (I can elaborate on the Npgsql issue if you're interested). It does clean up lots of Let me know if you want any more info. |
This was discussed in triage with the following conclusions:
Overall, we are not going to do anything immediately or generally on this, but based on other perf testing we could look at making targeted changes. |
@ajcvickers are you currently doing ConfigureAwait everywhere in the code base? |
@davidfowl No, we don't call ConfigureAwait--that's what this discussion is about. |
But it's closed now 😄 . Are we going to? |
@davidfowl No, we'll stick with our original decision to not call it. (reasoning above) |
I'm not sure those points are all entirely reasonable. How did you test the performance differences? What sync context did you use?
That's not true. If there's a sync context that serializes execution of continuations (like ASP.NET does) and you have 2 tasks that are interdependent then it's possible to cause a deadlock without explicitly calling .Wait. It's not always about performance, it might actually be about correctness. |
We held a new referendum on this issue. The outcome from this "People's Vote" is that we're going to do it. The sync context concerns are much less significant for .NET Core, and .NET Core is the future. |
@ajcvickers I can take this. |
Go for it! |
Removing milestone to discuss punting. |
Closing in favor of #10164 |
Set up Microsoft.CodeAnalysis.FxCopAnalyzers with only the ConfigureAwait rule enabled. Closes #10164
Set up Microsoft.CodeAnalysis.FxCopAnalyzers with only the ConfigureAwait rule enabled. Closes #10164
* [release/5.0-preview6] Update dependencies from dotnet/arcade (#21111) * Update dependencies from https://github.com/dotnet/arcade build 20200530.1 Microsoft.DotNet.Arcade.Sdk , Microsoft.DotNet.Helix.Sdk From Version 5.0.0-beta.20261.9 -> To Version 5.0.0-beta.20280.1 * [master] Update dependencies from dotnet/arcade (#21091) * Update dependencies from https://github.com/dotnet/arcade build 20200528.4 Microsoft.DotNet.Arcade.Sdk , Microsoft.DotNet.Helix.Sdk From Version 5.0.0-beta.20261.9 -> To Version 5.0.0-beta.20278.4 * Update dotnet on helix Co-authored-by: dotnet-maestro[bot] <dotnet-maestro[bot]@users.noreply.github.com> Co-authored-by: Brennan <[email protected]> Co-authored-by: dotnet-maestro[bot] <dotnet-maestro[bot]@users.noreply.github.com> Co-authored-by: dotnet-maestro[bot] <42748379+dotnet-maestro[bot]@users.noreply.github.com> Co-authored-by: Brennan <[email protected]> * Return ValueTask in loggers and interceptors (#21152) (#21158) Closes #21109 (cherry picked from commit 9f316e5) * Add ConfigureAwait(false) (#21110) (#21185) Set up Microsoft.CodeAnalysis.FxCopAnalyzers with only the ConfigureAwait rule enabled. Closes #10164 (cherry picked from commit e1c9a3a) Co-authored-by: dotnet-maestro[bot] <42748379+dotnet-maestro[bot]@users.noreply.github.com> Co-authored-by: dotnet-maestro[bot] <dotnet-maestro[bot]@users.noreply.github.com> Co-authored-by: Brennan <[email protected]> Co-authored-by: Shay Rojansky <[email protected]>
Creating an issue so that we can chat about this, and decide (again) whether we should be doing anything differently.
See aspnet/SignalR#545 for some context. This was found by @anpete while trying to understand what Npgsql is doing around it.
We came to what we have (practically not doing anything) through a long and painful analysis, but unfortunately it is very hard (for me at least) to remember or find exactly what we decided.
The text was updated successfully, but these errors were encountered: