Skip to content

Commit 26b20bd

Browse files
gate fixes
1 parent ecc2da1 commit 26b20bd

File tree

6 files changed

+14
-13
lines changed

6 files changed

+14
-13
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ public void configure() {
218218
// This effectively means we reset the debt count upon reconfiguration
219219
accumulatedDebtCarryCount = accumulatedDebtCarryLimit;
220220
avgPopulationSize = 0;
221-
ewmaPopulationSizeAlpha = (double) 1 / windowLookback(next);
221+
ewmaPopulationSizeAlpha = 1.0 / windowLookback(next);
222222
reconfigure = false;
223223
}
224224

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,12 @@
3232
import com.oracle.svm.core.locks.VMMutex;
3333

3434
/**
35-
* Each event that supports throttling has its own throttler that can be accessed through this class.
35+
* Each event that supports throttling has its own throttler that can be accessed through this
36+
* class.
3637
*/
3738
public class JfrThrottlerSupport {
3839
JfrThrottler objectAllocationSampleThrottler;
40+
3941
@Platforms(Platform.HOSTED_ONLY.class)
4042
JfrThrottlerSupport() {
4143
if (HasJfrSupport.get()) {

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

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -83,13 +83,13 @@ public long samplesExpected() {
8383
return samplesPerWindow + debt;
8484
}
8585

86-
public void configure(long debt, double projectedPopSize) {
87-
this.debt = debt;
86+
public void configure(long newDebt, double projectedPopSize) {
87+
this.debt = newDebt;
8888
if (projectedPopSize <= samplesExpected()) {
8989
samplingInterval = 1;
9090
} else {
9191

92-
double projectedProbability = (double) samplesExpected() / projectedPopSize;
92+
double projectedProbability = samplesExpected() / projectedPopSize;
9393
samplingInterval = nextGeometric(projectedProbability, Math.random());
9494
}
9595

@@ -110,12 +110,13 @@ public void configure(long debt, double projectedPopSize) {
110110
* This method is essentially the same as jfrAdaptiveSampler::next_geometric(double, double) in
111111
* the OpenJDK.
112112
*/
113-
private long nextGeometric(double p, double u) {
114-
if (u == 0.0) {
115-
u = 0.01;
113+
private static long nextGeometric(double probability, double u) {
114+
double randomVar = u;
115+
if (randomVar == 0.0) {
116+
randomVar = 0.01;
116117
}
117118
// Inverse CDF for the geometric distribution.
118-
return (long) Math.ceil(log(1.0 - u) / log(1.0 - p));
119+
return (long) Math.ceil(log(1.0 - randomVar) / log(1.0 - probability));
119120
}
120121

121122
public boolean isExpired() {

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -648,7 +648,6 @@ public boolean shouldCommit(JfrEvent event) {
648648
return jfrThrottlerSupport.shouldCommit(event.getId());
649649
}
650650

651-
@Uninterruptible(reason = "Called from uninterruptible code.", mayBeInlined = true)
652651
public boolean setThrottle(long eventTypeId, long eventSampleSize, long periodMs) {
653652
return jfrThrottlerSupport.setThrottle(eventTypeId, eventSampleSize, periodMs);
654653
}

substratevm/src/com.oracle.svm.core/src/com/oracle/svm/core/jfr/events/JfrAllocationEvents.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,7 @@ public static void emit(long startTicks, Class<?> clazz, UnsignedWord allocation
5656

5757
/**
5858
* This method exists as a slight optimization to avoid entering the sampler code if
59-
* unnecessary. We'll have to check {@link JfrEvent.shouldEmit()} again if a sample ends up
60-
* being taken.
59+
* unnecessary. This is required because the sampler code is interruptible.
6160
*/
6261
@Uninterruptible(reason = "Needed for JfrEvent.shouldEmit().")
6362
private static boolean shouldEmitObjectAllocationSample() {

substratevm/src/com.oracle.svm.test/src/com/oracle/svm/test/jfr/TestThrottler.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,7 @@ public void testDistributionLateBurst() { // *** I think its [NOT] bursting ever
324324
* This is a more involved test that checks the sample distribution. It has been adapted from
325325
* JfrGTestAdaptiveSampling in the OpenJDK.
326326
*/
327-
private void testDistribution(IncomingPopulation incomingPopulation, int samplePointsPerWindow, double errorFactor) {
327+
private static void testDistribution(IncomingPopulation incomingPopulation, int samplePointsPerWindow, double errorFactor) {
328328
final int distributionSlots = 100;
329329
final int windowDurationMs = 100;
330330
final int windowCount = 10000;

0 commit comments

Comments
 (0)