Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ public boolean shouldCollectOnAllocation() {
if (sizes == null) {
return false; // updateSizeParameters() has never been called
}
UnsignedWord edenUsed = HeapImpl.getHeapImpl().getAccounting().getEdenUsedBytes();
UnsignedWord edenUsed = HeapImpl.getAccounting().getEdenUsedBytes();
return edenUsed.aboveOrEqual(edenSize);
}

Expand Down Expand Up @@ -144,8 +144,6 @@ protected void guaranteeSizeParametersInitialized() {

@Override
public void updateSizeParameters() {
PhysicalMemory.tryInitialize();

SizeParameters params = computeSizeParameters(sizes);
SizeParameters previous = sizes;
if (previous != null && params.equal(previous)) {
Expand Down Expand Up @@ -301,7 +299,7 @@ public int getTenuringAge() {
public void onCollectionBegin(boolean completeCollection, long requestingNanoTime) {
// Capture the fraction of bytes in aligned chunks at the start to include all allocated
// (also dead) objects, because we use it to reserve aligned chunks for future allocations
UnsignedWord youngChunkBytes = GCImpl.getGCImpl().getAccounting().getYoungChunkBytesBefore();
UnsignedWord youngChunkBytes = GCImpl.getAccounting().getYoungChunkBytesBefore();
if (youngChunkBytes.notEqual(0)) {
UnsignedWord youngAlignedChunkBytes = HeapImpl.getHeapImpl().getYoungGeneration().getAlignedChunkBytes();
avgYoungGenAlignedChunkFraction.sample(UnsignedUtils.toDouble(youngAlignedChunkBytes) / UnsignedUtils.toDouble(youngChunkBytes));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,9 @@ UnsignedWord getInitialValue() {

abstract UnsignedWord getMaximumValue();

abstract void afterCollection(GCAccounting accounting);
abstract void beforeCollection();

abstract void afterCollection();

MemoryUsage memoryUsage(UnsignedWord usedAndCommitted) {
return new MemoryUsage(getInitialValue().rawValue(), usedAndCommitted.rawValue(), usedAndCommitted.rawValue(), getMaximumValue().rawValue());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,7 @@ public void onCollectionEnd(boolean completeCollection, GCCause cause) { // {maj
timer.reset();
timer.open();

GCAccounting accounting = GCImpl.getGCImpl().getAccounting();
GCAccounting accounting = GCImpl.getAccounting();
UnsignedWord oldLive = accounting.getOldGenerationAfterChunkBytes();
oldSizeExceededInPreviousCollection = oldLive.aboveThan(oldSize);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ protected static UnsignedWord m(long bytes) {

@Override
public boolean shouldCollectOnAllocation() {
UnsignedWord youngUsed = HeapImpl.getHeapImpl().getAccounting().getYoungUsedBytes();
UnsignedWord youngUsed = HeapImpl.getAccounting().getYoungUsedBytes();
return youngUsed.aboveOrEqual(getMaximumYoungGenerationSize());
}

Expand All @@ -79,12 +79,6 @@ public void ensureSizeParametersInitialized() {

@Override
public void updateSizeParameters() {
// Sample the physical memory size, before the first GC but after some allocation.
UnsignedWord allocationBeforeUpdate = WordFactory.unsigned(SerialAndEpsilonGCOptions.AllocationBeforePhysicalMemorySize.getValue());
if (GCImpl.getGCImpl().getCollectionEpoch().equal(WordFactory.zero()) &&
HeapImpl.getHeapImpl().getAccounting().getYoungUsedBytes().aboveOrEqual(allocationBeforeUpdate)) {
PhysicalMemory.tryInitialize();
}
// Size parameters are recomputed from current values whenever they are queried
}

Expand Down Expand Up @@ -287,15 +281,15 @@ public boolean shouldCollectCompletely(boolean followingIncrementalCollection) {
private UnsignedWord estimateUsedHeapAtNextIncrementalCollection() {
UnsignedWord currentYoungBytes = HeapImpl.getHeapImpl().getYoungGeneration().getChunkBytes();
UnsignedWord maxYoungBytes = getMaximumYoungGenerationSize();
UnsignedWord oldBytes = GCImpl.getGCImpl().getAccounting().getOldGenerationAfterChunkBytes();
UnsignedWord oldBytes = GCImpl.getAccounting().getOldGenerationAfterChunkBytes();
return currentYoungBytes.add(maxYoungBytes).add(oldBytes);
}

private static boolean enoughTimeSpentOnIncrementalGCs() {
int incrementalWeight = SerialGCOptions.PercentTimeInIncrementalCollection.getValue();
assert incrementalWeight >= 0 && incrementalWeight <= 100 : "BySpaceAndTimePercentTimeInIncrementalCollection should be in the range [0..100].";

GCAccounting accounting = GCImpl.getGCImpl().getAccounting();
GCAccounting accounting = GCImpl.getAccounting();
long actualIncrementalNanos = accounting.getIncrementalCollectionTotalNanos();
long completeNanos = accounting.getCompleteCollectionTotalNanos();
long totalNanos = actualIncrementalNanos + completeNanos;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
import org.graalvm.word.WordFactory;

import com.oracle.svm.core.Uninterruptible;
import com.oracle.svm.core.log.Log;

/**
* Accounting for a {@link Space} or {@link Generation}. For the eden space, the values are
Expand Down Expand Up @@ -84,12 +83,6 @@ public UnsignedWord getUnalignedChunkBytes() {
return unalignedChunkBytes;
}

void report(Log reportLog) {
reportLog.string("aligned: ").unsigned(getAlignedChunkBytes()).string("/").unsigned(alignedCount);
reportLog.string(" ");
reportLog.string("unaligned: ").unsigned(unalignedChunkBytes).string("/").unsigned(unalignedCount);
}

@Uninterruptible(reason = "Called from uninterruptible code.", mayBeInlined = true)
void noteAlignedHeapChunk() {
alignedCount++;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,12 @@ public CompleteGarbageCollectorMXBean() {

@Override
public long getCollectionCount() {
return HeapImpl.getGCImpl().getAccounting().getCompleteCollectionCount();
return GCImpl.getAccounting().getCompleteCollectionCount();
}

@Override
public long getCollectionTime() {
long nanos = HeapImpl.getGCImpl().getAccounting().getCompleteCollectionTotalNanos();
long nanos = GCImpl.getAccounting().getCompleteCollectionTotalNanos();
return TimeUtils.roundNanosToMillis(nanos);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,10 @@
import com.oracle.svm.core.Uninterruptible;

/**
* This data is only updated during a GC.
* Note that this data may be updated up to 3 times during a single VM operation (incremental GC,
* full GC, full GC that treats soft references as weak). Therefore, this class should only be used
* by GC internal code that is aware of this (could result in incorrect "before"/"after" values
* otherwise). Non-GC code should use the class {@link HeapAccounting} instead.
*
* ChunkBytes refer to bytes reserved (but maybe not occupied). ObjectBytes refer to bytes occupied
* by objects.
Expand All @@ -50,10 +53,7 @@ public final class GCAccounting {
private boolean lastIncrementalCollectionOverflowedSurvivors = false;

/* Before and after measures. */
private UnsignedWord edenChunkBytesBefore = WordFactory.zero();
private UnsignedWord edenChunkBytesAfter = WordFactory.zero();
private UnsignedWord youngChunkBytesBefore = WordFactory.zero();
private UnsignedWord youngChunkBytesAfter = WordFactory.zero();
private UnsignedWord oldChunkBytesBefore = WordFactory.zero();
private UnsignedWord oldChunkBytesAfter = WordFactory.zero();

Expand All @@ -78,10 +78,6 @@ public long getIncrementalCollectionTotalNanos() {
return incrementalCollectionTotalNanos;
}

UnsignedWord getTotalAllocatedChunkBytes() {
return totalAllocatedChunkBytes;
}

public long getCompleteCollectionCount() {
return completeCollectionCount;
}
Expand All @@ -90,6 +86,10 @@ public long getCompleteCollectionTotalNanos() {
return completeCollectionTotalNanos;
}

UnsignedWord getTotalAllocatedChunkBytes() {
return totalAllocatedChunkBytes;
}

UnsignedWord getTotalCollectedChunkBytes() {
return totalCollectedChunkBytes;
}
Expand All @@ -102,26 +102,14 @@ UnsignedWord getAllocatedObjectBytes() {
return allocatedObjectBytes;
}

public UnsignedWord getOldGenerationAfterChunkBytes() {
UnsignedWord getOldGenerationAfterChunkBytes() {
return oldChunkBytesAfter;
}

UnsignedWord getEdenChunkBytesBefore() {
return edenChunkBytesBefore;
}

UnsignedWord getEdenChunkBytesAfter() {
return edenChunkBytesAfter;
}

UnsignedWord getYoungChunkBytesBefore() {
return youngChunkBytesBefore;
}

UnsignedWord getYoungChunkBytesAfter() {
return youngChunkBytesAfter;
}

UnsignedWord getLastIncrementalCollectionPromotedChunkBytes() {
return lastIncrementalCollectionPromotedChunkBytes;
}
Expand All @@ -136,7 +124,6 @@ void beforeCollection(boolean completeCollection) {
YoungGeneration youngGen = heap.getYoungGeneration();
OldGeneration oldGen = heap.getOldGeneration();

edenChunkBytesBefore = youngGen.getEden().getChunkBytes();
youngChunkBytesBefore = youngGen.getChunkBytes();
oldChunkBytesBefore = oldGen.getChunkBytes();

Expand Down Expand Up @@ -192,8 +179,7 @@ private void afterCollectionCommon() {
YoungGeneration youngGen = heap.getYoungGeneration();
OldGeneration oldGen = heap.getOldGeneration();

edenChunkBytesAfter = youngGen.getEden().getChunkBytes();
youngChunkBytesAfter = youngGen.getChunkBytes();
UnsignedWord youngChunkBytesAfter = youngGen.getChunkBytes();
oldChunkBytesAfter = oldGen.getChunkBytes();

UnsignedWord beforeChunkBytes = youngChunkBytesBefore.add(oldChunkBytesBefore);
Expand All @@ -211,9 +197,14 @@ private void afterCollectionCommon() {
if (SerialGCOptions.PrintGCSummary.getValue()) {
UnsignedWord afterObjectBytesAfter = youngGen.computeObjectBytes().add(oldGen.computeObjectBytes());
UnsignedWord beforeObjectBytes = youngObjectBytesBefore.add(oldObjectBytesBefore);
assert beforeObjectBytes.aboveOrEqual(afterObjectBytesAfter);
UnsignedWord collectedObjectBytes = beforeObjectBytes.subtract(afterObjectBytesAfter);
totalCollectedObjectBytes = totalCollectedObjectBytes.add(collectedObjectBytes);
/*
* Object size may increase (e.g., identity hashcode field may be added to promoted
* objects).
*/
if (beforeObjectBytes.aboveOrEqual(afterObjectBytesAfter)) {
UnsignedWord collectedObjectBytes = beforeObjectBytes.subtract(afterObjectBytesAfter);
totalCollectedObjectBytes = totalCollectedObjectBytes.add(collectedObjectBytes);
}
}
}
}
Loading