This is an automated email from the ASF dual-hosted git repository.
xianjingfeng pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/uniffle.git
The following commit(s) were added to refs/heads/master by this push:
new b43872f47 [#2441] improvement(client): remove synchronized in
ShuffleServerClientFactory#getShuffleServerClient (#2442)
b43872f47 is described below
commit b43872f4725cad2149edcf663c1a303857391e5b
Author: xianjingfeng <[email protected]>
AuthorDate: Thu Apr 17 09:55:50 2025 +0800
[#2441] improvement(client): remove synchronized in
ShuffleServerClientFactory#getShuffleServerClient (#2442)
### What changes were proposed in this pull request?
Remove synchronized in ShuffleServerClientFactory#getShuffleServerClient
### Why are the changes needed?
For better performance
Fix: #2441
### Does this PR introduce any user-facing change?
No.
### How was this patch tested?
CI
---
.../client/factory/ShuffleServerClientFactory.java | 16 +++++++---------
1 file changed, 7 insertions(+), 9 deletions(-)
diff --git
a/internal-client/src/main/java/org/apache/uniffle/client/factory/ShuffleServerClientFactory.java
b/internal-client/src/main/java/org/apache/uniffle/client/factory/ShuffleServerClientFactory.java
index 8b4f5f91a..7c419e25f 100644
---
a/internal-client/src/main/java/org/apache/uniffle/client/factory/ShuffleServerClientFactory.java
+++
b/internal-client/src/main/java/org/apache/uniffle/client/factory/ShuffleServerClientFactory.java
@@ -59,20 +59,18 @@ public class ShuffleServerClientFactory {
}
}
- public synchronized ShuffleServerClient getShuffleServerClient(
+ public ShuffleServerClient getShuffleServerClient(
String clientType, ShuffleServerInfo shuffleServerInfo) {
return getShuffleServerClient(clientType, shuffleServerInfo, new
RssConf());
}
- public synchronized ShuffleServerClient getShuffleServerClient(
+ public ShuffleServerClient getShuffleServerClient(
String clientType, ShuffleServerInfo shuffleServerInfo, RssConf rssConf)
{
- clients.putIfAbsent(clientType, JavaUtils.newConcurrentMap());
- Map<ShuffleServerInfo, ShuffleServerClient> serverToClients =
clients.get(clientType);
- if (serverToClients.get(shuffleServerInfo) == null) {
- serverToClients.put(
- shuffleServerInfo, createShuffleServerClient(clientType,
shuffleServerInfo, rssConf));
- }
- return serverToClients.get(shuffleServerInfo);
+ Map<ShuffleServerInfo, ShuffleServerClient> serverToClients =
+ clients.computeIfAbsent(clientType, key ->
JavaUtils.newConcurrentMap());
+ return serverToClients.computeIfAbsent(
+ shuffleServerInfo,
+ key -> createShuffleServerClient(clientType, shuffleServerInfo,
rssConf));
}
// Only for tests