Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Optimize ContentCachingRequestWrapper allocation
This commit builds on top of changes made in gh-29775 and gh-31737. Before this change, we would allocate several byte arrays even in cases of known request size. This could decrease performance when getting the cached content as it requires merging several arrays and data is not colocated in memory. This change ensures that we create a `FastByteArrayOutputStream` instance with the known request size so that the first allocated segment can contain the entire content. If the request size is not know, we will default back on the default allocation size for the `FastByteArrayOutputStream`. Closes gh-31834
- Loading branch information
Shouldn't
FastByteArrayOutputStream(contentLength)
be constrained bycontentCacheLimit
? For example, if it receives a request with 50MB of content but thecontentCacheLimit
is only 1MB, it could result in unintended memory usage.