From 03ea11c50c91c7e2ce317812486d7c62b503df12 Mon Sep 17 00:00:00 2001 From: Foivos Zakkak Date: Tue, 16 Aug 2022 11:15:24 +0300 Subject: [PATCH] Re-enable `ParseOnce` starting with GraalVM / Mandrel 22.2 We no longer need to disable `ParseOnce` as memory usage with it enabled has improved in GraalVM 22.2. See https://docs.google.com/spreadsheets/d/15PJ1Qd7kgneuP61N1T2_AyJ3WBsbXpVHIPKbxgH1qfM/edit#gid=1672873268 for a comparison between using and not using `ParseOnce` with 22.2. Relates to https://github.com/oracle/graal/issues/3435 and https://github.com/graalvm/mandrel/issues/316 Fixes #25944 --- .../pkg/steps/NativeImageBuildStep.java | 28 ++++++++++--------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/core/deployment/src/main/java/io/quarkus/deployment/pkg/steps/NativeImageBuildStep.java b/core/deployment/src/main/java/io/quarkus/deployment/pkg/steps/NativeImageBuildStep.java index 9e4898fef0687..129e351cd2351 100644 --- a/core/deployment/src/main/java/io/quarkus/deployment/pkg/steps/NativeImageBuildStep.java +++ b/core/deployment/src/main/java/io/quarkus/deployment/pkg/steps/NativeImageBuildStep.java @@ -677,19 +677,21 @@ public NativeImageInvokerInfo build() { } nativeImageArgs.add("--features=" + String.join(",", featuresList)); - /* - * Instruct GraalVM / Mandrel parse compiler graphs twice, once for the static analysis and once again - * for the AOT compilation. - * - * We do this because single parsing significantly increases memory usage at build time - * see https://github.com/oracle/graal/issues/3435 and - * https://github.com/graalvm/mandrel/issues/304#issuecomment-952070568 for more details. - * - * Note: This option must come before the invocation of - * {@code handleAdditionalProperties(nativeImageArgs)} to ensure that devs and advanced users can - * override it by passing -Dquarkus.native.additional-build-args=-H:+ParseOnce - */ - nativeImageArgs.add("-H:-ParseOnce"); + if (graalVMVersion.isOlderThan(GraalVM.Version.VERSION_22_2_0)) { + /* + * Instruct GraalVM / Mandrel parse compiler graphs twice, once for the static analysis and once again + * for the AOT compilation. + * + * We do this because single parsing significantly increases memory usage at build time + * see https://github.com/oracle/graal/issues/3435 and + * https://github.com/graalvm/mandrel/issues/304#issuecomment-952070568 for more details. + * + * Note: This option must come before the invocation of + * {@code handleAdditionalProperties(nativeImageArgs)} to ensure that devs and advanced users can + * override it by passing -Dquarkus.native.additional-build-args=-H:+ParseOnce + */ + nativeImageArgs.add("-H:-ParseOnce"); + } /** * This makes sure the Kerberos integration module is made available in case any library