This PR renames "encoding" to "codec" in the compression package to remove the cognitive dissonance.
It also removes the `Enc` prefix for codec identifiers, so that they adhere Go's best practice of naming conventions, e.g. `compression.EncGZIP` becomes `compression.GZIP` when used in a different package.
Signed-off-by: Christian Haudum <christian.haudum@gmail.com>
Decompression is a CPU intensive task, especially un-gzipping. The gain of compressing a tar archive of storage optimized binary blocks is neglectable (question: is it?).
In this example, the block of ~170MiB is ~3.3MiB bigger when not compressed, which is a ratio of ~2%
```bash
$ ls -las 2bc017f79711e12a-2bffc5dcc0e8e964_1726004114913-1726106283939-bc42f529.tar
177048 -rw-rw-r-- 1 christian christian 181293056 Sep 18 13:49 2bc017f79711e12a-2bffc5dcc0e8e964_1726004114913-1726106283939-bc42f529.tar
$ ls -las 2bc017f79711e12a-2bffc5dcc0e8e964_1726004114913-1726106283939-bc42f529.tar.gz
173732 -rw-rw-r-- 1 christian christian 177897689 Sep 18 13:49 2bc017f79711e12a-2bffc5dcc0e8e964_1726004114913-1726106283939-bc42f529.tar.gz
$ qalc '(181293056 - 177897689) / 1024/ 1024'
((181293056 − 177897689) / 1024) / 1024 ≈ 3.238074303
$ qalc '181293056 / 177897689'
181293056 / 177897689 ≈ 1.019086066
```
After some consideration, we decided to store the encoding of the bloom block in the `BlockRef`. This means, that the changes in this PR do not break compatibility with existing blocks compressed with gzip, although new blocks will not be compressed any more.
However, the PR adds support for different compression algorithms, such as gzip, snappy, lz4, flate, and zstd. Compression is not configurable yet.
---
Signed-off-by: Christian Haudum <christian.haudum@gmail.com>
Compression tooling has been part of the `chunkenc` (chunk encoding) package in the past for legacy reasons.
Since more components use this now, it's easier to keep it in a separate package. This also eliminates the confusion around "encoding", since this has been incorrectly used synonymously with "compression" in the past.
---
Signed-off-by: Christian Haudum <christian.haudum@gmail.com>
Co-authored-by: Robert Fratto <robertfratto@gmail.com>