Repository navigation
Decode DEFLATE with zlib in the inflating reader - #2506
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
|
Faster oas reading will be very much appreciated. I found that writing oas with zlib compression set to 2 instead of the default 6 will create 5-10% larger oas, but both writing and reading can be up to 2x faster, a tradeoff well worth it. Depending on the order of the reference tables and the cells written, different tools write the same oas with different files sizes anyways, so a slight file size increase due to zlib compression level 2 might even go unnoticed. |
|
Hi @nikosavola , [1] This PR seems to be an improvement over #2505, if I may phrase it that way.
[2] If it takes, say 5 successive PRs to reach a state where no further improvement seems possible :
Hi @stefanottili , Would you be able to run @nikosavola 's solution on your various layout files (as many as possible) and tabulate the speedup ? In the PR above, I think the sample size is only 2 layouts ? |
|
I've experimented with just one file, using Leo Mosers mpw gf180ws-run2/G802.oas:
It has 4M propnames, 503k duplicate klayout tile aref and I believe was written with klayout.
Using zlib for reading these files doesn't make a difference for strm2oas read times. The unzipped file size does: 24 s for 418.6 MB, 31 s for 490 MB. Unlike strm2oas my own program reads its own output faster than strm2oas oas. |
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.