Skip to content

HttpStatus.resolve allocates HttpStatus.values() once per invocation #26842

Closed
@richardstartin

Description

@richardstartin

I just noticed looking at profiles of some reactor based benchmarks we run to measure Datadog tracer overhead that HttpStatus.resolve allocates an HttpStatus[] once per invocation, so once per response. In a very modest throughput benchmark (~600rps) this is allocating 1MB/s just to resolve the integer status code to the HttpStatus enum value.
Screenshot 2021-04-21 at 22 35 38

I tracked the spring framework code down here.

This could be fixed by caching HttpStatus.values() in an array, which could be iterated over as many times as one likes without any further allocation.

Metadata

Metadata

Assignees

Labels

in: webIssues in web modules (web, webmvc, webflux, websocket)type: enhancementA general enhancement

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions