Merge pull request #11236 from overleaf/jpa-pdf-caching-fix-size-estimation

[web] pdf-caching: fix estimation of multipart response size

GitOrigin-RevId: 5929cc1e413befb3f931889b38a4b21a7ed4cea8
This commit is contained in:
Jakob Ackermann 2023-01-16 09:32:12 +00:00 committed by Copybot
parent e00e17035c
commit 6154db8f92

View file

@ -10,7 +10,7 @@ const HEADER_OVERHEAD_PER_MULTI_PART_CHUNK = composeMultipartHeader({
start: 9 * 1024 * 1024 * 1024, start: 9 * 1024 * 1024 * 1024,
end: 9 * 1024 * 1024 * 1024, end: 9 * 1024 * 1024 * 1024,
size: 9 * 1024 * 1024 * 1024, size: 9 * 1024 * 1024 * 1024,
}) }).length
const MULTI_PART_THRESHOLD = 4 const MULTI_PART_THRESHOLD = 4
const INCREMENTAL_CACHE_SIZE = 1000 const INCREMENTAL_CACHE_SIZE = 1000
// Download large chunks once the shard bandwidth exceeds 50% of their size. // Download large chunks once the shard bandwidth exceeds 50% of their size.
@ -88,7 +88,8 @@ function estimateSizeOfMultipartResponse(chunks) {
(totalBytes, chunk) => (totalBytes, chunk) =>
totalBytes + totalBytes +
HEADER_OVERHEAD_PER_MULTI_PART_CHUNK + HEADER_OVERHEAD_PER_MULTI_PART_CHUNK +
(chunk.end - chunk.start) (chunk.end - chunk.start),
0
) + ('\r\n' + SAMPLE_NGINX_BOUNDARY + '--').length ) + ('\r\n' + SAMPLE_NGINX_BOUNDARY + '--').length
) )
} }