Skip to content
This repository was archived by the owner on Nov 20, 2018. It is now read-only.

Reduce FeatureReference checking, lazy init FormFeature - #999

Closed
benaadams wants to merge 4 commits into
aspnet:masterfrom
benaadams:feature-references
Closed

benaadams wants to merge 4 commits into
aspnet:masterfrom
benaadams:feature-references

Conversation

@benaadams

@benaadams benaadams commented Feb 10, 2018 •

Copy link
Copy Markdown
Contributor

Update to #925

Resolves #924 "FeatureCache is over-checked and over-reset"
Resolves #677 "FormFeature allocates when unused"
Resolves #880 "Don't allocate the FormFeature eagerly per request"

/cc @davidfowl

}

public DefaultHttpContext(IFeatureCollection features)
: this(new FeatureCollection(), FormOptions.Default)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Shouldn’t we be passing the feature collection and not a new one?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done


// featurecollection is set. all cached interfaces are null.
var context = new DefaultHttpContext(features);
var context = new DefaultHttpContext(features, FormOptions.Default);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Make sure we validate the default ctor as well

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done

@benaadams

Copy link
Copy Markdown
Contributor Author

Before
image

After
image

Still a bucket load of calls; but less

{
public class FormOptions
{
public static readonly FormOptions Default = new FormOptions();

@Tratcher Tratcher Feb 12, 2018 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

We can't make a mutable instance a public static. Make it internal?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Good point

private readonly static Func<IFeatureCollection, IHttpRequestFeature> _nullRequestFeature = f => null;
private readonly static Func<IFeatureCollection, IQueryFeature> _newQueryFeature = f => new QueryFeature(f);
private readonly static Func<HttpRequest, IFormFeature> _newFormFeature = r => new FormFeature(r);
private readonly static Func<(HttpRequest request, FormOptions options), IFormFeature> _newFormFeature = (r) => new FormFeature(r.request, r.options ?? FormOptions.Default);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Tuples? 😄

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Custom struct or another Fetch overload?

@natemcmaster
natemcmaster changed the base branch from dev to master July 2, 2018 17:58
@muratg

muratg commented Oct 10, 2018

Copy link
Copy Markdown

@davidfowl @Tratcher is this still relevant/useful in your opinion? If so, let's move it forward. If not, let's get it closed.

Ben, thanks for the PR!

@muratg muratg added this to the 2.2.0-preview3 milestone Oct 10, 2018
@davidfowl

Copy link
Copy Markdown
Member

@benaadams I'm going to move this to 3.0

@davidfowl davidfowl modified the milestones: 2.2.0-preview3, 3.0.0 Nov 5, 2018
@natemcmaster

Copy link
Copy Markdown
Contributor

@davidfowl I'm about to merge this repo into aspnet/AspNetCore. If you'd like this PR merged, can you bring it in today? If not, I'm going to close this and you'll have to re-open the PR.

@davidfowl

Copy link
Copy Markdown
Member

@natemcmaster close it and I'll make @benaadams reopen it 😄

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants