Skip to content

HTTP/3: Remove AsTask allocations #38559

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

Merged
merged 1 commit into from
Nov 22, 2021
Merged

Conversation

JamesNK
Copy link
Member

@JamesNK JamesNK commented Nov 21, 2021

AsTask always allocates. Use existing GetAsTask to avoid allocation if task is already complete.

Comment on lines -82 to -91
#pragma warning disable CS8634 // The type cannot be used as type parameter in the generic type or method. Nullability of type argument doesn't match 'class' constraint.
_applicationServiceCollection.AddSingleton(services
=> services.GetService<ApplicationLifetime>() as IHostApplicationLifetime);
_applicationServiceCollection.AddSingleton<IHostApplicationLifetime>(services
=> services.GetService<ApplicationLifetime>()!);
#pragma warning disable CS0618 // Type or member is obsolete
_applicationServiceCollection.AddSingleton(services
=> services.GetService<ApplicationLifetime>() as AspNetCore.Hosting.IApplicationLifetime);
_applicationServiceCollection.AddSingleton(services
=> services.GetService<ApplicationLifetime>() as Extensions.Hosting.IApplicationLifetime);
_applicationServiceCollection.AddSingleton<AspNetCore.Hosting.IApplicationLifetime>(services
=> services.GetService<ApplicationLifetime>()!);
_applicationServiceCollection.AddSingleton<Extensions.Hosting.IApplicationLifetime>(services
=> services.GetService<ApplicationLifetime>()!);
#pragma warning restore CS0618 // Type or member is obsolete
#pragma warning restore CS8634 // The type cannot be used as type parameter in the generic type or method. Nullability of type argument doesn't match 'class' constraint.
Copy link
Member Author

@JamesNK JamesNK Nov 21, 2021

Choose a reason for hiding this comment

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

Was compiling on my machine because of nullability changes.

@BrennanConroy
Copy link
Member

@JamesNK
Copy link
Member Author

JamesNK commented Nov 22, 2021

ValueTask<TResult> + AsTask allocates.

@JamesNK JamesNK merged commit 13a4608 into main Nov 22, 2021
@JamesNK JamesNK deleted the jamesnk/http3-astask-optimize branch November 22, 2021 21:12
@ghost ghost added this to the 7.0-preview1 milestone Nov 22, 2021
@davidfowl davidfowl added the Perf label Aug 26, 2022
@amcasey amcasey added area-networking Includes servers, yarp, json patch, bedrock, websockets, http client factory, and http abstractions and removed area-runtime labels Jun 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-networking Includes servers, yarp, json patch, bedrock, websockets, http client factory, and http abstractions Perf
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants