Skip to content

Commit fe7d3da

Browse files
adjust global buffer defaults
1 parent aab6528 commit fe7d3da

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jfr/JfrOptionSet.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,12 +75,28 @@ public JfrOptionSet() {
7575
}
7676

7777
public void validateAndAdjustMemoryOptions() {
78+
maybeAdjustDefaults();
7879
ensureValidMinimumSizes();
7980
ensureValidMemoryRelations();
8081
adjustMemoryOptions();
8182
assert checkPostCondition();
8283
}
8384

85+
/**
86+
* We expect that Native Image executables will require lesser defaults than JFR on the JVM. So
87+
* to reduce JFR native memory consumption, we use lower default values. We should not adjust
88+
* default values too early (at build time) because if any settings are user defined, we
89+
* shouldn't change any values.
90+
*/
91+
private void maybeAdjustDefaults() {
92+
if (!globalBufferSize.isUserValue() && !globalBufferCount.isUserValue() && !memorySize.isUserValue()) {
93+
globalBufferSize.setValue(globalBufferSize.defaultValue / 2);
94+
globalBufferCount.setValue(globalBufferCount.defaultValue / 2);
95+
// Update record of total size
96+
memorySize.setValue(globalBufferSize.getValue() * globalBufferCount.getValue());
97+
}
98+
}
99+
84100
private void ensureValidMinimumSizes() {
85101
if (memorySize.isUserValue() && memorySize.getValue() < MIN_MEMORY_SIZE) {
86102
throw new IllegalStateException("The value specified for the JFR option 'memorysize' is too low. Please use at least " + MIN_MEMORY_SIZE + " bytes.");

0 commit comments

Comments
 (0)