Repository navigation
Decode DEFLATE with zlib in the inflating reader - #2506
Draft
nikosavola wants to merge 4 commits into
Draft
nikosavola wants to merge 4 commits into
nikosavola wants to merge 4 commits into
Conversation
- get was out-of-line, so byte-wise readers such as the OASIS varint decoder and the GDS2 record reader paid a call per get, two inside a CBLOCK - the inline get serves bytes from the raw buffer and single bytes from the inflate ring buffer, refills and the end of the inflated data stay in get_slow - the last ring slot is left to get_slow too: get rotates the ring there so the read pointer does not wrap, otherwise a following unget(1) asserts - tlStream.h now needs the InflateFilter definition, so tlDeflate.h no longer includes tlStream.h and BitStream::get_byte moved to tlDeflate.cc | case | before ms | after ms | speedup | |---|---:|---:|---:| | oasis_read_vexriscv_compressed | 145.0 | 132.4 | 1.09x | | gds2_read_vexriscv | 135.9 | 127.8 | 1.06x | | oasis_read_vexriscv | 71.5 | 69.9 | 1.02x | Xeon Gold 6248, g++ 13 -O2, before and after alternated for 6 rounds on one pinned core, every round agrees.
- InflateFilter uses zlib raw inflate like DeflateFilter already uses zlib deflate, instead of its own Huffman decoder - the output buffer is linear, zlib keeps its own window, so the ring buffer and its rotation are gone - zlib reads the compressed input in chunks, the part behind the DEFLATE stream is pushed back with the new bypass_inflate flag of InputStream::unget so raw reading continues right after the block - InputStream::pos does not count the chunk part zlib has not decoded yet, so error positions inside a CBLOCK stay close to where they were - BitStream and HuffmannDecoder were only used by the old decoder and are removed
This was referenced Oct 14, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Draft, stacked on #2505: the first two commits are #2505's and drop out once it is merged and I rebase. New here are the last two commits.
InflateFilternow decodes with zlib raw inflate, the same wayDeflateFilteralready encodes with zlib, instead of its own Huffman decoder.BitStreamandHuffmannDecoderare removed, about 400 lines lessbypass_inflateflag onInputStream::unget, so the raw stream continues right after the block, andpos ()does not count the bytes zlib has not decoded yetpos ()while inflating and truncated input. They pass with the old decoder tooXeon Gold 6248, gcc 13 -O2, before (#2505) and after alternated on one pinned core for 6 to 10 rounds, every round agrees. The uncompressed reads do not run the changed code, so their 1% either way is code layout.