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

optimize: Use shared EventLoop for TM and RM clients to reduce thread overhead and improve performance #7179

Merged
merged 11 commits into from
Mar 4, 2025

Conversation

YongGoose
Copy link
Contributor

…ad overhead

  • I have registered the PR changes.

Ⅰ. Describe what this PR did

Ⅱ. Does this pull request fix one issue?

fixes #6774

Ⅲ. Why don't you add test cases (unit test/integration test)?

Ⅳ. Describe how to verify it

Ⅴ. Special notes for reviews

Copy link

codecov bot commented Feb 23, 2025

Codecov Report

Attention: Patch coverage is 77.27273% with 5 lines in your changes missing coverage. Please review.

Project coverage is 51.57%. Comparing base (ba1f753) to head (a836f57).
Report is 1 commits behind head on 2.x.

Files with missing lines Patch % Lines
...che/seata/core/rpc/netty/NettyClientBootstrap.java 70.58% 3 Missing and 2 partials ⚠️
Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff              @@
##                2.x    #7179      +/-   ##
============================================
+ Coverage     51.55%   51.57%   +0.01%     
- Complexity     6804     6813       +9     
============================================
  Files          1169     1169              
  Lines         41463    41478      +15     
  Branches       4850     4851       +1     
============================================
+ Hits          21375    21391      +16     
+ Misses        18069    18065       -4     
- Partials       2019     2022       +3     
Files with missing lines Coverage Δ
...ava/org/apache/seata/common/ConfigurationKeys.java 0.00% <ø> (ø)
...in/java/org/apache/seata/common/DefaultValues.java 0.00% <ø> (ø)
...apache/seata/core/rpc/netty/NettyClientConfig.java 50.00% <100.00%> (+0.72%) ⬆️
.../autoconfigure/properties/TransportProperties.java 94.73% <100.00%> (+0.39%) ⬆️
...che/seata/core/rpc/netty/NettyClientBootstrap.java 55.55% <70.58%> (+2.74%) ⬆️

... and 5 files with indirect coverage changes

@YongGoose YongGoose marked this pull request as ready for review February 26, 2025 06:12
private final NettyPoolKey.TransactionRole transactionRole;
private final EventLoopGroup sharedEventLoopGroup;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it should still be named eventLoopGroupWorker, because it is possible that this EventLoopGroup is not shared.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in 982f2a3 !

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would appreciate it if you could also review the comments below. 🙂

@YongGoose YongGoose requested a review from funky-eyes March 3, 2025 04:25
private final NettyPoolKey.TransactionRole transactionRole;
private final EventLoopGroup eventLoopGroupWorker;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not a static variable, the clientBootstrap held by the two instances of TmNettyRemotingClient and RmNettyRemotingClient are not the same, how does this variable manage to be shared use?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could this be related to the comment?

In fact, I also believe that it should be a static variable to use the same value across multiple instances.
However, if it becomes a static variable, there’s an issue where the previous eventLoopGroupWorker gets modified when a new one is created. I wanted to ask about that.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The previous eventLoopGroupWorker should not have been created yet, so I don't think there should be an action to modify this.

Copy link
Contributor Author

@YongGoose YongGoose Mar 3, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in f308be6 !

PTAL ⚡️

@YongGoose YongGoose requested a review from funky-eyes March 3, 2025 06:58
@YongGoose YongGoose changed the title optimize: Use shared EventLoop for TM and RM clients to reduce thre… optimize: Use shared EventLoop for TM and RM clients to reduce thread overhead and improve performance Mar 3, 2025
*/
public class NettyClientBootstrap implements RemotingBootstrap {

private static final Logger LOGGER = LoggerFactory.getLogger(NettyClientBootstrap.class);
private static final String THREAD_PREFIX_SPLIT_CHAR = "_";

private static EventLoopGroup eventLoopGroupWorker;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it should be a static variable, sharedEventLoopGroupWorker, and eventLoopGroupWorker is an instance variable. When enableClientSharedEventLoop is true, sharedEventLoopGroupWorker is created and assigned to eventLoopGroupWorker.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in a836f57 !

Copy link
Contributor

@funky-eyes funky-eyes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@funky-eyes funky-eyes added this to the 2.4.0 milestone Mar 4, 2025
@funky-eyes funky-eyes merged commit b530e30 into apache:2.x Mar 4, 2025
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

optimize seata-client TM&RM netty eventloop
3 participants