Skip to content

Commit

Permalink
apacheGH-43394: [Java][Benchmarking] Fix Java benchmarks for Java 17+
Browse files Browse the repository at this point in the history
  • Loading branch information
danepitkin committed Jul 23, 2024
1 parent f95773d commit 3c434ae
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 27 deletions.
29 changes: 4 additions & 25 deletions dev/archery/archery/integration/tester_java.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ def load_version_from_pom():
_JAVA_OPTS = [
"-Dio.netty.tryReflectionSetAccessible=true",
"-Darrow.struct.conflict.policy=CONFLICT_APPEND",
"--add-opens=java.base/java.nio=org.apache.arrow.memory.core,ALL-UNNAMED",
# GH-39113: avoid failures accessing files in `/tmp/hsperfdata_...`
"-XX:-UsePerfData",
]
Expand Down Expand Up @@ -88,24 +89,13 @@ def setup_jpype():
import jpype
jar_path = f"{_ARROW_TOOLS_JAR}:{_ARROW_C_DATA_JAR}"
# XXX Didn't manage to tone down the logging level here (DEBUG -> INFO)
java_opts = _JAVA_OPTS[:]
proc = subprocess.run(
['java', '--add-opens'],
stderr=subprocess.PIPE,
stdout=subprocess.PIPE,
text=True)
if 'Unrecognized option: --add-opens' not in proc.stderr:
# Java 9+
java_opts.append(
'--add-opens=java.base/java.nio='
'org.apache.arrow.memory.core,ALL-UNNAMED')
jpype.startJVM(jpype.getDefaultJVMPath(),
"-Djava.class.path=" + jar_path,
# This flag is too heavy for IPC and Flight tests
"-Darrow.memory.debug.allocator=true",
# Reduce internal use of signals by the JVM
"-Xrs",
*java_opts)
*_JAVA_OPTS)


class _CDataBase:
Expand Down Expand Up @@ -253,20 +243,9 @@ class JavaTester(Tester):

def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
# Detect whether we're on Java 8 or Java 9+
self._java_opts = _JAVA_OPTS[:]
proc = subprocess.run(
['java', '--add-opens'],
stderr=subprocess.PIPE,
stdout=subprocess.PIPE,
text=True)
if 'Unrecognized option: --add-opens' not in proc.stderr:
# Java 9+
self._java_opts.append(
'--add-opens=java.base/java.nio='
'org.apache.arrow.memory.core,ALL-UNNAMED')
self._java_opts.append(
'--add-reads=org.apache.arrow.flight.core=ALL-UNNAMED')
self._java_opts.append(
'--add-reads=org.apache.arrow.flight.core=ALL-UNNAMED')

def _run(self, arrow_path=None, json_path=None, command='VALIDATE'):
cmd = (
Expand Down
12 changes: 10 additions & 2 deletions dev/archery/archery/lang/java.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,22 @@ def __init__(self, jar, *args, **kwargs):


class JavaConfiguration:
def __init__(self,
REQUIRED_JAVA_OPTIONS = [
"--add-opens=java.base/java.nio=org.apache.arrow.memory.core,ALL-UNNAMED",
]

def __init__(self,
# toolchain
java_home=None, java_options=None,
# build & benchmark
build_extras=None, benchmark_extras=None):
self.java_home = java_home
self.java_options = java_options

required_options = " ".join(self.REQUIRED_JAVA_OPTIONS)
if java_options:
self.java_options = java_options + " " + required_options
else:
self.java_options = required_options

self.build_extras = list(build_extras) if build_extras else []
self.benchmark_extras = list(
Expand Down

0 comments on commit 3c434ae

Please sign in to comment.