compress/flate: read data with partial flush #68130
Open
+27
−82
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.
problem: data written with zlib's Z_PARTIAL_FLUSH can't be read because decompressor returns only after Z_SYNC_FLUSH block or data end (not taking into account internal buffer flush). For some protocols it could be crucial, as an example imap client can send command and start waiting for a reply, but server wouldn't be able to read the command, because it will read futher and there will be deadlock
This change makes decompressor return after each block (like zlib's infalte Z_BLOCK flush mode), thus
Read
calls would be more often. Benchmarks show no difference, but new implementation should be slower. As an option we could add decompressor parameter (flush mode)before
after
and with 100 blocks (25 vs 100 reads)
before
after
gist partial block generation scripts and benchmark code