This is an automated email from the ASF dual-hosted git repository.
jianbin pushed a commit to branch 2.x
in repository https://gitbox.apache.org/repos/asf/incubator-seata.git
The following commit(s) were added to refs/heads/2.x by this push:
new aba742df11 optimize: optimize seata client I/O processing by adjusting
thread count (#7170)
aba742df11 is described below
commit aba742df117f24c4526690e253076d884a3154c4
Author: Yongjun Hong <[email protected]>
AuthorDate: Wed Feb 19 17:20:49 2025 +0900
optimize: optimize seata client I/O processing by adjusting thread count
(#7170)
---
changes/en-us/2.x.md | 1 +
changes/zh-cn/2.x.md | 1 +
common/src/main/java/org/apache/seata/common/DefaultValues.java | 2 +-
.../java/org/apache/seata/core/rpc/netty/NettyClientConfig.java | 7 ++++---
script/client/conf/file.conf | 2 +-
script/client/spring/application.properties | 2 +-
script/client/spring/application.yml | 2 +-
script/config-center/config.txt | 2 +-
.../apache/seata/spring/boot/autoconfigure/CorePropertiesTest.java | 2 +-
9 files changed, 12 insertions(+), 9 deletions(-)
diff --git a/changes/en-us/2.x.md b/changes/en-us/2.x.md
index 5c999299f2..4edd73b27c 100644
--- a/changes/en-us/2.x.md
+++ b/changes/en-us/2.x.md
@@ -37,6 +37,7 @@ Add changes here for all PR submitted to the 2.x branch.
- [[#7141](https://github.com/apache/incubator-seata/pull/7141)] remove unused
dependencies
- [[#7142](https://github.com/apache/incubator-seata/pull/7142)] upgrade
commons-compress to 1.27.1
- [[#7149](https://github.com/apache/incubator-seata/pull/7149)] Fix abnormal
character display issues in ./distribution/NOTICE.md
+- [[#7170](https://github.com/apache/incubator-seata/pull/7170)] Optimize
seata client I/O processing by adjusting thread count
### security:
diff --git a/changes/zh-cn/2.x.md b/changes/zh-cn/2.x.md
index 0141ea7a08..40b6bdcfc4 100644
--- a/changes/zh-cn/2.x.md
+++ b/changes/zh-cn/2.x.md
@@ -37,6 +37,7 @@
- [[#7141](https://github.com/apache/incubator-seata/pull/7141)] 去除未使用的依赖
- [[#7142](https://github.com/apache/incubator-seata/pull/7142)] 升级
commons-compress 至 1.27.1 版本
- [[#7149](https://github.com/apache/incubator-seata/pull/7149)]
修复./distribution/NOTICE.md文件中的异常字符串显示问题
+- [[#7170](https://github.com/apache/incubator-seata/pull/7170)] 通过调整线程数优化
Seata 客户端 I/O 处理
### security:
diff --git a/common/src/main/java/org/apache/seata/common/DefaultValues.java
b/common/src/main/java/org/apache/seata/common/DefaultValues.java
index 049d625548..0c3480bab1 100644
--- a/common/src/main/java/org/apache/seata/common/DefaultValues.java
+++ b/common/src/main/java/org/apache/seata/common/DefaultValues.java
@@ -103,7 +103,7 @@ public interface DefaultValues {
/**
* The constant DEFAULT_SELECTOR_THREAD_SIZE.
*/
- int DEFAULT_SELECTOR_THREAD_SIZE = 1;
+ int DEFAULT_SELECTOR_THREAD_SIZE = -1;
/**
* The constant DEFAULT_BOSS_THREAD_SIZE.
*/
diff --git
a/core/src/main/java/org/apache/seata/core/rpc/netty/NettyClientConfig.java
b/core/src/main/java/org/apache/seata/core/rpc/netty/NettyClientConfig.java
index 6858360826..d31794cbe4 100644
--- a/core/src/main/java/org/apache/seata/core/rpc/netty/NettyClientConfig.java
+++ b/core/src/main/java/org/apache/seata/core/rpc/netty/NettyClientConfig.java
@@ -25,7 +25,6 @@ import static
org.apache.seata.common.DefaultValues.DEFAULT_PROTOCOL;
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;
import static
org.apache.seata.common.DefaultValues.DEFAULT_WORKER_THREAD_PREFIX;
/**
@@ -346,11 +345,13 @@ public class NettyClientConfig extends NettyBaseConfig {
/**
* Gets client selector thread size.
+ * If the configured thread size is less than or equal to 0, it returns
the default value.
*
- * @return the client selector thread size
+ * @return the client selector thread size, or the default value if the
configured size is invalid.
*/
public int getClientSelectorThreadSize() {
- return CONFIG.getInt(ConfigurationKeys.CLIENT_SELECTOR_THREAD_SIZE,
DEFAULT_SELECTOR_THREAD_SIZE);
+ int threadSize =
CONFIG.getInt(ConfigurationKeys.CLIENT_SELECTOR_THREAD_SIZE,
WorkThreadMode.Default.getValue());
+ return threadSize > 0 ? threadSize : WorkThreadMode.Default.getValue();
}
/**
diff --git a/script/client/conf/file.conf b/script/client/conf/file.conf
index 4b12166092..80858d0c1f 100644
--- a/script/client/conf/file.conf
+++ b/script/client/conf/file.conf
@@ -41,7 +41,7 @@ transport {
serverExecutorThread-prefix = "NettyServerBizHandler"
shareBossWorker = false
clientSelectorThreadPrefix = "NettyClientSelector"
- clientSelectorThreadSize = 1
+ clientSelectorThreadSize = -1
clientWorkerThreadPrefix = "NettyClientWorkerThread"
# netty boss thread size
bossThreadSize = 1
diff --git a/script/client/spring/application.properties
b/script/client/spring/application.properties
index 620cbd9714..af8c19ae60 100755
--- a/script/client/spring/application.properties
+++ b/script/client/spring/application.properties
@@ -71,7 +71,7 @@
seata.transport.thread-factory.worker-thread-prefix=NettyServerNIOWorker
seata.transport.thread-factory.server-executor-thread-prefix=NettyServerBizHandler
seata.transport.thread-factory.share-boss-worker=false
seata.transport.thread-factory.client-selector-thread-prefix=NettyClientSelector
-seata.transport.thread-factory.client-selector-thread-size=1
+seata.transport.thread-factory.client-selector-thread-size=-1
seata.transport.thread-factory.client-worker-thread-prefix=NettyClientWorkerThread
seata.transport.thread-factory.worker-thread-size=default
seata.transport.thread-factory.boss-thread-size=1
diff --git a/script/client/spring/application.yml
b/script/client/spring/application.yml
index 580cb0180e..5ad6816a86 100755
--- a/script/client/spring/application.yml
+++ b/script/client/spring/application.yml
@@ -82,7 +82,7 @@ seata:
server-executor-thread-prefix: NettyServerBizHandler
share-boss-worker: false
client-selector-thread-prefix: NettyClientSelector
- client-selector-thread-size: 1
+ client-selector-thread-size: -1
client-worker-thread-prefix: NettyClientWorkerThread
worker-thread-size: default
boss-thread-size: 1
diff --git a/script/config-center/config.txt b/script/config-center/config.txt
index 6ded35ed83..92039c90db 100644
--- a/script/config-center/config.txt
+++ b/script/config-center/config.txt
@@ -32,7 +32,7 @@
transport.threadFactory.workerThreadPrefix=NettyServerNIOWorker
transport.threadFactory.serverExecutorThreadPrefix=NettyServerBizHandler
transport.threadFactory.shareBossWorker=false
transport.threadFactory.clientSelectorThreadPrefix=NettyClientSelector
-transport.threadFactory.clientSelectorThreadSize=1
+transport.threadFactory.clientSelectorThreadSize=-1
transport.threadFactory.clientWorkerThreadPrefix=NettyClientWorkerThread
transport.threadFactory.bossThreadSize=1
transport.threadFactory.workerThreadSize=default
diff --git
a/seata-spring-autoconfigure/seata-spring-autoconfigure-core/src/test/java/org/apache/seata/spring/boot/autoconfigure/CorePropertiesTest.java
b/seata-spring-autoconfigure/seata-spring-autoconfigure-core/src/test/java/org/apache/seata/spring/boot/autoconfigure/CorePropertiesTest.java
index 490f056446..decf64708d 100644
---
a/seata-spring-autoconfigure/seata-spring-autoconfigure-core/src/test/java/org/apache/seata/spring/boot/autoconfigure/CorePropertiesTest.java
+++
b/seata-spring-autoconfigure/seata-spring-autoconfigure-core/src/test/java/org/apache/seata/spring/boot/autoconfigure/CorePropertiesTest.java
@@ -56,7 +56,7 @@ public class CorePropertiesTest {
assertEquals("NettyServerBizHandler",
context.getBean(ThreadFactoryProperties.class).getServerExecutorThreadPrefix());
assertFalse(context.getBean(ThreadFactoryProperties.class).isShareBossWorker());
assertEquals("NettyClientSelector",
context.getBean(ThreadFactoryProperties.class).getClientSelectorThreadPrefix());
- assertEquals(1,
context.getBean(ThreadFactoryProperties.class).getClientSelectorThreadSize());
+ assertEquals(-1,
context.getBean(ThreadFactoryProperties.class).getClientSelectorThreadSize());
assertEquals("NettyClientWorkerThread",
context.getBean(ThreadFactoryProperties.class).getClientWorkerThreadPrefix());
assertEquals(1,
context.getBean(ThreadFactoryProperties.class).getBossThreadSize());
assertEquals("Default",
context.getBean(ThreadFactoryProperties.class).getWorkerThreadSize());
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]