Skip to content

Investigate options to allow pooling of JSON serialization infrastructure #45332

@DamianEdwards

Description

@DamianEdwards

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Perfarea-minimalIncludes minimal APIs, endpoint filters, parameter binding, request delegate generator etcfeature-minimal-actionsController-like actions for endpoint routing

    Type

    No type

    Projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions