Skip to content

[CI] PR to test https://github.com/DataDog/zstd/pull/69#70

Closed
Viq111 wants to merge 3 commits into1.xfrom
TriggerMail-1.x-ci
Closed

[CI] PR to test https://github.com/DataDog/zstd/pull/69#70
Viq111 wants to merge 3 commits into1.xfrom
TriggerMail-1.x-ci

Conversation

@Viq111
Copy link
Collaborator

@Viq111 Viq111 commented Sep 25, 2019

I didn't enable external PR CI on CircleCI yet so tests were not run for #69

Just putting this PR up to run the tests

Michael Hurwitz and others added 3 commits September 25, 2019 11:38
Digging into pprof, there was a lot of time spent in allocations and in GC. The allocations seemed to be mostly focused on `NewReaderDict`. In that method, two []byte slices were allocated. The size of those slices is based on compile-time decisions in the zstd C library. In an attempt to improve that situation, two changes were made:

* The sizes of those buffers are read, casted, and checked once
* The buffers come from a pair of `sync.Pool`s in the `NewReaderDict` factory method, returned to the pool in `reader.Close`.

Using the following test:
```
$ PAYLOAD=zstd_decompress.c go test \
    -bench BenchmarkStreamDecompression \
    -benchtime=5s \
    -benchmem
```

The number of bytes allocated per decompression dropped to 1/705 of previous:
```
pkg: github.com/TriggerMail/zstd
BenchmarkStreamDecompression      100000        121617 ns/op     595.48 MB/s         384 B/op         10 allocs/op

pkg: github.com/DataDog/zstd
BenchmarkStreamDecompression       50000        156142 ns/op     463.81 MB/s      270640 B/op         10 allocs/op
```

Note that this improvement is only in the Go-managed heap memory, not additional heap allocations in creating the zstd context. Because those are freed explicitly in `reader.Close`, the concern is heap fragmentation.
@Viq111
Copy link
Collaborator Author

Viq111 commented Sep 25, 2019

Tests passed ✅, closing.
Future external PR shouldn't need that since Enabling CI for forked pull requests is now enabled for future PR

@Viq111 Viq111 closed this Sep 25, 2019
@Viq111 Viq111 deleted the TriggerMail-1.x-ci branch January 31, 2020 16:24
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

Successfully merging this pull request may close these issues.

1 participant