From acaa135e529677c67c579855921643d23455ed79 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=B2=20Boschi?= Date: Sat, 2 Apr 2022 00:34:34 +0200 Subject: [PATCH 1/2] Enable netty optimization and BK native IO on jdk17 --- bin/common.sh | 17 ++++++++++++++++- bin/common_gradle.sh | 16 ++++++++++++++-- .../scripts/src/test/bash/bk_test_bin_common.sh | 15 +++++++++++++-- .../src/test/bash/gradle/bk_test_bin_common.sh | 12 +++++++++++- 4 files changed, 54 insertions(+), 6 deletions(-) diff --git a/bin/common.sh b/bin/common.sh index 7949cf9066a..10c25305612 100755 --- a/bin/common.sh +++ b/bin/common.sh @@ -284,7 +284,16 @@ build_cli_jvm_opts() { } build_netty_opts() { + NETTY_OPTS="-Dio.netty.leakDetectionLevel=${NETTY_LEAK_DETECTION_LEVEL}" echo "-Dio.netty.leakDetectionLevel=${NETTY_LEAK_DETECTION_LEVEL}" + + # --add-opens does not exist on jdk8 + if [ "$USING_JDK8" -eq "0" ]; then + # Enable java.nio.DirectByteBuffer + # https://github.com/netty/netty/blob/4.1/common/src/main/java/io/netty/util/internal/PlatformDependent0.java + NETTY_OPTS="$NETTY_OPTS --add-opens java.base/sun.nio=ALL-UNNAMED" + fi + echo $NETTY_OPTS } build_logging_opts() { @@ -312,7 +321,13 @@ build_cli_logging_opts() { } build_bookie_opts() { - echo "-Djava.net.preferIPv4Stack=true" + BOOKIE_OPTS="-Djava.net.preferIPv4Stack=true" + # --add-opens does not exist on jdk8 + if [ "$USING_JDK8" -eq "0" ]; then + # enable posix_fadvise usage in the Journal + BOOKIE_OPTS="$BOOKIE_OPTS --add-opens java.base/java.io=ALL-UNNAMED" + fi + echo $BOOKIE_OPTS } find_table_service() { diff --git a/bin/common_gradle.sh b/bin/common_gradle.sh index 82d8fdb8773..ab06359bea6 100755 --- a/bin/common_gradle.sh +++ b/bin/common_gradle.sh @@ -266,7 +266,13 @@ build_cli_jvm_opts() { } build_netty_opts() { - echo "-Dio.netty.leakDetectionLevel=${NETTY_LEAK_DETECTION_LEVEL}" + # --add-opens does not exist on jdk8 + if [ "$USING_JDK8" -eq "0" ]; then + # Enable java.nio.DirectByteBuffer + # https://github.com/netty/netty/blob/4.1/common/src/main/java/io/netty/util/internal/PlatformDependent0.java + NETTY_OPTS="$NETTY_OPTS --add-opens java.base/sun.nio=ALL-UNNAMED" + fi + echo $NETTY_OPTS } build_logging_opts() { @@ -294,7 +300,13 @@ build_cli_logging_opts() { } build_bookie_opts() { - echo "-Djava.net.preferIPv4Stack=true" + BOOKIE_OPTS="-Djava.net.preferIPv4Stack=true" + # --add-opens does not exist on jdk8 + if [ "$USING_JDK8" -eq "0" ]; then + # enable posix_fadvise usage in the Journal + BOOKIE_OPTS="$BOOKIE_OPTS --add-opens java.base/java.io=ALL-UNNAMED" + fi + echo $BOOKIE_OPTS } find_table_service() { diff --git a/tests/scripts/src/test/bash/bk_test_bin_common.sh b/tests/scripts/src/test/bash/bk_test_bin_common.sh index f95b3dadcd3..a6fe3e2f7a7 100644 --- a/tests/scripts/src/test/bash/bk_test_bin_common.sh +++ b/tests/scripts/src/test/bash/bk_test_bin_common.sh @@ -228,9 +228,13 @@ testBuildNettyOpts() { source ${BK_BINDIR}/common.sh ACTUAL_NETTY_OPTS=$(build_netty_opts) - EXPECTED_NETTY_OPTS="-Dio.netty.leakDetectionLevel=disabled" + if [ "$USING_JDK8" -ne "1" ]; then + EXPECTED_NETTY_OPTS="-Dio.netty.leakDetectionLevel=disabled --add-opens java.base/java.nio=ALL-UNNAMED" + else + EXPECTED_NETTY_OPTS="-Dio.netty.leakDetectionLevel=disabled" + fi - assertEquals "Netty OPTS is not set correctly" "${EXPECTED_NETTY_OPTS}" "${ACTUAL_NETTY_OPTS}" + assertEquals "Netty OPTS is not set correctly" "${EXPECTED_NETTY_OPTS}" "${ACTUAL_NETTY_OPTS}" } testBuildBookieOpts() { @@ -239,6 +243,13 @@ testBuildBookieOpts() { ACTUAL_OPTS=$(build_bookie_opts) EXPECTED_OPTS="-Djava.net.preferIPv4Stack=true" + USEJDK8=$(detect_jdk8) + if [ "$USING_JDK8" -ne "1" ]; then + EXPECTED_OPTS="-Djava.net.preferIPv4Stack=true --add-opens java.base/java.io=ALL-UNNAMED" + else + EXPECTED_OPTS="-Djava.net.preferIPv4Stack=true" + fi + assertEquals "Bookie OPTS is not set correctly" "${EXPECTED_OPTS}" "${ACTUAL_OPTS}" } diff --git a/tests/scripts/src/test/bash/gradle/bk_test_bin_common.sh b/tests/scripts/src/test/bash/gradle/bk_test_bin_common.sh index 152298bbb98..ef942878805 100644 --- a/tests/scripts/src/test/bash/gradle/bk_test_bin_common.sh +++ b/tests/scripts/src/test/bash/gradle/bk_test_bin_common.sh @@ -206,6 +206,11 @@ testBuildNettyOpts() { ACTUAL_NETTY_OPTS=$(build_netty_opts) EXPECTED_NETTY_OPTS="-Dio.netty.leakDetectionLevel=disabled" + if [ "$USING_JDK8" -ne "1" ]; then + EXPECTED_NETTY_OPTS="-Dio.netty.leakDetectionLevel=disabled --add-opens java.base/java.nio=ALL-UNNAMED" + else + EXPECTED_NETTY_OPTS="-Dio.netty.leakDetectionLevel=disabled" + fi assertEquals "Netty OPTS is not set correctly" "${EXPECTED_NETTY_OPTS}" "${ACTUAL_NETTY_OPTS}" } @@ -214,7 +219,12 @@ testBuildBookieOpts() { source ${BK_BINDIR}/common_gradle.sh ACTUAL_OPTS=$(build_bookie_opts) - EXPECTED_OPTS="-Djava.net.preferIPv4Stack=true" + USEJDK8=$(detect_jdk8) + if [ "$USING_JDK8" -ne "1" ]; then + EXPECTED_OPTS="-Djava.net.preferIPv4Stack=true --add-opens java.base/java.io=ALL-UNNAMED" + else + EXPECTED_OPTS="-Djava.net.preferIPv4Stack=true" + fi assertEquals "Bookie OPTS is not set correctly" "${EXPECTED_OPTS}" "${ACTUAL_OPTS}" } From 967e159ea544721e28c4856145214916c05b98da Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=B2=20Boschi?= Date: Thu, 21 Apr 2022 16:37:53 +0200 Subject: [PATCH 2/2] zip and better docs --- bin/common.sh | 9 +++++---- bin/common_gradle.sh | 6 +++++- pom.xml | 1 + tests/scripts/src/test/bash/bk_test_bin_common.sh | 7 ++++--- tests/scripts/src/test/bash/gradle/bk_test_bin_common.sh | 8 ++++---- 5 files changed, 19 insertions(+), 12 deletions(-) diff --git a/bin/common.sh b/bin/common.sh index 10c25305612..38d2e54f596 100755 --- a/bin/common.sh +++ b/bin/common.sh @@ -284,14 +284,13 @@ build_cli_jvm_opts() { } build_netty_opts() { - NETTY_OPTS="-Dio.netty.leakDetectionLevel=${NETTY_LEAK_DETECTION_LEVEL}" - echo "-Dio.netty.leakDetectionLevel=${NETTY_LEAK_DETECTION_LEVEL}" - + NETTY_OPTS="-Dio.netty.leakDetectionLevel=${NETTY_LEAK_DETECTION_LEVEL} -Dio.netty.tryReflectionSetAccessible=true" # --add-opens does not exist on jdk8 if [ "$USING_JDK8" -eq "0" ]; then # Enable java.nio.DirectByteBuffer # https://github.com/netty/netty/blob/4.1/common/src/main/java/io/netty/util/internal/PlatformDependent0.java - NETTY_OPTS="$NETTY_OPTS --add-opens java.base/sun.nio=ALL-UNNAMED" + # https://github.com/netty/netty/issues/12265 + NETTY_OPTS="$NETTY_OPTS --add-opens java.base/java.nio=ALL-UNNAMED --add-opens java.base/jdk.internal.misc=ALL-UNNAMED" fi echo $NETTY_OPTS } @@ -326,6 +325,8 @@ build_bookie_opts() { if [ "$USING_JDK8" -eq "0" ]; then # enable posix_fadvise usage in the Journal BOOKIE_OPTS="$BOOKIE_OPTS --add-opens java.base/java.io=ALL-UNNAMED" + # DirectMemoryCRC32Digest + BOOKIE_OPTS="$BOOKIE_OPTS --add-opens java.base/java.util.zip=ALL-UNNAMED" fi echo $BOOKIE_OPTS } diff --git a/bin/common_gradle.sh b/bin/common_gradle.sh index ab06359bea6..d6e0495af5d 100755 --- a/bin/common_gradle.sh +++ b/bin/common_gradle.sh @@ -266,11 +266,13 @@ build_cli_jvm_opts() { } build_netty_opts() { + NETTY_OPTS="-Dio.netty.leakDetectionLevel=${NETTY_LEAK_DETECTION_LEVEL} -Dio.netty.tryReflectionSetAccessible=true" # --add-opens does not exist on jdk8 if [ "$USING_JDK8" -eq "0" ]; then # Enable java.nio.DirectByteBuffer # https://github.com/netty/netty/blob/4.1/common/src/main/java/io/netty/util/internal/PlatformDependent0.java - NETTY_OPTS="$NETTY_OPTS --add-opens java.base/sun.nio=ALL-UNNAMED" + # https://github.com/netty/netty/issues/12265 + NETTY_OPTS="$NETTY_OPTS --add-opens java.base/java.nio=ALL-UNNAMED --add-opens java.base/jdk.internal.misc=ALL-UNNAMED" fi echo $NETTY_OPTS } @@ -305,6 +307,8 @@ build_bookie_opts() { if [ "$USING_JDK8" -eq "0" ]; then # enable posix_fadvise usage in the Journal BOOKIE_OPTS="$BOOKIE_OPTS --add-opens java.base/java.io=ALL-UNNAMED" + # DirectMemoryCRC32Digest + BOOKIE_OPTS="$BOOKIE_OPTS --add-opens java.base/java.util.zip=ALL-UNNAMED" fi echo $BOOKIE_OPTS } diff --git a/pom.xml b/pom.xml index 886a0c1d4d4..5e7735e303c 100644 --- a/pom.xml +++ b/pom.xml @@ -1226,6 +1226,7 @@ --add-opens java.base/java.util=ALL-UNNAMED --add-opens java.base/java.util.concurrent=ALL-UNNAMED --add-opens java.base/java.util.stream=ALL-UNNAMED + --add-opens java.base/java.util.zip=ALL-UNNAMED --add-opens java.base/java.time=ALL-UNNAMED --add-opens java.base/jdk.internal.loader=ALL-UNNAMED --add-opens java.base/sun.net.dns=ALL-UNNAMED diff --git a/tests/scripts/src/test/bash/bk_test_bin_common.sh b/tests/scripts/src/test/bash/bk_test_bin_common.sh index a6fe3e2f7a7..4af609fa4b6 100644 --- a/tests/scripts/src/test/bash/bk_test_bin_common.sh +++ b/tests/scripts/src/test/bash/bk_test_bin_common.sh @@ -228,10 +228,11 @@ testBuildNettyOpts() { source ${BK_BINDIR}/common.sh ACTUAL_NETTY_OPTS=$(build_netty_opts) + EXPECTED_NETTY_OPTS="" if [ "$USING_JDK8" -ne "1" ]; then - EXPECTED_NETTY_OPTS="-Dio.netty.leakDetectionLevel=disabled --add-opens java.base/java.nio=ALL-UNNAMED" + EXPECTED_NETTY_OPTS="-Dio.netty.leakDetectionLevel=disabled -Dio.netty.tryReflectionSetAccessible=true --add-opens java.base/java.nio=ALL-UNNAMED --add-opens java.base/jdk.internal.misc=ALL-UNNAMED" else - EXPECTED_NETTY_OPTS="-Dio.netty.leakDetectionLevel=disabled" + EXPECTED_NETTY_OPTS="-Dio.netty.leakDetectionLevel=disabled -Dio.netty.tryReflectionSetAccessible=true" fi assertEquals "Netty OPTS is not set correctly" "${EXPECTED_NETTY_OPTS}" "${ACTUAL_NETTY_OPTS}" @@ -245,7 +246,7 @@ testBuildBookieOpts() { USEJDK8=$(detect_jdk8) if [ "$USING_JDK8" -ne "1" ]; then - EXPECTED_OPTS="-Djava.net.preferIPv4Stack=true --add-opens java.base/java.io=ALL-UNNAMED" + EXPECTED_OPTS="-Djava.net.preferIPv4Stack=true --add-opens java.base/java.io=ALL-UNNAMED --add-opens java.base/java.util.zip=ALL-UNNAMED" else EXPECTED_OPTS="-Djava.net.preferIPv4Stack=true" fi diff --git a/tests/scripts/src/test/bash/gradle/bk_test_bin_common.sh b/tests/scripts/src/test/bash/gradle/bk_test_bin_common.sh index ef942878805..c36b6db0247 100644 --- a/tests/scripts/src/test/bash/gradle/bk_test_bin_common.sh +++ b/tests/scripts/src/test/bash/gradle/bk_test_bin_common.sh @@ -205,11 +205,11 @@ testBuildNettyOpts() { source ${BK_BINDIR}/common_gradle.sh ACTUAL_NETTY_OPTS=$(build_netty_opts) - EXPECTED_NETTY_OPTS="-Dio.netty.leakDetectionLevel=disabled" + EXPECTED_NETTY_OPTS="" if [ "$USING_JDK8" -ne "1" ]; then - EXPECTED_NETTY_OPTS="-Dio.netty.leakDetectionLevel=disabled --add-opens java.base/java.nio=ALL-UNNAMED" + EXPECTED_NETTY_OPTS="-Dio.netty.leakDetectionLevel=disabled -Dio.netty.tryReflectionSetAccessible=true --add-opens java.base/java.nio=ALL-UNNAMED --add-opens java.base/jdk.internal.misc=ALL-UNNAMED" else - EXPECTED_NETTY_OPTS="-Dio.netty.leakDetectionLevel=disabled" + EXPECTED_NETTY_OPTS="-Dio.netty.leakDetectionLevel=disabled -Dio.netty.tryReflectionSetAccessible=true" fi assertEquals "Netty OPTS is not set correctly" "${EXPECTED_NETTY_OPTS}" "${ACTUAL_NETTY_OPTS}" @@ -221,7 +221,7 @@ testBuildBookieOpts() { ACTUAL_OPTS=$(build_bookie_opts) USEJDK8=$(detect_jdk8) if [ "$USING_JDK8" -ne "1" ]; then - EXPECTED_OPTS="-Djava.net.preferIPv4Stack=true --add-opens java.base/java.io=ALL-UNNAMED" + EXPECTED_OPTS="-Djava.net.preferIPv4Stack=true --add-opens java.base/java.io=ALL-UNNAMED --add-opens java.base/java.util.zip=ALL-UNNAMED" else EXPECTED_OPTS="-Djava.net.preferIPv4Stack=true" fi