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

Investigate options to allow pooling of JSON serialization infrastructure #45332

Open
DamianEdwards opened this issue Nov 28, 2022 · 2 comments
Labels
area-minimal Includes minimal APIs, endpoint filters, parameter binding, request delegate generator etc feature-minimal-actions Controller-like actions for endpoint routing Perf
Milestone

Comments

@DamianEdwards
Copy link
Member

Related:

Our JSON-related extension methods on HttpResponse today and the inherent JSON serialization implemented by Minimal APIs (either directly from route handler returned objects or the JSON IResult types) call through the JSON serializers async code paths. These paths don't implement any pooling for the underlying infrastructure like Utf8JsonWriter resulting in repeated allocations of those types, which for small payloads can represent the majority of allocations for the related requests.

We should explore options to enable these features to either pool the underlying types or instead go through the synchronous code paths of JsonSerializer instead, as they implement pooling under the covers, with appropriate heuristics or options to ensure expectations around memory allocations, back pressure, etc. are maintained.

Note it's possible existing ongoing work in the runtime will yield some benefits here already.

@captainsafia
Copy link
Member

captainsafia commented Dec 1, 2022

Triage: @BrennanConroy Is this something that you are taking a look at?

Update triage: Brennan has updated benchmark apps to pool the UTF8Writer and used the source generator for message payloads and this led to improvements in the number of allocations that occur from the JSON middleware.

Also merged a PR for minimal APIs that reduces allocations for minimal API scenarios via #45359 and Brennan is working on a change to remove boxing struct types in the serialization.

Stick this in .NET 8 since there's work in progress on this front.

@captainsafia captainsafia added this to the .NET 8 Planning milestone Dec 1, 2022
@ghost
Copy link

ghost commented Dec 1, 2022

Thanks for contacting us.

We're moving this issue to the .NET 8 Planning milestone for future evaluation / consideration. We would like to keep this around to collect more feedback, which can help us with prioritizing this work. We will re-evaluate this issue, during our next planning meeting(s).
If we later determine, that the issue has no community involvement, or it's very rare and low-impact issue, we will close it - so that the team can focus on more important and high impact issues.
To learn more about what to expect next and how this issue will be handled you can read more about our triage process here.

@amcasey amcasey added the area-minimal Includes minimal APIs, endpoint filters, parameter binding, request delegate generator etc label Jun 2, 2023
@captainsafia captainsafia removed the old-area-web-frameworks-do-not-use *DEPRECATED* This label is deprecated in favor of the area-mvc and area-minimal labels label Jun 6, 2023
@dotnet-policy-service dotnet-policy-service bot added the pending-ci-rerun When assigned to a PR indicates that the CI checks should be rerun label Feb 6, 2024
@wtgodbe wtgodbe removed the pending-ci-rerun When assigned to a PR indicates that the CI checks should be rerun label Feb 6, 2024
@dotnet-policy-service dotnet-policy-service bot added the pending-ci-rerun When assigned to a PR indicates that the CI checks should be rerun label Feb 6, 2024
@wtgodbe wtgodbe removed the pending-ci-rerun When assigned to a PR indicates that the CI checks should be rerun label Feb 13, 2024
@dotnet dotnet deleted a comment from dotnet-policy-service bot Feb 13, 2024
@dotnet dotnet deleted a comment from dotnet-policy-service bot Feb 13, 2024
@captainsafia captainsafia modified the milestones: .NET 8 Planning, Backlog Mar 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-minimal Includes minimal APIs, endpoint filters, parameter binding, request delegate generator etc feature-minimal-actions Controller-like actions for endpoint routing Perf
Projects
No open projects
Status: No status
Development

No branches or pull requests

4 participants