mirror of
https://github.com/vacp2p/status-linea-besu.git
synced 2026-01-09 22:07:59 -05:00
control jemalloc reporting and loading (#7424)
* Implementing Issue #7047 - Optionally load jemalloc Signed-off-by: Antonio Mota <antonio.mota@citi.com> * Implementing Issue #7047 - Optionally load jemalloc Signed-off-by: Antonio Mota <antonio.mota@citi.com> * Implementing Issue #7047 - Optionally load jemalloc: fixes after review Signed-off-by: Antonio Mota <antonio.mota@citi.com> * Implementing Issue #7047 - Optionally load jemalloc: added entry to CHANGELOG Signed-off-by: Antonio Mota <antonio.mota@citi.com> * Changes after review Signed-off-by: Antonio Mota <antonio.mota@citi.com> * Added env var check in unix script Signed-off-by: Antonio Mota <antonio.mota@citi.com> * Improved code and script, build and tested Signed-off-by: amsmota <amsmota@gmail.com> * Improved code and script, build and tested Signed-off-by: amsmota <amsmota@gmail.com> --------- Signed-off-by: Antonio Mota <antonio.mota@citi.com> Signed-off-by: amsmota <amsmota@gmail.com>
This commit is contained in:
@@ -103,6 +103,7 @@ This release version has been deprecated release due to CI bug
|
||||
- Remove long-deprecated `perm*whitelist*` methods [#7401](https://github.com/hyperledger/besu/pull/7401)
|
||||
|
||||
### Additions and Improvements
|
||||
- Allow optional loading of `jemalloc` (if installed) by setting the environment variable `BESU_USING_JEMALLOC` to true/false. It that env is not set at all it will behave as if it is set to `true`
|
||||
- Expose set finalized/safe block in plugin api BlockchainService. These method can be used by plugins to set finalized/safe block for a PoA network (such as QBFT, IBFT and Clique).[#7382](https://github.com/hyperledger/besu/pull/7382)
|
||||
- In process RPC service [#7395](https://github.com/hyperledger/besu/pull/7395)
|
||||
- Added support for tracing private transactions using `priv_traceTransaction` API. [#6161](https://github.com/hyperledger/besu/pull/6161)
|
||||
|
||||
@@ -433,14 +433,18 @@ public class ConfigurationOverviewBuilder {
|
||||
private void detectJemalloc(final List<String> lines) {
|
||||
Optional.ofNullable(Objects.isNull(environment) ? null : environment.get("BESU_USING_JEMALLOC"))
|
||||
.ifPresentOrElse(
|
||||
t -> {
|
||||
jemallocEnabled -> {
|
||||
try {
|
||||
final String version = PlatformDetector.getJemalloc();
|
||||
lines.add("jemalloc: " + version);
|
||||
if (Boolean.parseBoolean(jemallocEnabled)) {
|
||||
final String version = PlatformDetector.getJemalloc();
|
||||
lines.add("jemalloc: " + version);
|
||||
} else {
|
||||
logger.warn(
|
||||
"besu_using_jemalloc is present but is not set to true, jemalloc library not loaded");
|
||||
}
|
||||
} catch (final Throwable throwable) {
|
||||
logger.warn(
|
||||
"BESU_USING_JEMALLOC is present but we failed to load jemalloc library to get the version",
|
||||
throwable);
|
||||
"besu_using_jemalloc is present but we failed to load jemalloc library to get the version");
|
||||
}
|
||||
},
|
||||
() -> {
|
||||
|
||||
@@ -182,19 +182,19 @@ APP_ARGS=`save "\$@"`
|
||||
# Collect all arguments for the java command, following the shell quoting and substitution rules
|
||||
eval set -- \$DEFAULT_JVM_OPTS \$JAVA_OPTS \$${optsEnvironmentVar} <% if ( appNameSystemProperty ) { %>"\"-D${appNameSystemProperty}=\$APP_BASE_NAME\"" <% } %>-classpath "\"\$CLASSPATH\"" <% if ( mainClassName.startsWith('--module ') ) { %>--module-path "\"\$MODULE_PATH\"" <% } %>${mainClassName} "\$APP_ARGS"
|
||||
|
||||
unset BESU_USING_JEMALLOC
|
||||
if [ "\$darwin" = "false" -a "\$msys" = "false" ]; then
|
||||
# check if jemalloc is available
|
||||
TEST_JEMALLOC=\$(LD_PRELOAD=libjemalloc.so sh -c true 2>&1)
|
||||
if [ "\$BESU_USING_JEMALLOC" != "FALSE" -a "\$BESU_USING_JEMALLOC" != "false" ]; then
|
||||
# check if jemalloc is available
|
||||
TEST_JEMALLOC=\$(LD_PRELOAD=libjemalloc.so sh -c true 2>&1)
|
||||
|
||||
# if jemalloc is available the output is empty, otherwise the output has an error line
|
||||
if [ -z "\$TEST_JEMALLOC" ]; then
|
||||
export LD_PRELOAD=libjemalloc.so
|
||||
export BESU_USING_JEMALLOC=true
|
||||
else
|
||||
# jemalloc not available, as fallback limit malloc to 2 arenas
|
||||
export MALLOC_ARENA_MAX=2
|
||||
fi
|
||||
# if jemalloc is available the output is empty, otherwise the output has an error line
|
||||
if [ -z "\$TEST_JEMALLOC" ]; then
|
||||
export LD_PRELOAD=libjemalloc.so
|
||||
else
|
||||
# jemalloc not available, as fallback limit malloc to 2 arenas
|
||||
export MALLOC_ARENA_MAX=2
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
exec "\$JAVACMD" "\$@"
|
||||
|
||||
@@ -37,6 +37,7 @@ import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.ArgumentMatchers.contains;
|
||||
import static org.mockito.ArgumentMatchers.eq;
|
||||
import static org.mockito.ArgumentMatchers.isNotNull;
|
||||
import static org.mockito.Mockito.argThat;
|
||||
import static org.mockito.Mockito.atLeast;
|
||||
import static org.mockito.Mockito.never;
|
||||
import static org.mockito.Mockito.verify;
|
||||
@@ -2412,13 +2413,16 @@ public class BesuCommandTest extends CommandTestAbstract {
|
||||
@Test
|
||||
public void logsWarningWhenFailToLoadJemalloc() {
|
||||
assumeTrue(PlatformDetector.getOSType().equals("linux"));
|
||||
setEnvironmentVariable("BESU_USING_JEMALLOC", "true");
|
||||
setEnvironmentVariable("BESU_USING_JEMALLOC", "false");
|
||||
parseCommand();
|
||||
verify(mockLogger)
|
||||
.warn(
|
||||
eq(
|
||||
"BESU_USING_JEMALLOC is present but we failed to load jemalloc library to get the version"),
|
||||
any(Throwable.class));
|
||||
argThat(
|
||||
arg ->
|
||||
arg.equals(
|
||||
"besu_using_jemalloc is present but is not set to true, jemalloc library not loaded")
|
||||
|| arg.equals(
|
||||
"besu_using_jemalloc is present but we failed to load jemalloc library to get the version")));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
Reference in New Issue
Block a user