8000 fix(sumologicexporter): avoid allocations in compressor by swiatekm · Pull Request #1118 · SumoLogic/sumologic-otel-collector · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

fix(sumologicexporter): avoid allocations in compressor #1118

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

Merged
merged 3 commits into from
May 2, 2023

Conversation

swiatekm
Copy link
@swiatekm swiatekm commented May 2, 2023

Avoid an additional copy when compressing data. In most cases, if the io.Reader used implements additional interfaces, a temporary buffer between the reader and the compressing Writer isn't necessary.

I've also fixed the compression benchmark to only measure compression, and not decompression. I've increased the size of the test data to be more representative of real-world workloads as well.

Here's the difference between main and this branch, running the new benchmark:

goos: linux
goarch: amd64
pkg: github.com/SumoLogic/sumologic-otel-collector/pkg/exporter/sumologicexporter
cpu: AMD Ryzen 7 2700X Eight-Core Processor         
                       │ benchmark.main.txt │         benchmark.HEAD.txt          │
                       │       sec/op       │   sec/op     vs base                │
Compression/deflate-16          613.5µ ± 2%   382.8µ ± 3%  -37.61% (p=0.000 n=10)
Compression/gzip-16             689.5µ ± 2%   363.7µ ± 3%  -47.25% (p=0.000 n=10)
geomean                         650.4µ        373.1µ       -42.63%

                       │ benchmark.main.txt │          benchmark.HEAD.txt          │
                       │        B/op        │     B/op      vs base                │
Compression/deflate-16        1535.3Ki ± 0%   512.2Ki ± 0%  -66.64% (p=0.000 n=10)
Compression/gzip-16           1535.7Ki ± 0%   512.4Ki ± 0%  -66.63% (p=0.000 n=10)
geomean                        1.499Mi        512.3Ki       -66.64%

                       │ benchmark.main.txt │         benchmark.HEAD.txt         │
                       │     allocs/op      │ allocs/op   vs base                │
Compression/deflate-16          23.000 ± 0%   4.000 ± 0%  -82.61% (p=0.000 n=10)
Compression/gzip-16             23.000 ± 0%   4.000 ± 0%  -82.61% (p=0.000 n=10)
geomean                          23.00        4.000       -82.61%

github-actions bot added the go label May 2, 2023
@swiatekm swiatekm force-pushed the fix/sumologicexporter/compress-allocs branch from 37c0c9a to c5b41af Compare May 2, 2023 09:26
@github-actions github-actions bot added the documentation Improvements or additions to documentation label May 2, 2023
@swiatekm swiatekm marked this pull request as ready for review May 2, 2023 09:26
@swiatekm swiatekm requested a review from a team as a code owner May 2, 2023 09:26
@swiatekm swiatekm force-pushed the fix/sumologicexporter/compress-allocs branch 3 times, most recently from 0d1cee9 to 388867e Compare May 2, 2023 10:52
@swiatekm swiatekm force-pushed the fix/sumologicexporter/compress-allocs branch from 388867e to a10a152 Compare May 2, 2023 14:11
@swiatekm swiatekm enabled auto-merge (rebase) May 2, 2023 14:11
@swiatekm swiatekm merged commit 261043b into main May 2, 2023
@swiatekm swiatekm deleted the fix/sumologicexporter/compress-allocs branch May 2, 2023 14:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation go
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants
0