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

refactor: client in msggateway #1343

Merged
merged 2 commits into from
Nov 7, 2023

Conversation

rfyiamcool
Copy link
Contributor

@rfyiamcool rfyiamcool commented Nov 6, 2023

summary

  1. Refactor the client.go code.
  2. A sync.pool object pool has been added for high-frequency req structs. Although the current code uses the value object of req, subsequent operations such as decode and replyMessage cause the object to escape to the heap. This means that during compilation, the object has already been determined to be allocated on the heap. Therefore, since this object is a heap object, pointers can be used directly afterwards, as stack allocation and copying also have their costs. Furthermore, it's only when the req does not escape that it's allocated on the stack.

Since it's a heap object, using sync.pool for object pooling can reduce the overhead of garbage collection.

image

Signed-off-by: rfyiamcool <rfyiamcool@163.com>
Signed-off-by: rfyiamcool <rfyiamcool@163.com>
Copy link
Contributor

sweep-ai bot commented Nov 6, 2023

Apply Sweep Rules to your PR?

  • Apply: All new business logic should have corresponding unit tests.
  • Apply: Refactor large functions to be more modular.

Copy link

codecov bot commented Nov 6, 2023

Codecov Report

Merging #1343 (9bd59dc) into main (3d3781f) will not change coverage.
The diff coverage is n/a.

@@          Coverage Diff          @@
##            main   #1343   +/-   ##
=====================================
  Coverage   2.41%   2.41%           
=====================================
  Files         13      13           
  Lines        786     786           
=====================================
  Hits          19      19           
  Misses       764     764           
  Partials       3       3           

@FGadvancer FGadvancer added this pull request to the merge queue Nov 7, 2023
Merged via the queue into openimsdk:main with commit 815fa15 Nov 7, 2023
18 checks passed
@github-actions github-actions bot added this to the v3.1 milestone Nov 7, 2023
@openimsdk openimsdk locked and limited conversation to collaborators Nov 7, 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.

3 participants