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

Avoid allocations from getting JsonOptions in Minimal #45359

Merged
merged 4 commits into from
Dec 1, 2022

Conversation

BrennanConroy
Copy link
Member

Part of #45330
Removes the two DI allocations and RequestServices allocation seen in #45330 (comment) which reduces the allocation rate of the JsonMapAction benchmark from 307M bytes/sec to 160M bytes/sec as well as increasing the RPS from from 845k to 894k.

We don't really have any E2E tests for RequestDelegateFactory, at least none that I could find. Fortunately, we do hit the code paths that were changed so it was easy to find all the Expression Tree code that I needed to update (follow the exceptions from tests).

Bonus: Updated the read path as well, so it'll be faster for Json requests.

@BrennanConroy BrennanConroy added Perf old-area-web-frameworks-do-not-use *DEPRECATED* This label is deprecated in favor of the area-mvc and area-minimal labels labels Nov 30, 2022
@ghost ghost added the area-runtime label Nov 30, 2022
@davidfowl
Copy link
Member

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 3 pipeline(s).

@BrennanConroy BrennanConroy requested a review from a team November 30, 2022 16:56
@BrennanConroy
Copy link
Member Author

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 3 pipeline(s).

@JamesNK
Copy link
Member

JamesNK commented Dec 1, 2022

What was the offending code that was the source of the allocations? Is it related to getting options from DI per request?

@BrennanConroy
Copy link
Member Author

BrennanConroy commented Dec 1, 2022

Removes the two DI allocations and RequestServices allocation seen in #45330 (comment)

From: https://source.dot.net/#Microsoft.AspNetCore.Http.Extensions/HttpResponseJsonExtensions.cs,9b30f6958023e0b7

@JamesNK
Copy link
Member

JamesNK commented Dec 1, 2022

Ok! I didn't know resolving config types from DI allocated. Usually, getting config from DI isn't on the hot path.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
old-area-web-frameworks-do-not-use *DEPRECATED* This label is deprecated in favor of the area-mvc and area-minimal labels Perf
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants