From 7c5c2bfbcbdb748232e13945fadb086776dd9d27 Mon Sep 17 00:00:00 2001 From: Fabio Di Fabio Date: Tue, 19 Sep 2023 21:06:42 +0200 Subject: [PATCH] Tune G1GC to reduce Besu memory footprint (#5879) Signed-off-by: Fabio Di Fabio --- CHANGELOG.md | 1 + build.gradle | 22 +++++++++++++++++++--- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 793f5f86378..669a819c586 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,7 @@ ### Additions and Improvements - Layered transaction pool implementation is now stable and enabled by default. If you want still to use the legacy implementation, use `--tx-pool=legacy` [#5772](https://github.com/hyperledger/besu) +- Tune G1GC to reduce Besu memory footprint, and new `besu-untuned` start scripts to run without any specific G1GC flags [#5879](https://github.com/hyperledger/besu/pull/5879) ### Bug Fixes - do not create ignorable storage on revert storage-variables subcommand [#5830](https://github.com/hyperledger/besu/pull/5830) diff --git a/build.gradle b/build.gradle index 05f32e6c2e6..8ce41eb46f1 100644 --- a/build.gradle +++ b/build.gradle @@ -551,6 +551,22 @@ def tweakStartScript(createScriptTask) { } startScripts { + defaultJvmOpts = applicationDefaultJvmArgs + [ + "-XX:G1ConcRefinementThreads=2", + "-XX:G1HeapWastePercent=15", + "-XX:MaxGCPauseMillis=100" + ] + unixStartScriptGenerator.template = resources.text.fromFile("${projectDir}/besu/src/main/scripts/unixStartScript.txt") + windowsStartScriptGenerator.template = resources.text.fromFile("${projectDir}/besu/src/main/scripts/windowsStartScript.txt") + doLast { tweakStartScript(startScripts) } +} + +task untunedStartScripts(type: CreateStartScripts) { + mainClass = 'org.hyperledger.besu.Besu' + classpath = startScripts.classpath + outputDir = startScripts.outputDir + applicationName = 'besu-untuned' + defaultJvmOpts = applicationDefaultJvmArgs unixStartScriptGenerator.template = resources.text.fromFile("${projectDir}/besu/src/main/scripts/unixStartScript.txt") windowsStartScriptGenerator.template = resources.text.fromFile("${projectDir}/besu/src/main/scripts/windowsStartScript.txt") doLast { tweakStartScript(startScripts) } @@ -587,10 +603,10 @@ task autocomplete(type: JavaExec) { } } -installDist { dependsOn checkLicenses, evmToolStartScripts } +installDist { dependsOn checkLicenses, untunedStartScripts, evmToolStartScripts } distTar { - dependsOn checkLicenses, autocomplete, evmToolStartScripts + dependsOn checkLicenses, autocomplete, untunedStartScripts, evmToolStartScripts doFirst { delete fileTree(dir: 'build/distributions', include: '*.tar.gz') } @@ -599,7 +615,7 @@ distTar { } distZip { - dependsOn checkLicenses, autocomplete, evmToolStartScripts + dependsOn checkLicenses, autocomplete, untunedStartScripts, evmToolStartScripts doFirst { delete fileTree(dir: 'build/distributions', include: '*.zip') }