-
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
Change relevant async APIs to return ValueTask instead of Task #15184
Comments
Some general guidance given by @stephentoub:
And specifically about non-generic ValueTask:
Additional thought about abstractions such as IAsyncDisposable/IAsyncEnumerable... in some cases, the API being designed is extremely abstract and has no knowledge of concrete implementations and their perf profile. In these cases adopting ValueTask is the right choice, since it allows a specific implementation to achieve the highest perf possible (e.g. via IValueTaskSource). Within EF Core we generally don't have that kind of abstractions (although we still need to consider IAsyncEnumerable). |
@divega @ajcvickers I think a good next step would be to list some major APIs and discuss concretely. We may want to make a distinction between APIs which never return synchronously (the majority?) and those which may return synchronously. As a good example for the latter, I think there's a clear case for modifying Conversely |
@roji, FYI, your paste of my comments ends up rendering without |
@stephentoub oops, thanks... Edited to make the angle brackets visible, everything does make a bit more sense now :) |
Here's a first pass listing important/public APIs with my opinion of what should be done, any comments welcome. Seems that it should return ValueTask
Seems that it should return Task
Discussion needed
|
Hi-lo generator still allocates (because it uses AsyncLock internally). But the important thing is that all other generators don't. Part of dotnet#15184
Submitted #15232 for |
Hi-lo generator still allocates (because it uses AsyncLock internally). But the important thing is that all other generators don't. Part of dotnet#15184
@roji Looks good; thanks for doing this analysis. |
Hi-lo generator still allocates (because it uses AsyncLock internally). But the important thing is that all other generators don't. Part of dotnet#15184
Hi-lo generator still allocates (because it uses AsyncLock internally). But the important thing is that all other generators don't. Part of dotnet#15184
* {DbContext,DbSet}.FindAsync() * {DbContext,DbSet}.AddAsync() * ValueGenerator API. Hi-lo generator still allocates (because of AsyncLock internally), but all other generators don't. Closes dotnet#15184
* {DbContext,DbSet}.FindAsync() * {DbContext,DbSet}.AddAsync() * ValueGenerator API. Hi-lo generator still allocates (because of AsyncLock internally), but all other generators don't. Closes dotnet#15184
Discussion in design meeting confirms analysis in #15184 (comment), and no additional APIs currently seem like they'd benefit from returning ValueTask. |
@ajcvickers @divega this was missing the 3.0.0-preview4 milestone - added it. |
Following discussion on #14551
The text was updated successfully, but these errors were encountered: