Skip to content

Voodoo zpaq level 2 ZPAQL

Franco Corbelli edited this page Sep 19, 2023 · 1 revision

ZPAQL

zpaq elaborate the data 1 byte at time (8 bits), running virtual machines in a special language, ZPAQL, similar to an assembly language so that it can be implemented efficiently while allowing for arbitrarily complex contexts. Another program in the same language is used for post-processing. Both programs are called once for each byte of input data.

OK, this is just a bit... complex

At this level the point is that the data are compressed not by a "normal" algorithm, compilated somehow in machine code by a compiler, like gcc, clang, or whatever.
A special language is instead used, and this need to be translated into machine code.
Something like a little java, if you know.
There are advantages and disadvantages

The main advantage

is that the code that extracts the data, i.e. that decompresses the bytes, is not in the zpaqfranz source, but in the archive itself, stored as ZPAQL code. This means that even very old versions of zpaq are compatible with archives created with the latest versions.
You can add new compression methods (written in ZPAQL) in version 10, say, and version 9 will be able to extract them anyway

The main disavantages

Speed. Just like interpreting java code is slow, there is a JIT (just-in-time) compiler that, on x86-32 and x86-64 processor, directly translate ZPAQL code to "Intel" machine code, running about at the same speed of native C/C++ algorithms.
On other hardware, like for example Apple M1/M2, ARM chips, PowerPC or whatever, the JIT must be disabled (compiling with -DNOJIT), then the ZPAQL code is interpreted, which is slower.

Clone this wiki locally