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 decompression support #595

Closed

Conversation

IoplachkinI
Copy link
Contributor

@IoplachkinI IoplachkinI commented May 19, 2024

Resolves issue #549

Benchmark results:

---------------------------------------------------------------
Benchmark                     Time             CPU   Iterations
---------------------------------------------------------------
ZstdDecompress/1024        4321 ns         4329 ns       161878
ZstdDecompress/2048        5288 ns         5293 ns       128786
ZstdDecompress/4096        7116 ns         7122 ns        97136
ZstdDecompress/8192       11499 ns        11502 ns        59946
ZstdDecompress/16384      16596 ns        16595 ns        42723
ZstdDecompress/32768      26929 ns        26926 ns        26055
GzipDecompress/1024       10459 ns        10457 ns        66482
GzipDecompress/2048       16552 ns        16550 ns        42502
GzipDecompress/4096       29337 ns        29338 ns        23916
GzipDecompress/8192       57317 ns        57314 ns        12272
GzipDecompress/16384     113640 ns       113633 ns         6156
GzipDecompress/32768     230311 ns       230269 ns         2952

@IoplachkinI IoplachkinI marked this pull request as ready for review May 19, 2024 18:00
@IoplachkinI IoplachkinI requested a review from segoon as a code owner May 19, 2024 18:00
cur_pos += input.size;
}

ZSTD_freeDStream(stream);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use RAII for that to avoid resource leaks

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

'В случае если content_encoding != "gzip" и content_encoding != "zstd" тело запроса потрётся :('
}

auto stream_del = [](ZSTD_DStream* ptr) { ZSTD_freeDStream(ptr); };
auto stream_guard =
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

seems like you can move up this guard to line after ZSTD_createDStream
also ZSTD_freeDStream accept NULL pointer

throw TooBigError();
}
if (decompressed_size > std::numeric_limits<int64_t>::max() / 2) {
return DecompressStream(compressed, max_size);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you sure you want to decompress more than 4611686018427387903 bytes?
seems like a sign mismatch here for <>
also decompressed_size is unsigned long long

@github-actions github-actions bot locked and limited conversation to collaborators May 29, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants