4 ms·
> This is due to the fact that the specification of the PNG has a sliding window of 32 kB for performance reasons. It’s a bit of a shortcut: in reality PNG use
by masklinn 5y ago
> This is due to the fact that the specification of the PNG has a sliding window of 32 kB for performance reasons.
It’s a bit of a shortcut: in reality PNG uses DEFLATE, and it’s DEFLATE which has a 32kB window.
And it’s not exactly performance reasons but memory budget, especially as deflate was designed for streaming, both when compressing and decompressing: when decompressing you need a buffer at least as large as the window, and when compressing you need that plus most likely an index of some sort (so you don’t have to look for matches linearly through the buffer).
This is more relevant with the context that Phil Katz created deflate in 1991, high-end desktops reached high single-digit megabytes of RAM but the low end might not even be there (Windows 3.0 required 1MB to run decently).
By comparison, if memory serves zstd uses a window of 8MB (or 16 depending on setting), though configurable anywhere from 1k to 512MB
- userbinator 5y ago...and 32k allows the buffer to fit into a single 64k segment along with the Huffman tables, no doubt a useful property at the time. Deflate is actually very similar to LZH, and there are small extensions to both which make the window 64k; but in my experience it doesn't provide all that much extra compression (few percent.)
- magicalhippo 5y ago> no doubt a useful property at the time For reference: https://en.wikipedia.org/wiki/X86_memory_segmentation#Real_mode https://en.wikipedia.org/wiki/X86_memory_segmentation#Real_m...
- jandrese 5y agoI find it amusing when reading the docs on compression programs and seeing statements like "Compression level of -9 should be used with caution as it can consume over 8 megabytes of main memory".