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

Mediocre gzip compression using flate2 with miniz_oxide #238

Closed
Fishrock123 opened this issue May 14, 2020 · 3 comments
Closed

Mediocre gzip compression using flate2 with miniz_oxide #238

Fishrock123 opened this issue May 14, 2020 · 3 comments

Comments

@Fishrock123
Copy link

Fishrock123 commented May 14, 2020

Hi there, I'm using flate2 with the default backend (apparently miniz_oxide) via the async_compression crate.

I have a "file" like this (in a test):

const TEXT: &'static str = concat![
    "Chunk one\n",
    "data data\n",
    "\n",
    "Chunk two\n",
    "data data\n",
    "\n",
    "Chunk three\n",
    "data data\n",
];

flate2 appears to compress that to the following (hex dump from binary):

00000000: 1f8b 0800 0000 0000 00ff 6dca b109 0030  ..........m....0
00000010: 0805 d1fe 4fe1 2e4e 2244 1002 0ac1 90f5  ....O..N"D......
00000020: 4352 59d8 5cf1 38b6 ed93 c215 4352 e805  CRY.\.8.....CR..
00000030: e08f 79a2 415b 5adf 0bde f2d7 8140 0000  ..y.A[Z......@..
00000040: 00                                       .

However, this test is being partially ported from Node.js, where I did something similar a while ago. Node.js uses zlib. The hex resulting from that binary is this:

00000000: 1f8b 0800 0000 0000 0013 73ce 28cd cb56  ..........s.(..V
00000010: c8cf 4be5 4a49 2c49 5400 115c 5cce 60c1  ..K.JI,IT..\\.`.
00000020: 92f2 7c2c 8219 45a9 c86a 01de f2d7 8140  ..|,..E..j.....@
00000030: 0000 00                                  ...

The zlib one here is quite a bit smaller.

Both of these do appear to be valid, and both decompress fine with other tools.

Addendum: this is with the "default" quality setting (zlib level 6 or 7 (whichever it is), default flate2). Changing flate2 to "best" does not appear to make a difference.

@alexcrichton
Copy link
Member

This might best be an issue for miniz-oxide? That's just a straight port of miniz though, so I'm not sure that much can be done. I'd recomend enabling the zlib backend if you get better results with that

@oyvindln
Copy link
Contributor

Yeah this would likely be an issue with miniz_oxide, provided you are sure you are providing the same input data. The output ought to be very similar, especially for a short input like this. Difference between default and max compression levels wont come into play when compressing a small file like this.

@joshtriplett
Copy link
Member

Closing this issue in favor of the issue on miniz_oxide.

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

4 participants