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

Add zstd support #98

Merged
merged 1 commit into from
Feb 2, 2021
Merged

Add zstd support #98

merged 1 commit into from
Feb 2, 2021

Conversation

cfergeau
Copy link
Contributor

This pull request adds support for detecting zstd archives
https://en.wikipedia.org/wiki/Zstandard

cfergeau added a commit to cfergeau/crc that referenced this pull request Jan 29, 2021
Testing[1] suggests that zstd compression might be better than xz, with
decompression being much faster than xz, so it's worth considering it
for our bundles.

There is no native support for zstd in golang, so this makes use of
https://pkg.go.dev/github.com/klauspost/compress/zstd for handling this
format. An alternative would be https://github.com/DataDog/zstd which
provides performance numbers, but which is not a pure go implementation,
which is why I picked the other one.

github.com/h2non/filetype does not support zstd type detection, so
a bit of additional code had to be added for that. Before registering a
zstd type, we check if it's supported, this will avoid potential issues
after h2non/filetype#98 is merged.

When compressed with `zstd --ultra -22 -T0`, the 4.6.9 bundle is 2.2G in
size, and uncompresses in about 1 minute. The xz-compressed bundle is
2.6G in size, and takes 3 minutes to uncompress.

An existing bundle can be converted to zstd for testing purposes with:
xzcat $bundle |zstd  -  -o crc_libvirt_xxx.crcbundle

This fixes crc-org#1340 for now.
@h2non
Copy link
Owner

h2non commented Jan 30, 2021

Can you please add it to the README list?

This adds support for detecting zstd compressed files
https://en.wikipedia.org/wiki/Zstandard
@cfergeau
Copy link
Contributor Author

cfergeau commented Feb 1, 2021

Can you please add it to the README list?

Done! https://github.com/cfergeau/filetype/tree/zstd#archive

@h2non h2non merged commit 95e2834 into h2non:master Feb 2, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants