This is an automated email from the ASF dual-hosted git repository.
zuston 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 a1974f6e3 [#2576] fix: Warm up java version var to eliminate lock on
creating concurrent hashmap (#2577)
a1974f6e3 is described below
commit a1974f6e3dc9272efab7b32e5865912033ff6f0e
Author: Junfan Zhang <[email protected]>
AuthorDate: Tue Aug 12 10:19:58 2025 +0800
[#2576] fix: Warm up java version var to eliminate lock on creating
concurrent hashmap (#2577)
### What changes were proposed in this pull request?
Cache the java9+ var to eliminate lock when creating concurrent hashmap
### Why are the changes needed?
fix #2576 .
`Enums.getIfPresent` will always using the global lock, this is unnecessary
and hurt the performance
### Does this PR introduce _any_ user-facing change?
No.
### How was this patch tested?
Existing tests.
---
common/src/main/java/org/apache/uniffle/common/util/JavaUtils.java | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/common/src/main/java/org/apache/uniffle/common/util/JavaUtils.java
b/common/src/main/java/org/apache/uniffle/common/util/JavaUtils.java
index 2f8f6804b..f7489a04e 100644
--- a/common/src/main/java/org/apache/uniffle/common/util/JavaUtils.java
+++ b/common/src/main/java/org/apache/uniffle/common/util/JavaUtils.java
@@ -33,9 +33,12 @@ public class JavaUtils {
private static final Logger logger =
LoggerFactory.getLogger(JavaUtils.class);
private static final String JAVA_9 = "JAVA_9";
+ private static final boolean JAVA9_PLUS =
+ Enums.getIfPresent(JavaVersion.class, JAVA_9).isPresent()
+ && SystemUtils.isJavaVersionAtLeast(JavaVersion.JAVA_9);
+
public static boolean isJavaVersionAtLeastJava9() {
- return Enums.getIfPresent(JavaVersion.class, JAVA_9).isPresent()
- && SystemUtils.isJavaVersionAtLeast(JavaVersion.JAVA_9);
+ return JAVA9_PLUS;
}
/** Closes the given object, ignoring IOExceptions. */