Skip to content

Commit

Permalink
Add AllowUserSignalHandlers.
Browse files Browse the repository at this point in the history
  • Loading branch information
mgm3746 committed Nov 22, 2024
1 parent 53e98f3 commit a4d5542
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 2 deletions.
24 changes: 23 additions & 1 deletion src/main/java/org/github/joa/JvmOptions.java
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,17 @@ public class JvmOptions {
*/
private String aggressiveOpts;

/**
* Option to allow the application to install signal handlers. Disabled by default.
*
* For example:
*
* <pre>
* -XX:+AllowUserSignalHandlers
* </pre>
*/
private String allowUserSignalHandlers;

/**
* Option to enable/disable touching all java heap memory pages on JVM startup.
*
Expand Down Expand Up @@ -2047,6 +2058,7 @@ public class JvmOptions {
* </pre>
*/
private String softRefLRUPolicyMSPerMB;

/**
* The option for starting JDK Flight Recorder (JFR). For example:
*
Expand All @@ -2067,7 +2079,6 @@ public class JvmOptions {
* </pre>
*/
private String startFlightRecording;

/**
* Option to set the number of <code>String</code>s to pool in the String table to optimize memory.
*
Expand Down Expand Up @@ -3092,6 +3103,9 @@ public JvmOptions(JvmContext jvmContext) {
} else if (option.matches("^-XX:[\\-+]AggressiveOpts$")) {
aggressiveOpts = option;
key = "AggressiveOpts";
} else if (option.matches("^-XX:[\\-+]AllowUserSignalHandlers$")) {
allowUserSignalHandlers = option;
key = "AllowUserSignalHandlers";
} else if (option.matches("^-XX:[\\-+]AlwaysPreTouch$")) {
alwaysPreTouch = option;
key = "alwaysPreTouch";
Expand Down Expand Up @@ -4725,6 +4739,10 @@ public void doAnalysis() {
if (JdkUtil.isOptionEnabled(aggressiveOpts)) {
addAnalysis(Analysis.INFO_AGGRESSIVE_OPTS_ENABLED);
}
// Check for -XX:+AllowUserSignalHandlers
if (JdkUtil.isOptionEnabled(allowUserSignalHandlers)) {
addAnalysis(Analysis.INFO_ALLOW_USER_SIGNAL_HANDLERS_ENABLED);
}
// Check for ZGC memory uncommitting disabled.
if (JdkUtil.isOptionDisabled(zUncommit) || ((JdkUtil.isOptionEnabled(useZGc)
|| jvmContext.getGarbageCollectors().contains(GarbageCollector.ZGC_GENERATIONAL)
Expand Down Expand Up @@ -4801,6 +4819,10 @@ public String getAggressiveOpts() {
return aggressiveOpts;
}

public String getAllowUserSignalHandlers() {
return allowUserSignalHandlers;
}

public String getAlwaysPreTouch() {
return alwaysPreTouch;
}
Expand Down
5 changes: 5 additions & 0 deletions src/main/java/org/github/joa/util/Analysis.java
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,11 @@ public enum Analysis {
*/
INFO_AGGRESSIVE_OPTS_ENABLED("info.aggressive.opts.enabled"),

/**
* Property key for allowing user signal handlers with -XX:+AllowUserSignalHandlers.
*/
INFO_ALLOW_USER_SIGNAL_HANDLERS_ENABLED("info.allow.user.signal.handlers.enabled"),

/**
* Property key for biased locking disabled (-XX:-UseBiasedLocking) when it is enabled by default (or the default is
* unknown) and {@link org.github.joa.domain.GarbageCollector#SHENANDOAH} is not identified.
Expand Down
3 changes: 2 additions & 1 deletion src/main/resources/org/github/joa/analysis.properties
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ info.64.d64.redundant=The -d64 flag does not serve a purpose in JDK8 and is remo
info.64.server.redundant=The -server flag no longer serves a purpose in JDK8+ and can be removed, as only the server JIT compiler is included in 64-bit JDKs.
info.active.processor.count=The number of cpu/cores is being explicitly set with -XX:ActiveProcessorCount=N. Unless multiple JVMs and/or processes are collocated and competing for resources, it's generally best to remove this option and let the JVM determine cpu/cores from cgroup settings.
info.aggressive.opts.enabled=-XX:+AggressiveOpts is not a recommended option. It's original intent was to enable/disable various experimental performance optimizations; however, the meaning has varied over time, with functionality removed or integrated. Currently, the only effect is setting 'AutoBoxCacheMax' to 20000 and 'BiasedLockingStartupDelay' to 500. These are questionable settings, but if they are desired, it is recommended to set them directly. Disabled by default, deprecated in JDK11, and removed in JDK17.
info.biased.locking.disabled=Biased locking is explicity disabled with -XX-UseBiasedLocking. Biased locking is a threading optimization that benefits objects that are only locked by a single thread. Enabled by default in JDK8/11, disabled by default and dreprecated in JDK17, and removed in JDK21.
info.allow.user.signal.handlers.enabled=User signal handlers are allowed with -XX:+AllowUserSignalHandlers.
info.biased.locking.disabled=Biased locking is explicitly disabled with -XX-UseBiasedLocking. Biased locking is a threading optimization that benefits objects that are only locked by a single thread. Enabled by default in JDK8/11, disabled by default and dreprecated in JDK17, and removed in JDK21.
info.biased.locking.disabled.redundant=-XX-UseBiasedLocking is redundant (disabled by default) and can be removed. Biased locking is a threading optimization that benefits objects that are only locked by a single thread. Dreprecated in JDK17 and removed in JDK21.
info.biased.locking.enabled=Biased locking is explicitly enabled with -XX+UseBiasedLocking. Biased locking is a threading optimization that benefits objects that are only locked by a single thread. Enabled by default in JDK8/11, disabled by default and dreprecated in JDK17, and removed in JDK21.
info.biased.locking.enabled.redundant=-XX+UseBiasedLocking is redundant (enabled by default) and can be removed. Biased locking is a threading optimization that benefits objects that are only locked by a single thread. Disabled by default and dreprecated in JDK17 and removed in JDK21.
Expand Down
9 changes: 9 additions & 0 deletions src/test/java/org/github/joa/TestJvmOptions.java
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,15 @@ void testAgentLib() {
"JDPA socket transport (debugging) not correct.");
}

@Test
void testAllowUserSignalHandlers() {
String opts = "-Xms1g -XX:+AllowUserSignalHandlers -Xmx1g";
JvmContext context = new JvmContext(opts);
JvmOptions jvmOptions = new JvmOptions(context);
assertEquals("-XX:+AllowUserSignalHandlers", jvmOptions.getAllowUserSignalHandlers(),
"AllowUserSignalHandlers not correct.");
}

@Test
void testBiasedLockingStartupDelay() {
String opts = "-Xms1000m -XX:BiasedLockingStartupDelay=500 -Xmx1500m";
Expand Down
11 changes: 11 additions & 0 deletions src/test/java/org/github/joa/util/TestAnalysis.java
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,17 @@ void testAggressiveOptsEnabled() {
Analysis.INFO_AGGRESSIVE_OPTS_ENABLED + " analysis not identified.");
}

@Test
void testAllowUserSignalHandlersEnabled() {
String opts = "-XX:+AllowUserSignalHandlers";
JvmContext context = new JvmContext(opts);
context.setContainer(true);
JvmOptions jvmOptions = new JvmOptions(context);
jvmOptions.doAnalysis();
assertTrue(jvmOptions.hasAnalysis(Analysis.INFO_ALLOW_USER_SIGNAL_HANDLERS_ENABLED.getKey()),
Analysis.INFO_ALLOW_USER_SIGNAL_HANDLERS_ENABLED + " analysis not identified.");
}

@Test
void testAlwaysPreTouchContainer() {
String opts = "-XX:+AlwaysPreTouch";
Expand Down

0 comments on commit a4d5542

Please sign in to comment.