BCJ (algorithm)

From Wikipedia, the free encyclopedia
Jump to navigation Jump to search

In data compression, BCJ, short for branch/call/jump, refers to a technique that improves the compression of machine code by replacing relative branch addresses with absolute ones. This allows a Lempel–Ziv compressor to identify duplicate targets and more efficiently encode them. On decompression, the inverse filter restores the original encoding. Different BCJ filters are used for different instruction sets, as each use different opcodes for branching.

A form of BCJ is seen in Microsoft's cabinet file format from 1996, which filters x86 CALL instructions for the LZX compressor.[1] The 7z and xz file formats implement BCJ for multiple architectures.[2][3] ZPAQ calls its x86 BCJ as "E8E9", after the opcode values.[4]

bsdiff, a tool for delta updates, circumvents the need of writing architecture-specific BCJ tools by encoding bytewise differences. This allows it to be much better than the "match and copy" type tools such as VCDIFF,[5] giving an output size of only 6% for Google Chrome. However, Google's courgette, which adds a layer of explicit disassembly, is able to produce 9× smaller diffs.[6]

Effect

[edit | edit source]

For a squashfs image of a Fedora Linux 31 live image, using x86 BCJ saves an extra 30 MB out of the ~1.7 GB compressed size, but doubles the installation time.[7] (An x86 BCJ filter is more complicated than the BCJ filters for other (especially RISC) architectures due to the variable length of instructions. With fixed-length instructions, a BCJ filter can be made parallel.)

References

[edit | edit source]
  1. ^ Lua error in Module:Citation/CS1/Configuration at line 2172: attempt to index field '?' (a nil value).
  2. ^ Lua error in Module:Citation/CS1/Configuration at line 2172: attempt to index field '?' (a nil value).
  3. ^ Lua error in Module:Citation/CS1/Configuration at line 2172: attempt to index field '?' (a nil value).
  4. ^ Lua error in Module:Citation/CS1/Configuration at line 2172: attempt to index field '?' (a nil value).
  5. ^ Colin Percival, Naive differences of executable code, http://www.daemonology.net/bsdiff/, 2003.
  6. ^ Lua error in Module:Citation/CS1/Configuration at line 2172: attempt to index field '?' (a nil value).
  7. ^ Lua error in Module:Citation/CS1/Configuration at line 2172: attempt to index field '?' (a nil value).