Apache Lucene open-source search software
LUCENE-9861: pull tuned vm options into a separate aspect. (#33)
Dawid Weiss078d0079d1f6
diff --git a/build.gradle b/build.gradleindex 2789d03cc34..31d390eccfe 100644--- a/build.gradle+++ b/build.gradle@@ -184,3 +184,4 @@ apply from: file('gradle/documentation/render-javadoc.gradle')apply from: file('gradle/hacks/gradle-archives.gradle')apply from: file('gradle/hacks/gradle.gradle')apply from: file('gradle/hacks/hashmapAssertions.gradle')+apply from: file('gradle/hacks/turbocharge-jvm-opts.gradle')diff --git a/gradle/documentation/render-javadoc.gradle b/gradle/documentation/render-javadoc.gradleindex eecbffb28c8..4503f8ebb31 100644--- a/gradle/documentation/render-javadoc.gradle+++ b/gradle/documentation/render-javadoc.gradle@@ -297,6 +297,10 @@ class RenderJavadocTask extends DefaultTask {@InputList<String> javadocMissingIgnore = []+ @Input+ @Optional+ ListProperty<String> extraOpts = project.objects.listProperty(String)+@Nullable@Optional@Input@@ -365,6 +369,9 @@ class RenderJavadocTask extends DefaultTask {opts << [ '-quiet' ]+ // Add all extra options, if any.+ opts.addAll(extraOpts.orElse([]).get())+def allOfflineLinks = [:]allOfflineLinks.putAll(offlineLinks)@@ -408,7 +415,16 @@ class RenderJavadocTask extends DefaultTask {opts << [ '--release', 11 ]opts << '-Xdoclint:all,-missing'- // Temporary file that holds all javadoc options for the current task.+ // Increase Javadoc's heap.+ opts += [ "-J-Xmx512m" ]+ // Force locale to be "en_US" (fix for: https://bugs.openjdk.java.net/browse/JDK-8222793)+ opts += [ "-J-Duser.language=en", "-J-Duser.country=US" ]++ // -J options have to be passed on command line, they are not interpreted if passed via args file.+ def jOpts = opts.findAll { opt -> opt instanceof String && opt.startsWith("-J") }+ opts.removeAll(jOpts)++ // Temporary file that holds all javadoc options for the current task (except jOpts)optionsFile.withWriter("UTF-8", { writer ->// escapes an option with single quotes or whitespace to be passed in the options.txt file fordef escapeJavadocOption = { String s -> (s =~ /[ '"]/) ? ("'" + s.replaceAll(/[\\'"]/, /\\$0/) + "'") : s }@@ -456,11 +472,7 @@ class RenderJavadocTask extends DefaultTask {errorOutput = wrappedargs += [ "@${optionsFile}" ]-- // -J flags can't be passed via options file... (an error "javadoc: error - invalid flag: -J-Xmx512m" occurs.)- args += [ "-J-Xmx512m" ]- // force locale to be "en_US" (fix for: https://bugs.openjdk.java.net/browse/JDK-8222793)- args += [ "-J-Duser.language=en", "-J-Duser.country=US" ]+ args += jOptsignoreExitValue true}diff --git a/gradle/hacks/turbocharge-jvm-opts.gradle b/gradle/hacks/turbocharge-jvm-opts.gradlenew file mode 100644index 00000000000..cdb226a89b3--- /dev/null+++ b/gradle/hacks/turbocharge-jvm-opts.gradle@@ -0,0 +1,36 @@+/*+ * Licensed to the Apache Software Foundation (ASF) under one or more+ * contributor license agreements. See the NOTICE file distributed with+ * this work for additional information regarding copyright ownership.+ * The ASF licenses this file to You under the Apache License, Version 2.0+ * (the "License"); you may not use this file except in compliance with+ * the License. You may obtain a copy of the License at+ *+ * http://www.apache.org/licenses/LICENSE-2.0+ *+ * Unless required by applicable law or agreed to in writing, software+ * distributed under the License is distributed on an "AS IS" BASIS,+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+ * See the License for the specific language governing permissions and+ * limitations under the License.+ */++// LUCENE-9861: tune JVM options for short-lived java subprocesses.+allprojects {+ def vmOpts = [+ '-XX:+UseParallelGC',+ '-XX:TieredStopAtLevel=1'+ ]++ // Inject vm options into custom javadoc rendering. We can't refer+ // to the task type because it's dynamic.+ tasks.matching { it.name in ["renderJavadoc", "renderSiteJavadoc"] }.all {+ extraOpts.addAll(vmOpts.collect {"-J" + it})+ }++ // Inject vm options into any JavaExec task... We could narrow it+ // down but I don't think there is any harm in keeping it broad.+ tasks.withType(JavaExec) {+ jvmArgs += vmOpts+ }+}\ No newline at end of filediff --git a/gradle/validation/ecj-lint.gradle b/gradle/validation/ecj-lint.gradleindex 09c4ebef094..7b6415703b9 100644--- a/gradle/validation/ecj-lint.gradle+++ b/gradle/validation/ecj-lint.gradle@@ -74,9 +74,6 @@ allprojects {args += [ "-enableJavadoc" ]args += [ "-properties", file("${resources}/ecj.javadocs.prefs").absolutePath ]- // disable for now because individual file excludes cannot be applied to ecj.- // enabled = false-doFirst {tmpDst.mkdirs()