When to use Dictionary Compression
fastcompression.blogspot.com
fastcompression.blogspot.com
git clone https://github.com/faragon/libsrt
cd libsrt
make
./enc -ezh <hugefile >hugefile.z
./enc -dz <hugefile.z >hugefile.again
For 1MB dictionary (faster, because of higher cache hit ratio, and using a much smaller buffer):
./enc -ez <hugefile >hugefile.z
./enc -dz <hugefile.z >hugefile.again
For the source code, check compression (senc_lz_aux()) and decompression (sdec_lz()) functions, much easier to understand than the Zstandard code (because of having less features):
https://github.com/faragon/libsrt/blob/master/src/saux/senc....
In a nutshell, both encoding and deciding side hold a dictionary that maps long sequences of data to still-unique short ones and vice versa (ie. a bijective mapping). Encoder uses it to compress, decoder reverses it.
There are obviously many interesting practical questions such as how the dictionary is synchronized, how the mappings are determined, how to keep it a bijective function, etc.
If you have, like, some standard data (handwave), you can build a dictionary of frequently-used terms and refer to it when you compress and decompress, and you can get better compression for being able to point at that pre-built dictionary.
I might be totally offbase here, as I think database normalization would remove much of the redundancy that a dictionary would target.
CREATE TABLE customer(
id SERIAL,
name VARCHAR(1024),
status VARCHAR(1024)
)
Vs CREATE TABLE customer(
id SERIAL,
name VARCHAR(1024),
status INT REFERENCES status(id)
)
CREATE TABLE status(
id SERIAL,
name VARCHAR(1024),
)
It wasn’t very clear from the parent above, but I think this is where they were trying to go. The normalized version is smaller because you’ve swapped a repeated varchar ‘status’ for an int — so that’s effectively a dictionary. It’s not entirely correct, but it’s not that far off.The problem with IRs is they put the processor in a very fragile state. Different chips handle e.g. stacked interrupts (an interrupt which occurs while another interrupt was being handled) differently, but no matter how they do it, you won't like it. Sometimes it turns off certain types of memory access protection, or other important (hardware) peripherals which might be ignored (because they, themselves, operate using those same interrupts under the hood); it's all madness.
Hence the interrupt just puts together some event data, sets some flag, and the main event loop can handle it when the time is there.
Never? Sometimes you have to in order to adhere to timing requirements.
Say we're talking about a USB device. You'd better respond EP0 control requests without data stage under 50ms; USB spec demands that.
Even more so, when there's physical safety involved. You might really want to stop that stepper motor long before main loop notices your marker...
Then there are those situations you need to do the processing in IRQ or lose (some) of the data due to system constraints.
Just never say never.