forked from cloudflare/golz4
-
Notifications
You must be signed in to change notification settings - Fork 1
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
Refactor stream reading #3
Closed
Closed
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
…rights, adjust license/doc
Change Uncompress() to return size
[golz4]add lz4 streaming API
Make the Reader work with io.Copy
add new printout to make sure using the right one
add more unit tests and checks in the Reader
[lz4]add comment for decomp double buffer
lz4 streaming compression support
Jerome.v/release version
Use external LibLZ4, detected using standard pkg-config (ME-768)
This is a noop * `LZ4_compress_limitedOutput` calls `LZ4_compress_default`: https://github.com/lz4/lz4/blob/v1.9.2/lib/lz4.c#L2335-L2338 * `LZ4_compressHC2_limitedOutput` calls `LZ4_compress_HC`: https://github.com/lz4/lz4/blob/v1.9.2/lib/lz4hc.c#L1156
Stop using deprecated functions
The input data needs to be at least 512 bytes long.
Use an internal buffer to store decompressed data between Read() calls when dst buffer is not big enough.
Fix reader out of bounds
* Use the doubleBuffer struct for handling read buffers * Do not use C.GoBytes as this leads to extra copies, reuse the internal buffers for pending reads
This ensures the overhead of creating the reader is mitigated by the successive decompression calls, which should better map reality.
Wrong target repo. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR refactors how data is read and uncompressed.
It adds a
doubleBuffer
helper struct to do the magic C, double buffer dance and makes use of this in theRead
function.Here are the benchmarks comparing the current
master
with this branch:master
New version
Performance is very similar, sometimes a bit better. There's still an extra alloc that slipped through the cracks, probably related to the addition of
doubleBuffer
.FWIW, I also tested moving the temporary
readBuffer
as a struct member but this turned out to be worse, performance wise