-
Notifications
You must be signed in to change notification settings - Fork 102
Remove mallocs from compress decompress #32
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
Closed
valyala
wants to merge
39
commits into
DataDog:master
from
valyala:remove-mallocs-from-compress-decompress
Closed
Remove mallocs from compress decompress #32
valyala
wants to merge
39
commits into
DataDog:master
from
valyala:remove-mallocs-from-compress-decompress
Conversation
This file contains hidden or 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
- Removing all .c/.h files from distribution. This will link against the shared library instead. - Updates to error code list. NOTE: the Go wrapper should really not be using its own error code map, as the upstream has no qualms about changing their error map at any time. - Updated Decompress() so that it uses zStd to guess the destintion buffer size. If zStd doesn't provide an estimate (returns 0) then the previous fallback code still operates as it did before.
This takes the c code from commit cbc5225d38ba65a1cd77701e91a9f45f3cc825ba available at facebook/zstd@cbc5225 3cc825ba The error list has been updated to reflect the C code
We will silence ZBUFF deprecation warnings at least for this version release. Moving to the new interface will need to use C pointers instead of Go pointers
Update zstd to 1.1.3 for 1.x branch (keeps zbuff interface)
Update zstd to 1.3.0
According to https://docs.travis-ci.com/user/languages/go/ > Go builds are not available on the OS X environment. But on OSX page: https://docs.travis-ci.com/user/reference/osx/#Languages > go 1.9.1 Worth a try
[travis] Add .travis.yml
Reduce memory allocations in Reader
[travis] Add Go 1.10 to list of tested go versions
- Errors were defined in private C/header files and we needed to change them every release (FIXME: this is very fragile, must map 1-to-1 with zstd's) - We actually just need DstSizeTooSmall error which we now have a check for and a test
TestFindIsDstSizeTooSmallError now check that there is ONE AND ONLY ONE zstd error that corresponds to DstSizeTooSmall error to make sure the check is not too leniant (before just tested we had at least one)
Add comments to exported variables and methods
[zstd][errors] Get rid of static error code translation and use C call
We have this function in Go code to not have to do a cgo call (really consuming). This function in a hot loop, that's why we can't call C code every time. This mirrors latest zstd implementation (they switched to 128kB window)
zstd 1.3 -> zstd 1.3.3
Go allocates a copy of slice headers when they are passed to C functions. See golang/go#24450 for details. Avoid this by passing unsafe.Pointer as C.uintptr_t into C functions. Benchmark results: $ PAYLOAD=ZSTD_LICENSE go test -run=111 -bench='k[CD]' -benchmem -count=10 name old time/op new time/op delta Compression-4 21.2µs ± 5% 20.8µs ± 6% ~ (p=0.190 n=10+10) Decompression-4 7.37µs ± 5% 6.93µs ± 6% -5.95% (p=0.001 n=10+10) name old speed new speed delta Compression-4 62.5MB/s ± 5% 63.7MB/s ± 6% ~ (p=0.190 n=10+10) Decompression-4 180MB/s ± 5% 191MB/s ± 6% +6.35% (p=0.001 n=10+10) name old alloc/op new alloc/op delta Compression-4 96.0B ± 0% 0.0B -100.00% (p=0.000 n=10+10) Decompression-4 96.0B ± 0% 0.0B -100.00% (p=0.000 n=10+10) name old allocs/op new allocs/op delta Compression-4 4.00 ± 0% 0.00 -100.00% (p=0.000 n=10+10) Decompression-4 4.00 ± 0% 0.00 -100.00% (p=0.000 n=10+10)
Update vendored zstd c lib to 1.3.4
Collaborator
|
The |
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.
Go allocates a copy of slice headers when they are passed to C functions.
See golang/go#24450 for details.
Avoid this by passing unsafe.Pointer as C.uintptr_t into C functions.