HackerTrans
TopNewTrendsCommentsPastAskShowJobs

jonjonsonjr

no profile record

comments

jonjonsonjr
·10 месяцев назад·discuss
Something must be in the air. I've been working on a gzip/deflate visualizer recently as well: https://jonjohnsonjr.github.io/deflate/

This is very work in progress, but for folks looking for a deeper explanation of how dynamic blocks are encoded, this is my attempt to visualize them.

(This all happens locally with way too much wasm, so attempting to upload a large gzip file will likely crash the tab.)

tl;dr for btype 2 blocks:

3 bit block header.

Three values telling you how many extra (above the minimum number) symbols are in each tree: HLIT, HDIST, and HCLEN.

First, we read (HCLEN + 4) * 3 bits.

These are the bit counts for symbols 0-18 in the code length tree, which gives you the bit patterns for a little mini-language used to compactly encode the literal/length and distance trees. 0-15 are literal bit lengths (0 meaning it's omitted). 16 repeats the previous symbol 3-6 times. 17 and 18 encode short (3-10) and long (11-138) runs of zeroes, which is useful for encoding blocks with sparse alphabets.

These bits counts are in a seemingly strange order that tries to push less-likely bit counts towards the end of the list so it can be truncated.

Knowing all the bit lengths for values in this alphabet allows you to reconstruct a huffman tree (thanks to canonical huffman codes) and decode the bit patterns for these code length codes.

That's followed by a bitstream that you decode to get the bit counts for the literal/length and distance trees. HLIT and HDIST (from earlier) tell you how many of these to expect.

Again, you can reconstruct these trees using just the bit lengths thanks to canonical huffman codes, which gives you the bit patterns for the data bitstream.

Then you just decode the rest of the bitstream (using LZSS) until you hit 256, the end of block (EOB).

If you're not already familiar with deflate, don't be discouraged if none of that made any sense. Bill Bird has an excellent (long) lecture that I recommend to everyone: https://www.youtube.com/watch?v=SJPvNi4HrWQ
jonjonsonjr
·10 месяцев назад·discuss
Sorry about that. I usually don't let it scale up at all so that I don't have to worry about costs.

I've raised some limits for now so hopefully you can get through.
jonjonsonjr
·10 месяцев назад·discuss
Hi, this is my project! I was surprised to see it posted here. It's a debugging tool for container images that I host for myself and some friends/coworkers.

Some of its features are intentionally not very discoverable, partially to keep the interface minimal, but mostly because I like to hide them as easter eggs.

I wrote a little more context for how this (and some related tools) came to be at https://dag.dev for the curious.

Happy to answer any questions, of course, but I imagine this is a pretty niche tool.