Improve buffering in Compression Streams API #2469
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Eliminate recursion in compression streams writeInternal()
This avoids having large stack traces when compressing larger chunks of data
and is easier to maintain with the added comments.
Reduce excessive copying in Compression Streams API
In the Compression Streams API, introduce a helper class to only shift output
data when this would reduce output vector size significantly. This results in
the leading bytes of the output vector becoming invalid when reading only parts
of it, which requires careful tracking but avoids having to move the output data
with every read from the buffer.
Increase Compression Streams output buffer size
Since zlib uses 256KiB of memory per compression stream with default settings, a
size of 16KiB will not increase memory usage by a large proportion. This should
make processing data slightly faster. Ideally we'd want this to be larger than
deflate's 32KiB window size which would allow zlib to avoid some extra copying
during decompression, but that can be done at a later time alongside other
compression optimizations.
Clean up ArrayPtr casts