Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compression benchmarks #130

Closed
wants to merge 6 commits into from

Conversation

Wumpf
Copy link

@Wumpf Wumpf commented Feb 17, 2023

After noticing that by far the slowest dependency to build on my machine was zstd (see rerun-io/rerun#1316), I set out in search for finding an alternative compression library that is pure Rust and has similar compression ratio & speed as zstd.

Not very successful so far! Seems the C written zstd is a lot faster than everything tried here!

Measurements on my M1 Max so far:

zstd encode            27.214 ms
zstd decode            8.7848 ms

gzip (flate2) encode   34.933 ms
gzip (flate2) decode   20.368 ms

lzma (lzma-rs) encode  157.91 ms
lzma (lzma-rs) decode  369.42 ms

brotli encode          67.711 ms
brotli decode          36.595 ms

slightly tweaked for roughly similar compression ratios for the generated test data:

zstd:   3.16
gzip:   2.98
lzma:   2.16
brotli: 3.46

Checklist

  • I have read the Contributor Guide
  • I have read and agree to the Code of Conduct
  • I have added a description of my changes and why I'd like them included in the section below

Description of Changes

Describe your changes here

Related Issues

List related issues here

@emilk
Copy link
Collaborator

emilk commented Apr 4, 2023

I added https://github.com/pseitz/lz4_flex which is VERY fast:

zstd encode             27   ms
zstd decode              9.3 ms

gzip (flate2) encode    35   ms
gzip (flate2) decode    20   ms

lzma (lzma-rs) encode  157   ms
lzma (lzma-rs) decode  403   ms

brotli encode           68   ms
brotli decode           37   ms

lz4_flex encode         10.6 ms
lz4_flex decode          2.9 ms

but doesn't compress as well:

zstd:     3.16
gzip:     2.98
lzma:     2.16
brotli:   3.46
lz4_flex: 1.97

@emilk
Copy link
Collaborator

emilk commented Apr 4, 2023

I think it would be worth to refactor puffin to support multiple compression schemes/libraries (zstd and lz4_flex, initially). The compression scheme would need to be encoded in the data stream. The puffin_viewer binary would support all of them for maximal compatibility, but we would let users of puffin to opt-in to different compression libraries so the users can chose between fast compression and compilation, or high compression ratio.

emilk added a commit that referenced this pull request May 20, 2023
### Checklist

* [x] I have read the [Contributor Guide](../CONTRIBUTING.md)
* [x] I have read and agree to the [Code of
Conduct](../CODE_OF_CONDUCT.md)
* [x] I have added a description of my changes and why I'd like them
included in the section below

### Description of Changes

[`lz4_flex`](https://github.com/PSeitz/lz4_flex) is a light-weight
Rust-only dependency.
It compiles and runs much faster than zstd, and it supports compression
in wasm.

zstd compresses better, so you can still opt-in to it with the "zstd"
feature.

For most `puffin` users the effect will be faster compilation time and
less CPU usage (about a third of zstd). Benchmarks can be found here:
#130 (comment)

Users of `puffin` must update their `puffin_viewer`s, but the new
`puffin_viewer` will still be able to open old puffin streams.
@repi
Copy link
Contributor

repi commented Jun 8, 2023

can close this now as we do support lz4 as well

@repi repi closed this Jun 8, 2023
@Wumpf Wumpf deleted the compression-benchmarks branch June 9, 2023 12:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants