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

New FeatureCollection constructor for initialCapacity #31249

Closed
NinoFloris opened this issue Mar 25, 2021 · 6 comments · Fixed by #31381
Closed

New FeatureCollection constructor for initialCapacity #31249

NinoFloris opened this issue Mar 25, 2021 · 6 comments · Fixed by #31381
Assignees
Labels
api-approved API was approved in API review, it can be implemented area-networking Includes servers, yarp, json patch, bedrock, websockets, http client factory, and http abstractions enhancement This issue represents an ask for new feature or an enhancement to an existing one good first issue Good for newcomers. help wanted Up for grabs. We would accept a PR to help resolve this issue
Milestone

Comments

@NinoFloris
Copy link

Background and Motivation

Some background can be found here, dictionary resizes were fairly visible in traces #31240

Proposed API

namespace Microsoft.AspNetCore.Http.Features
{
    public class FeatureCollection
    {
+       public FeatureCollection(int initialCapacity);
    }
}

Usage Examples

Initial place this will be used is

        public DefaultHttpContext()
            : this(new FeatureCollection(10)) // right here
        {
            Features.Set<IHttpRequestFeature>(new HttpRequestFeature());
            Features.Set<IHttpResponseFeature>(new HttpResponseFeature());
            Features.Set<IHttpResponseBodyFeature>(new StreamResponseBodyFeature(Stream.Null));
            // At least some slots left before resize for storing RequestAborted feature, Services and other such things. 
        }

The initial capacity of 10 is just an example, say 5 or 7 would also be fine for me.

Alternative Designs

This could also be handled through an internal constructor.

Risks

It can be viewed as api bloat if it provides minimal overall value.

@NinoFloris NinoFloris added the api-suggestion Early API idea and discussion, it is NOT ready for implementation label Mar 25, 2021
@davidfowl davidfowl added this to the 6.0-preview4 milestone Mar 25, 2021
@davidfowl davidfowl added area-servers api-ready-for-review API is ready for formal API review - https://github.com/dotnet/apireviews and removed api-suggestion Early API idea and discussion, it is NOT ready for implementation labels Mar 25, 2021
@davidfowl
Copy link
Member

API looks good to me. We'll review it in API review.

@davidfowl davidfowl self-assigned this Mar 25, 2021
@davidfowl davidfowl added the enhancement This issue represents an ask for new feature or an enhancement to an existing one label Mar 25, 2021
@mkArtakMSFT mkArtakMSFT added api-approved API was approved in API review, it can be implemented and removed api-ready-for-review API is ready for formal API review - https://github.com/dotnet/apireviews labels Mar 29, 2021
@mkArtakMSFT
Copy link
Member

Thanks for the proposal, @NinoFloris.
It looks great. We'll mark this as help-wanted so community members can handle this too.

@mkArtakMSFT mkArtakMSFT added good first issue Good for newcomers. help wanted Up for grabs. We would accept a PR to help resolve this issue labels Mar 29, 2021
@mareklinka
Copy link
Contributor

Hello all. This looks rather straight-forward - if it's still open, I'd like to take a crack at it. Is there anything special or important that I should be aware of?

@davidfowl
Copy link
Member

Hello all. This looks rather straight-forward - if it's still open, I'd like to take a crack at it. Is there anything special or important that I should be aware of?

Nope, its as straight forward as it seems!

@davidfowl davidfowl assigned mareklinka and unassigned davidfowl Mar 29, 2021
@davidfowl
Copy link
Member

Assigned to you @mareklinka

@NinoFloris
Copy link
Author

Thanks @mareklinka!

@ghost ghost locked as resolved and limited conversation to collaborators Apr 29, 2021
@amcasey amcasey added area-networking Includes servers, yarp, json patch, bedrock, websockets, http client factory, and http abstractions and removed area-runtime labels Aug 24, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
api-approved API was approved in API review, it can be implemented area-networking Includes servers, yarp, json patch, bedrock, websockets, http client factory, and http abstractions enhancement This issue represents an ask for new feature or an enhancement to an existing one good first issue Good for newcomers. help wanted Up for grabs. We would accept a PR to help resolve this issue
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants