Investigate options to allow pooling of JSON serialization infrastructure #45332
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
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 JSONIResult
types) call through the JSON serializers async code paths. These paths don't implement any pooling for the underlying infrastructure likeUtf8JsonWriter
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.
The text was updated successfully, but these errors were encountered: