Skip to content

Conversation

@YongGoose
Copy link
Member

  • I have registered the PR changes.

Ⅰ. Describe what this PR did

Ⅱ. Does this pull request fix one issue?

fixes #7168

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

Ⅳ. Describe how to verify it

Ⅴ. Special notes for reviews

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

import static org.apache.seata.common.DefaultValues.DEFAULT_RPC_RM_REQUEST_TIMEOUT;
import static org.apache.seata.common.DefaultValues.DEFAULT_RPC_TM_REQUEST_TIMEOUT;
import static org.apache.seata.common.DefaultValues.DEFAULT_SELECTOR_THREAD_PREFIX;
import static org.apache.seata.common.DefaultValues.DEFAULT_SELECTOR_THREAD_SIZE;
Copy link
Contributor

Choose a reason for hiding this comment

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

The value of DEFAULT_SELECTOR_THREAD_SIZE should be changed to -1

Copy link
Member Author

Choose a reason for hiding this comment

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

Done in f5d38a9 !

Copy link
Contributor

Choose a reason for hiding this comment

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

Done in f5d38a9 !

In NettyClientBootstrap, it is necessary to handle the case where selectorThreadSizeThreadSize=-1.

Copy link
Member Author

Choose a reason for hiding this comment

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

Done in f5d38a9 !

In NettyClientBootstrap, it is necessary to handle the case where selectorThreadSizeThreadSize=-1.

What do you think?

@codecov
Copy link

codecov bot commented Feb 19, 2025

Codecov Report

Attention: Patch coverage is 50.00000% with 1 line in your changes missing coverage. Please review.

Project coverage is 52.18%. Comparing base (46c9b63) to head (02885a1).
Report is 3 commits behind head on 2.x.

Files with missing lines Patch % Lines
...apache/seata/core/rpc/netty/NettyClientConfig.java 50.00% 0 Missing and 1 partial ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff            @@
##                2.x    #7170   +/-   ##
=========================================
  Coverage     52.18%   52.18%           
  Complexity     6813     6813           
=========================================
  Files          1154     1154           
  Lines         41112    41113    +1     
  Branches       4818     4819    +1     
=========================================
+ Hits          21455    21456    +1     
+ Misses        17617    17616    -1     
- Partials       2040     2041    +1     
Files with missing lines Coverage Δ
...in/java/org/apache/seata/common/DefaultValues.java 0.00% <ø> (ø)
...apache/seata/core/rpc/netty/NettyClientConfig.java 52.17% <50.00%> (-0.77%) ⬇️

... and 2 files with indirect coverage changes

@YongGoose
Copy link
Member Author

Then, in the code, handle the value of -1 by converting it to the number of CPU cores * 2.

What do you think about changing the thread count to CPU cores * 2 when the value is negative?

@funky-eyes
Copy link
Contributor

What do you think about changing the thread count to CPU cores * 2 when the value is negative?

If it is a negative number, directly assign the value of WorkThreadMode.Default.getValue() to it

Comment on lines +353 to +354
int threadSize = CONFIG.getInt(ConfigurationKeys.CLIENT_SELECTOR_THREAD_SIZE, WorkThreadMode.Default.getValue());
return threadSize > 0 ? threadSize : WorkThreadMode.Default.getValue();
Copy link
Member Author

@YongGoose YongGoose Feb 19, 2025

Choose a reason for hiding this comment

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

@funky-eyes

Handling this in NettyClientBootstrap is a good idea, but I believe it is more appropriate to process it here.
Because if we handle this in NettyClientBootstrap, we would need to process -1 in every piece of code that retrieves the thread count using this method.

Copy link
Contributor

Choose a reason for hiding this comment

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

You are right, handling it this way is better, good job.

@YongGoose
Copy link
Member Author

@funky-eyes

I have resolved the failing test related to getClientSelectorThreadSize.
However, the testRemoveConfig test in ZkConfigurationTest is still failing, but only when running on Java 8.
Could you help me understand why this failure occurs specifically in Java 8?

@funky-eyes
Copy link
Contributor

@funky-eyes

I have resolved the failing test related to getClientSelectorThreadSize. However, the testRemoveConfig test in ZkConfigurationTest is still failing, but only when running on Java 8. Could you help me understand why this failure occurs specifically in Java 8?

This is not caused by your PR; this issue is an occasional occurrence, and the exact cause is currently unknown. I have restarted the CI workflow for now.

@funky-eyes funky-eyes merged commit aba742d into apache:2.x Feb 19, 2025
8 checks passed
@funky-eyes funky-eyes changed the title optimize: Optimize seata client I/O processing by adjusting thread count optimize: optimize seata client I/O processing by adjusting thread count Feb 19, 2025
@funky-eyes funky-eyes added this to the 2.4.0 milestone Feb 19, 2025
slievrly pushed a commit to slievrly/fescar that referenced this pull request Oct 21, 2025
YvCeung pushed a commit to YvCeung/incubator-seata that referenced this pull request Dec 25, 2025
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.

The client's NioEventLoopGroup thread is only 1 by default

2 participants