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

Incorrect/inconsistent reported compression percentage for empty files #2059

Closed
marcusmueller opened this issue Apr 1, 2020 · 1 comment
Closed

Comments

@marcusmueller
Copy link

Describe the bug

zstd reports that compressing an empty file (i.e. 0 bytes) (which yields a 9 B archive) is a compression ratio of 900%. It's not.

It does, however, correctly, report that compressing a single-byte file to a 10 B archive is a compression ratio of 1000%.

While the compression ratio for empty files is essentially meaningless, the compression ratio 0->9 B is actually worse than 1->10 B, and it should be reported as such.

To Reproduce

$ touch empty
$ zstd empty --no-check -o empty.zstd
empty                :900.00%   (     0 =>      9 bytes, empty.zstd)

Expected behavior

Reporting inf %, or not reporting a compression ratio at all.

Desktop (please complete the following information):

  • OS: Linux x86_64, Fedora 31
  • Version *** zstd command line interface 64-bits v1.4.4, by Yann Collet ***
  • Compiler: Fedora standard, so gcc (GCC) 9.2.1 20190827 (Red Hat 9.2.1-1)
  • Flags: Fedora default, -O2 -g
@terrelln
Copy link
Contributor

terrelln commented Apr 1, 2020

Yeah, our logic takes compressed size / max(input_size, 1). I'd be happy to accept any PR that fixes this to handle input_size == 0 specially.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants