2

When compressing small values (< 500 bytes or so), and for uncompressible random values, lz4 returns data that is much larger than the original value (e.g. 27 bytes from 4).

When a large amount of such values is compressed separately (e.g. in a key-value storage), this adds up.

Question is: why doesn't lz4 use e.g. a separate magic number for values that didn't become smaller after compression, leaving the original data as-is, and only adding 4 bytes of the overhead?

The same applies to many other compression formats.

Code with demonstration: https://jsfiddle.net/gczy7f3k/2/

HoverHell
  • 4,739
  • 3
  • 21
  • 23

1 Answers1

0

I believe this is something you have to decide on higher level.

You can determine yourself if you want to compress, and add a marker (magic numbers) if the data is compressed.

Bojan Hrnkas
  • 1,587
  • 16
  • 22