-
Notifications
You must be signed in to change notification settings - Fork 38.6k
Closed
Labels
in: webIssues in web modules (web, webmvc, webflux, websocket)Issues in web modules (web, webmvc, webflux, websocket)type: enhancementA general enhancementA general enhancement
Milestone
Description
While profiling Spring web applications (MVC and WebFlux), it seems that MimeType
(through MediaType
) is creating a significant amount of garbage that could be avoided.
- Caching the
toString()
result ofMimeType
instances, since it cannot change and this method is called many times on hot paths -
MediaType.parseMediaType
is called multiple times, for each request; this could be backed by a simple LRU cache implementation to avoid re-parsing known media types -
MimeTypeUtils.parseMimeType
parsing code can be improved; a draft implementation shows +40% throughput and -10% allocation. -
MimeTypeUtils
andMediaType
both have static sections where well-known types are parsed; changing those fromAPPLICATION_JSON = MimeType.valueOf(APPLICATION_JSON_VALUE);
toAPPLICATION_JSON = new MimeType("application", "json");
leads to a bit of duplication but consistently reduces garbage and CPU usage at startup time (approx. 10ms).
rstoyanchev and clemstoquartsdeleuze
Metadata
Metadata
Assignees
Labels
in: webIssues in web modules (web, webmvc, webflux, websocket)Issues in web modules (web, webmvc, webflux, websocket)type: enhancementA general enhancementA general enhancement