This is an automated email from the ASF dual-hosted git repository.
uschindler pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/solr.git
The following commit(s) were added to refs/heads/main by this push:
new e9813bd SOLR-15282: pull tuned vm options into a separate aspect
e9813bd is described below
commit e9813bd701be66ddc403c8e32be00c7d4eddcdd5
Author: Dawid Weiss <[email protected]>
AuthorDate: Tue Mar 23 10:39:09 2021 +0100
SOLR-15282: pull tuned vm options into a separate aspect
(cherry picked from commit 078d0079d1f697dde305277b92f0a6792d6843d2,
LUCENE-9861)
# Conflicts:
# build.gradle
---
build.gradle | 1 +
gradle/documentation/render-javadoc.gradle | 24 +++++++++++++++-----
gradle/hacks/turbocharge-jvm-opts.gradle | 36 ++++++++++++++++++++++++++++++
3 files changed, 55 insertions(+), 6 deletions(-)
diff --git a/build.gradle b/build.gradle
index a3be7c0..86938da 100644
--- a/build.gradle
+++ b/build.gradle
@@ -180,6 +180,7 @@ apply from: file('gradle/hacks/solr.findbugs.gradle')
apply from: file('gradle/hacks/gradle.gradle')
apply from: file('gradle/hacks/hashmapAssertions.gradle')
+apply from: file('gradle/hacks/turbocharge-jvm-opts.gradle')
apply from: file('gradle/solr-tlp-migration/inaccessible-test-sources.gradle')
diff --git a/gradle/documentation/render-javadoc.gradle
b/gradle/documentation/render-javadoc.gradle
index a0a35b2..2e462d6 100644
--- a/gradle/documentation/render-javadoc.gradle
+++ b/gradle/documentation/render-javadoc.gradle
@@ -228,6 +228,10 @@ class RenderJavadocTask extends DefaultTask {
@Input
List<String> javadocMissingIgnore = []
+ @Input
+ @Optional
+ ListProperty<String> extraOpts = project.objects.listProperty(String)
+
@Nullable
@Optional
@Input
@@ -296,6 +300,9 @@ class RenderJavadocTask extends DefaultTask {
opts << [ '-quiet' ]
+ // Add all extra options, if any.
+ opts.addAll(extraOpts.orElse([]).get())
+
def allOfflineLinks = [:]
allOfflineLinks.putAll(offlineLinks)
@@ -341,7 +348,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 for
def escapeJavadocOption = { String s -> (s =~ /[ '"]/) ? ("'" +
s.replaceAll(/[\\'"]/, /\\$0/) + "'") : s }
@@ -389,11 +405,7 @@ class RenderJavadocTask extends DefaultTask {
errorOutput = wrapped
args += [ "@${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 += jOpts
ignoreExitValue true
}
diff --git a/gradle/hacks/turbocharge-jvm-opts.gradle
b/gradle/hacks/turbocharge-jvm-opts.gradle
new file mode 100644
index 0000000..cdb226a
--- /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 file