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

bit-identical output to zstd command line tool #234

Open
djugei opened this issue Jul 27, 2023 · 1 comment
Open

bit-identical output to zstd command line tool #234

djugei opened this issue Jul 27, 2023 · 1 comment

Comments

@djugei
Copy link

djugei commented Jul 27, 2023

I am trying to generate bit idential binaries to the zstd command line tool.

specifically for the following invocation:
cat file | zstd -c -T0 --ultra -20 > file.zst

pipes matter, providing the output file as parameter changes the output.

i have tried:

let mut endcoder = zstd::Encoder::new(file, 20)
encoder.set_parameter(CParameter::NbWorkers(4))

the number of workers (and -T0) may be a red herring though since they do not seem to change output in my test.

calling the zstd binary using Command and utilizing two pipes does work but is a bit less comfortable than need be.

@gyscos
Copy link
Owner

gyscos commented Oct 11, 2023

Hi, and thanks for the report!

I'm not entirely sure how to get bit-identical output with the CLI.

First, you will of course need to ensure you are using the exact same version of zstd (currently 1.5.5).

You will also need to enable the zstdmt feature for the multi-thread code to have any effect, and match the CLI. The number of workers shouldn't matter, as long as it's non-zero.

In addition, the zstd cli and the library have different default options. For example, the CLI includes checksum by default, but not the lib: you'll need to add CParameter::ChecksumFlag(true).

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

No branches or pull requests

2 participants