Skip to content

Commit 266073d

Browse files
committed
[GR-42666] Report correct generation capacities in SerialGCPerfData.
PullRequest: graal/13264
2 parents c1252c0 + b454cc3 commit 266073d

File tree

4 files changed

+42
-5
lines changed

4 files changed

+42
-5
lines changed

substratevm/src/com.oracle.svm.core.genscavenge/src/com/oracle/svm/core/genscavenge/AbstractCollectionPolicy.java

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ public UnsignedWord getMaximumYoungGenerationSize() {
219219
public UnsignedWord getCurrentHeapCapacity() {
220220
assert VMOperation.isGCInProgress() : "use only during GC";
221221
guaranteeSizeParametersInitialized();
222-
return edenSize.add(survivorSize.multiply(2)).add(oldSize);
222+
return edenSize.add(survivorSize).add(oldSize);
223223
}
224224

225225
@Override
@@ -229,6 +229,19 @@ public UnsignedWord getSurvivorSpacesCapacity() {
229229
return survivorSize;
230230
}
231231

232+
@Override
233+
@Uninterruptible(reason = "Ensure reading a consistent value.")
234+
public UnsignedWord getYoungGenerationCapacity() {
235+
guaranteeSizeParametersInitialized();
236+
return edenSize.add(survivorSize);
237+
}
238+
239+
@Override
240+
public UnsignedWord getOldGenerationCapacity() {
241+
guaranteeSizeParametersInitialized();
242+
return oldSize;
243+
}
244+
232245
@Override
233246
public UnsignedWord getMaximumFreeAlignedChunksSize() {
234247
assert VMOperation.isGCInProgress() : "use only during GC";

substratevm/src/com.oracle.svm.core.genscavenge/src/com/oracle/svm/core/genscavenge/BasicCollectionPolicies.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,21 @@ public UnsignedWord getSurvivorSpacesCapacity() {
151151
return WordFactory.zero();
152152
}
153153

154+
@Override
155+
public UnsignedWord getYoungGenerationCapacity() {
156+
return getMaximumYoungGenerationSize();
157+
}
158+
159+
@Override
160+
public UnsignedWord getOldGenerationCapacity() {
161+
UnsignedWord heapCapacity = getCurrentHeapCapacity();
162+
UnsignedWord youngCapacity = getYoungGenerationCapacity();
163+
if (youngCapacity.aboveThan(heapCapacity)) {
164+
return WordFactory.zero(); // should never happen unless options change in between
165+
}
166+
return heapCapacity.subtract(youngCapacity);
167+
}
168+
154169
@Override
155170
public final UnsignedWord getMaximumFreeAlignedChunksSize() {
156171
return getMaximumYoungGenerationSize();

substratevm/src/com.oracle.svm.core.genscavenge/src/com/oracle/svm/core/genscavenge/CollectionPolicy.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,12 @@ static boolean shouldCollectYoungGenSeparately(boolean defaultValue) {
158158
*/
159159
UnsignedWord getSurvivorSpacesCapacity();
160160

161+
/** The capacity of the young generation, comprising the eden and survivor spaces. */
162+
UnsignedWord getYoungGenerationCapacity();
163+
164+
/** The capacity of the old generation. */
165+
UnsignedWord getOldGenerationCapacity();
166+
161167
/**
162168
* The maximum number of bytes that should be kept readily available for allocation or copying
163169
* during collections.

substratevm/src/com.oracle.svm.core.genscavenge/src/com/oracle/svm/core/genscavenge/jvmstat/SerialGCPerfData.java

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
import org.graalvm.nativeimage.Platform;
2929
import org.graalvm.nativeimage.Platforms;
3030

31+
import com.oracle.svm.core.genscavenge.CollectionPolicy;
3132
import com.oracle.svm.core.genscavenge.GCAccounting;
3233
import com.oracle.svm.core.genscavenge.GCImpl;
3334
import com.oracle.svm.core.genscavenge.HeapAccounting;
@@ -94,24 +95,26 @@ public void allocate() {
9495
public void update() {
9596
GCAccounting accounting = GCImpl.getGCImpl().getAccounting();
9697
HeapAccounting heapAccounting = HeapImpl.getHeapImpl().getAccounting();
98+
CollectionPolicy policy = GCImpl.getPolicy();
99+
policy.ensureSizeParametersInitialized();
97100

98-
long maxNewSize = GCImpl.getPolicy().getMaximumYoungGenerationSize().rawValue();
101+
long maxNewSize = policy.getMaximumYoungGenerationSize().rawValue();
99102
youngCollector.invocations.setValue(accounting.getIncrementalCollectionCount());
100103
youngCollector.time.setValue(accounting.getIncrementalCollectionTotalNanos());
101104

102-
youngGen.capacity.setValue(heapAccounting.getYoungUsedBytes().rawValue());
105+
youngGen.capacity.setValue(policy.getYoungGenerationCapacity().rawValue());
103106
youngGen.maxCapacity.setValue(maxNewSize);
104107

105108
youngGen.spaces[0].used.setValue(heapAccounting.getEdenUsedBytes().rawValue());
106109
for (int i = 1; i < youngGen.spaces.length; i++) {
107110
youngGen.spaces[i].used.setValue(heapAccounting.getSurvivorSpaceAfterChunkBytes(i - 1).rawValue());
108111
}
109112

110-
long maxOldSize = GCImpl.getPolicy().getMaximumHeapSize().rawValue() - maxNewSize;
113+
long maxOldSize = policy.getMaximumHeapSize().rawValue() - maxNewSize;
111114
oldCollector.invocations.setValue(accounting.getCompleteCollectionCount());
112115
oldCollector.time.setValue(accounting.getCompleteCollectionTotalNanos());
113116

114-
oldGen.capacity.setValue(accounting.getOldGenerationAfterChunkBytes().rawValue());
117+
oldGen.capacity.setValue(policy.getOldGenerationCapacity().rawValue());
115118
oldGen.maxCapacity.setValue(maxOldSize);
116119

117120
oldGen.spaces[0].used.setValue(accounting.getOldGenerationAfterChunkBytes().rawValue());

0 commit comments

Comments
 (0)