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

[FEATURE] Use pooled gzip writer for request body gzip compression #520

Closed
pakio opened this issue Apr 9, 2024 · 0 comments · Fixed by #521
Closed

[FEATURE] Use pooled gzip writer for request body gzip compression #520

pakio opened this issue Apr 9, 2024 · 0 comments · Fixed by #521
Labels
enhancement New feature or request untriaged

Comments

@pakio
Copy link
Contributor

pakio commented Apr 9, 2024

Is your feature request related to a problem?

While I was profiling the performance of our application, I noticed that gzip.NewWriter and extending buffer space are consuming a of memory.
This is a feature request to update logic to pool Writer object and buffer for better performance, similar to other package, e.g, grpc-go, go-ethereum.

What solution would you like?

Use sync.Pool to share gzip writer object

What alternatives have you considered?

N/A

Do you have any additional context?

Here's the benchmark I run while I was contributing to other package, comparing performance of gzip-ing {"query":{"match_all":{}}}. Result might differ depending on the use case but I expect to see similar impact by the update.

=== RUN   BenchmarkTransport/Compress_body_(pool:_false)
BenchmarkTransport/Compress_body_(pool:_false)
BenchmarkTransport/Compress_body_(pool:_false)-8                    9450            117462 ns/op          815014 B/op         31 allocs/op
=== RUN   BenchmarkTransport/Compress_body_(pool:_true)
BenchmarkTransport/Compress_body_(pool:_true)
BenchmarkTransport/Compress_body_(pool:_true)-8                    57690             20462 ns/op            1152 B/op         12 allocs/op
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request untriaged
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant