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

perf: improve gzip performance with sync.pool #1321

Merged
merged 2 commits into from
Nov 10, 2023

Conversation

rfyiamcool
Copy link
Contributor

@rfyiamcool rfyiamcool commented Nov 2, 2023

summary

use sync.pool to improve gzip compress/decompress performance. refer to the optimization in the opentelemetry collector.

image

https://github.com/open-telemetry/opentelemetry-collector/blob/main/config/confighttp/compressor.go#L27

benchmark result

goarch: amd64
pkg: github.com/openimsdk/open-im-server/v3/internal/msggateway
cpu: Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz
BenchmarkCompress
BenchmarkCompress-12                  	    6334	    158260 ns/op	  814115 B/op	      20 allocs/op
BenchmarkCompressWithSyncPool
BenchmarkCompressWithSyncPool-12      	   56709	     19790 ns/op	     240 B/op	       3 allocs/op
BenchmarkDecompress
BenchmarkDecompress-12                	  147972	      8135 ns/op	   41749 B/op	       7 allocs/op
BenchmarkDecompressWithSyncPool
BenchmarkDecompressWithSyncPool-12    	  691808	      1674 ns/op	     565 B/op	       2 allocs/op
PASS
ok  	github.com/openimsdk/open-im-server/v3/internal/msggateway	7.339s

Signed-off-by: rfyiamcool <rfyiamcool@163.com>
@pull-request-size pull-request-size bot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Nov 2, 2023
@rfyiamcool rfyiamcool temporarily deployed to openim November 2, 2023 03:16 — with GitHub Actions Inactive
@rfyiamcool rfyiamcool temporarily deployed to openim November 2, 2023 03:16 — with GitHub Actions Inactive
@rfyiamcool rfyiamcool temporarily deployed to openim November 2, 2023 03:16 — with GitHub Actions Inactive
@rfyiamcool rfyiamcool temporarily deployed to openim November 2, 2023 03:16 — with GitHub Actions Inactive
@rfyiamcool rfyiamcool temporarily deployed to openim November 2, 2023 03:16 — with GitHub Actions Inactive
@rfyiamcool rfyiamcool temporarily deployed to openim November 2, 2023 03:16 — with GitHub Actions Inactive
@rfyiamcool rfyiamcool temporarily deployed to openim November 2, 2023 03:16 — with GitHub Actions Inactive
Copy link
Contributor

sweep-ai bot commented Nov 2, 2023

Apply Sweep Rules to your PR?

  • Apply: Leftover TODOs in the code should be handled.
  • Apply: All new business logic should have corresponding unit tests in the tests/ directory.
  • Apply: Any clearly inefficient or repeated code should be optimized or refactored.

Copy link

codecov bot commented Nov 2, 2023

Codecov Report

Merging #1321 (fcfe086) into main (a32e94b) will decrease coverage by 0.38%.
Report is 1 commits behind head on main.
The diff coverage is 51.42%.

@@           Coverage Diff            @@
##            main   #1321      +/-   ##
========================================
- Coverage   2.41%   2.04%   -0.38%     
========================================
  Files         13      26      +13     
  Lines        786    1908    +1122     
========================================
+ Hits          19      39      +20     
- Misses       764    1861    +1097     
- Partials       3       8       +5     
Files Coverage Δ
internal/msggateway/init.go 0.00% <ø> (ø)
internal/msggateway/client.go 0.00% <0.00%> (ø)
internal/msggateway/compressor.go 35.08% <54.54%> (ø)

... and 10 files with indirect coverage changes

FGadvancer
FGadvancer previously approved these changes Nov 10, 2023
@cubxxw cubxxw added this pull request to the merge queue Nov 10, 2023
Merged via the queue into openimsdk:main with commit a580c15 Nov 10, 2023
17 checks passed
@openimsdk openimsdk locked and limited conversation to collaborators Nov 10, 2023
@github-actions github-actions bot added this to the v3.1 milestone Nov 10, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants