Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
106 commits
Select commit Hold shift + click to select a range
1533d7b
Noop thread using volatile flags and busy wait
petermz Feb 17, 2022
6195b82
Noop thread with safepoints and synchronization
petermz Feb 28, 2022
3dfd353
OldGeneration.scanGreyObjects() runs on worker thread (but logging cr…
petermz Mar 2, 2022
ce6b153
Worker thread synchronizing via a queue, never put on safepoint
petermz Apr 21, 2022
674df60
Two parallel workers synchronizing via queue
petermz Apr 22, 2022
ae4f77f
`releaseSpaces` stage working on 2 background threads
petermz May 31, 2022
7db5c49
Added a custom Timer to HeapImpl
petermz Jun 2, 2022
aef1e38
Parallel `dirtyCardIfNecessary`
petermz Jun 7, 2022
54683ec
Parallel objRef update
petermz Jun 7, 2022
2bfc96e
Passing `original` object safely via Pointer
petermz Jun 8, 2022
7d69248
`installFwPtr` works but not on workers
petermz Jun 8, 2022
f036854
`installForwardingPointer` works on parallel threads
petermz Jun 9, 2022
b8dd7c8
`enableRememberedSetForObject` works in parallel
petermz Jun 9, 2022
ac78015
Protect against promoting an object twice.
petermz Jun 9, 2022
d8b11d0
Uninlined several methods
petermz Jun 21, 2022
0820d8d
Parallel memory allocation in to-space.
petermz Jun 23, 2022
980155b
Better sync strategy in `HeapChunk.walkObjectsFromInline`
petermz Jun 24, 2022
66aa7fc
Simplified parallel invocation, assuming complete gc, innerOffset=0, …
petermz Jun 24, 2022
d526393
Restored call to `Space.promoteAlignedObject()`
petermz Jun 24, 2022
3bf93c0
Restored call to `GCImpl.promoteObject()`
petermz Jun 24, 2022
1b15e01
Restored call to `GreyToBlackObjRefVisitor.visitObjectReferenceInline()`
petermz Jun 24, 2022
043da38
Extended TaskQueue to 1024 task items
petermz Jun 27, 2022
0d936b0
Put objects on the queue rather than refs
petermz Jun 27, 2022
d47b6d2
Don't put G2BObjectVisitor instances on TaskQueue
petermz Jun 28, 2022
239c849
Added max queue size statistic
petermz Jun 28, 2022
e04d49a
Made TaskQueue private in ParallelGCImpl
petermz Jun 28, 2022
6b692e2
Queue grey objects instead of scanning chunks
petermz Jun 28, 2022
69bbd0d
Queue unaligned objects for parallel scan
petermz Jun 30, 2022
23b19ac
TaskQueue fixes: `drain` and `idleCount`
petermz Jun 30, 2022
57e8275
Made TaskQueue reference-free
petermz Jun 30, 2022
c0129b4
Protect `GCImpl.promoteObject` with critical section
petermz Jul 4, 2022
ff66f18
Fixed `TaskQueue.waitUntilIdle`
petermz Jul 4, 2022
af6f70b
Removed locking on fromSpace
petermz Jul 5, 2022
972002c
`scanGreyObjects` cleanup
petermz Jul 6, 2022
b6c5168
Added `ParallelGCImpl.checkThrowable`
petermz Jul 8, 2022
2295b15
Increased queue size for HyperAlloc
petermz Jul 10, 2022
81c02c7
Forwarding pointers done right + VerifyHeap hack
petermz Jul 8, 2022
db7c057
Protected chunk promotion with mutex
petermz Jul 10, 2022
57d2372
Cleanup
petermz Jul 10, 2022
e376e13
Handle queue overflow by executing tasks synchronously
petermz Jul 11, 2022
1c891d1
Cleanup
petermz Jul 11, 2022
7b880b6
Added thread local Stats
petermz Jul 19, 2022
cdf4815
(Incomplete) CAS based queue with minimal synchronization.
petermz Jul 18, 2022
71c515a
Thread local memory allocation
petermz Jul 19, 2022
1d2f791
Retract speculatively allocated memory
petermz Aug 8, 2022
17c695b
Thread local task stacks
petermz Aug 10, 2022
d9a47b7
Post merge cleanup
petermz Aug 12, 2022
ef9c35f
Introduced `UseParallelGC` option
petermz Aug 15, 2022
4c77aa3
Removed some static state from ParallelGCImpl
petermz Aug 16, 2022
3d6b797
Replaced `Space.mutex` with `ParallelGCImpl.mutex`
petermz Aug 16, 2022
4a3c01c
Cleanup: removed Stats printout
petermz Aug 16, 2022
d99ca0f
Enqueue objects as they are copied
petermz Aug 17, 2022
e29e81d
Cleanup
petermz Aug 17, 2022
e068f43
Fixed hangup; better worker thread management
petermz Aug 17, 2022
e67370c
Reuse GC thread as one of the workers
petermz Aug 17, 2022
8e33c3d
Determine number of workers at runtime
petermz Aug 26, 2022
73177bd
Shared synchronized buffer, so far holds object pointers
petermz Sep 15, 2022
060bbd4
Use buffer for aligned chunks instead of objects
petermz Sep 16, 2022
f0a26b7
Support for unaligned chunks
petermz Sep 17, 2022
ec5dd99
HyperAlloc works but load is badly unbalanced
petermz Sep 19, 2022
d59cb36
Report stats for relevant threads only
petermz Sep 19, 2022
c4c4b34
Fixed SerialGC compilation
petermz Oct 3, 2022
c061049
Cleanup
petermz Oct 3, 2022
1dbd6c1
Determine buffer size at runtime
petermz Oct 3, 2022
ca5edac
Removed Stats
petermz Oct 3, 2022
757075f
Cleanup
petermz Oct 4, 2022
01627fc
Fixed crash due to unscanned chunks
petermz Nov 2, 2022
80df70e
Added copyright notices
petermz Nov 3, 2022
b9fed22
Merge branch 'master' of github.com:oracle/graal into parallel-gc
petermz Nov 3, 2022
2a540d3
Fixed merge errors
petermz Nov 10, 2022
f228f74
Fixed Substrate options to work with ParallelGC
petermz Nov 10, 2022
3cbe52e
Post-review renaming and cleanup
petermz Nov 21, 2022
c8ae8a3
Review: forwarding header installation was not atomic enough
petermz Nov 22, 2022
1a22815
Worker thread shutdown
petermz Nov 23, 2022
00a8f37
Made `ChunkBuffer` grow as needed and free memory in the end
petermz Nov 23, 2022
2af8a30
More robust worker thread routine
petermz Nov 25, 2022
b849c4a
Thread safe Reference handling
petermz Dec 7, 2022
14c2047
Made SerialGC options work with ParallelGC
petermz Dec 7, 2022
271134d
Enabled incremental collections
petermz Dec 8, 2022
bced7d1
Use try-finally for mutex locking
petermz Dec 12, 2022
165a8dc
Added assertion to `ParallelGCImpl.getScannedChunk()`
petermz Dec 13, 2022
8ec4ce9
Wait for workers to be blocked before starting parallel phase
petermz Dec 13, 2022
93bfef8
Merge branch 'master' of github.com:oracle/graal into parallel-gc
petermz Dec 13, 2022
e4ec854
Don't retire scanned allocation chunks
petermz Jan 26, 2023
793deff
Merge branch 'master' of github.com:oracle/graal into parallel-gc
petermz Mar 6, 2023
dd32219
Merged ParallelGC and ParallelGCImpl
petermz Mar 7, 2023
d9f38f3
Introduced special SafepointBehavior for worker threads
petermz Mar 7, 2023
ec3b2a5
Style fixes
petermz Mar 7, 2023
1462c2f
Fall back to serial GC if collection occurs before worker threads hav…
petermz Mar 9, 2023
df09255
Style fixes
petermz Mar 14, 2023
7086973
Merge with master.
christianhaeubl Mar 15, 2023
34ad44d
Fix after rebasing to master.
christianhaeubl Mar 13, 2023
35325d6
Make the inner-most part of the GC uninterruptible.
christianhaeubl Mar 15, 2023
5b16c29
Use unattached threads as GC worker threads.
christianhaeubl Mar 15, 2023
f432220
Cleanup and assertion fixes
petermz Mar 16, 2023
22d9dc5
Addressed minor review comments
petermz Mar 20, 2023
43b944d
Adapted to IdentityHash changes
petermz Mar 20, 2023
c824b1b
Worker thread shutdown routine
petermz Mar 20, 2023
13557ba
Merge remote-tracking branch 'upstream/master' into parallel-gc
petermz Mar 20, 2023
5954d36
Report OOME on main GC thread only
petermz Mar 21, 2023
cf486e6
Added javadoc for ParallelGC
petermz Mar 21, 2023
d31e9d7
Workaround for @Uninterruptible visitors
petermz Mar 27, 2023
65e7ad2
Fixed crash due to chunk space being null
petermz Mar 29, 2023
3579f90
Merge branch 'master' of github.com:oracle/graal into parallel-gc
petermz Mar 29, 2023
4f6b3f6
Merge with master.
christianhaeubl Apr 3, 2023
5b47410
Fix object forwarding.
christianhaeubl Apr 3, 2023
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 @@ -243,6 +243,7 @@ public UnsignedWord getCurrentHeapCapacity() {
}

@Override
@Uninterruptible(reason = "Called from uninterruptible code.", mayBeInlined = true)
public UnsignedWord getSurvivorSpacesCapacity() {
assert VMOperation.isGCInProgress() : "use only during GC";
guaranteeSizeParametersInitialized();
Expand Down Expand Up @@ -290,6 +291,7 @@ public UnsignedWord getMaximumFreeAlignedChunksSize() {
}

@Override
@Uninterruptible(reason = "Called from uninterruptible code.", mayBeInlined = true)
public int getTenuringAge() {
assert VMOperation.isGCInProgress() : "use only during GC";
return tenuringThreshold;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ private AlignedHeapChunk() { // all static
public interface AlignedHeader extends HeapChunk.Header<AlignedHeader> {
}

@Uninterruptible(reason = "Called from uninterruptible code.", mayBeInlined = true)
public static void initialize(AlignedHeader chunk, UnsignedWord chunkSize) {
HeapChunk.initialize(chunk, AlignedHeapChunk.getObjectsStart(chunk), chunkSize);
}
Expand All @@ -101,6 +102,7 @@ public static Pointer getObjectsEnd(AlignedHeader that) {
}

/** Allocate uninitialized memory within this AlignedHeapChunk. */
@Uninterruptible(reason = "Called from uninterruptible code.", mayBeInlined = true)
static Pointer allocateMemory(AlignedHeader that, UnsignedWord size) {
Pointer result = WordFactory.nullPointer();
UnsignedWord available = HeapChunk.availableObjectMemory(that);
Expand All @@ -112,6 +114,15 @@ static Pointer allocateMemory(AlignedHeader that, UnsignedWord size) {
return result;
}

/** Retract the latest allocation. Used by parallel collector. */
@Uninterruptible(reason = "Called from uninterruptible code.", mayBeInlined = true)
static Pointer retractAllocation(AlignedHeader that, UnsignedWord size) {
Pointer newTop = HeapChunk.getTopPointer(that).subtract(size);
assert newTop.aboveOrEqual(getObjectsStart(that));
HeapChunk.setTopPointer(that, newTop);
return newTop;
}

@Uninterruptible(reason = "Called from uninterruptible code.", mayBeInlined = true)
static UnsignedWord getCommittedObjectMemory(AlignedHeader that) {
return HeapChunk.getEndOffset(that).subtract(getObjectsStartOffset());
Expand All @@ -129,6 +140,7 @@ public static AlignedHeader getEnclosingChunkFromObjectPointer(Pointer ptr) {
}

/** Return the offset of an object within the objects part of a chunk. */
@Uninterruptible(reason = "Called from uninterruptible code.", mayBeInlined = true)
public static UnsignedWord getObjectOffset(AlignedHeader that, Pointer objectPointer) {
Pointer objectsStart = getObjectsStart(that);
return objectPointer.subtract(objectsStart);
Expand All @@ -139,7 +151,7 @@ static boolean walkObjects(AlignedHeader that, ObjectVisitor visitor) {
}

@AlwaysInline("GC performance")
static boolean walkObjectsInline(AlignedHeader that, ObjectVisitor visitor) {
public static boolean walkObjectsInline(AlignedHeader that, ObjectVisitor visitor) {
return HeapChunk.walkObjectsFromInline(that, getObjectsStart(that), visitor);
}

Expand All @@ -154,7 +166,7 @@ static MemoryWalker.HeapChunkAccess<AlignedHeapChunk.AlignedHeader> getMemoryWal
}

/** Methods for a {@link MemoryWalker} to access an aligned heap chunk. */
@AutomaticallyRegisteredImageSingleton(onlyWith = UseSerialOrEpsilonGC.class)
@AutomaticallyRegisteredImageSingleton(onlyWith = UseMarkAndCopyOrEpsilonGC.class)
static final class MemoryWalkerAccessImpl extends HeapChunk.MemoryWalkerAccessImpl<AlignedHeapChunk.AlignedHeader> {

@Platforms(Platform.HOSTED_ONLY.class)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import org.graalvm.word.WordFactory;

import com.oracle.svm.core.SubstrateGCOptions;
import com.oracle.svm.core.Uninterruptible;
import com.oracle.svm.core.heap.GCCause;
import com.oracle.svm.core.heap.PhysicalMemory;
import com.oracle.svm.core.heap.ReferenceAccess;
Expand Down Expand Up @@ -167,6 +168,7 @@ public UnsignedWord getMaximumSurvivorSize() {
}

@Override
@Uninterruptible(reason = "Called from uninterruptible code.", mayBeInlined = true)
public UnsignedWord getSurvivorSpacesCapacity() {
return WordFactory.zero();
}
Expand Down Expand Up @@ -202,6 +204,7 @@ public final UnsignedWord getMaximumFreeAlignedChunksSize() {
}

@Override
@Uninterruptible(reason = "Called from uninterruptible code.", mayBeInlined = true)
public int getTenuringAge() {
return 1;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ public void reset() {
unalignedChunkBytes = WordFactory.zero();
}

@Uninterruptible(reason = "Called from uninterruptible code.", mayBeInlined = true)
public UnsignedWord getChunkBytes() {
return getAlignedChunkBytes().add(getUnalignedChunkBytes());
}
Expand Down Expand Up @@ -96,6 +97,7 @@ void noteAlignedHeapChunk() {
}
}

@Uninterruptible(reason = "Called from uninterruptible code.", mayBeInlined = true)
void unnoteAlignedHeapChunk() {
alignedCount--;
if (parent != null) {
Expand All @@ -117,10 +119,12 @@ private void noteUnaligned(UnsignedWord size) {
}
}

@Uninterruptible(reason = "Called from uninterruptible code.", mayBeInlined = true)
void unnoteUnalignedHeapChunk(UnalignedHeapChunk.UnalignedHeader chunk) {
unnoteUnaligned(UnalignedHeapChunk.getCommittedObjectMemory(chunk));
}

@Uninterruptible(reason = "Called from uninterruptible code.", mayBeInlined = true)
private void unnoteUnaligned(UnsignedWord size) {
unalignedCount--;
unalignedChunkBytes = unalignedChunkBytes.subtract(size);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import org.graalvm.word.WordFactory;

import com.oracle.svm.core.SubstrateOptions;
import com.oracle.svm.core.Uninterruptible;
import com.oracle.svm.core.heap.GCCause;
import com.oracle.svm.core.heap.PhysicalMemory;
import com.oracle.svm.core.util.UserError;
Expand Down Expand Up @@ -176,6 +177,7 @@ static boolean shouldCollectYoungGenSeparately(boolean defaultValue) {
* survivor-to spaces of all ages. In other words, when copying during a collection, up to 2x
* this amount can be used for surviving objects.
*/
@Uninterruptible(reason = "Called from uninterruptible code.", mayBeInlined = true)
UnsignedWord getSurvivorSpacesCapacity();

/** The capacity of the young generation, comprising the eden and survivor spaces. */
Expand All @@ -200,6 +202,7 @@ static boolean shouldCollectYoungGenSeparately(boolean defaultValue) {
* 1 (straight from eden) and the {@linkplain HeapParameters#getMaxSurvivorSpaces() number of
* survivor spaces + 1}.
*/
@Uninterruptible(reason = "Called from uninterruptible code.", mayBeInlined = true)
int getTenuringAge();

/** Called at the beginning of a collection, in the safepoint operation. */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import org.graalvm.word.WordFactory;

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

/**
Expand Down Expand Up @@ -154,6 +155,7 @@ void beforeCollection(boolean completeCollection) {

/** Called after an object has been promoted from the young generation to the old generation. */
@AlwaysInline("GC performance")
@Uninterruptible(reason = "Called from uninterruptible code.", mayBeInlined = true)
void onSurvivorOverflowed() {
lastIncrementalCollectionOverflowedSurvivors = true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@
import com.oracle.svm.core.genscavenge.BasicCollectionPolicies.NeverCollect;
import com.oracle.svm.core.genscavenge.HeapChunk.Header;
import com.oracle.svm.core.genscavenge.UnalignedHeapChunk.UnalignedHeader;
import com.oracle.svm.core.genscavenge.parallel.ParallelGC;
import com.oracle.svm.core.genscavenge.remset.RememberedSet;
import com.oracle.svm.core.graal.RuntimeCompilation;
import com.oracle.svm.core.heap.CodeReferenceMapDecoder;
Expand Down Expand Up @@ -128,6 +129,8 @@ public final class GCImpl implements GC {
public String getName() {
if (SubstrateOptions.UseEpsilonGC.getValue()) {
return "Epsilon GC";
} else if (SubstrateOptions.UseParallelGC.getValue()) {
return "Parallel GC";
} else {
return "Serial GC";
}
Expand Down Expand Up @@ -198,6 +201,10 @@ private void collectOperation(CollectionVMOperationData data) {
assert VMOperation.isGCInProgress() : "Collection should be a VMOperation.";
assert getCollectionEpoch().equal(data.getRequestingEpoch());

if (SubstrateOptions.UseParallelGC.getValue()) {
ParallelGC.singleton().initialize();
}

timers.mutator.closeAt(data.getRequestingNanoTime());
startCollectionOrExit();

Expand Down Expand Up @@ -525,6 +532,7 @@ public void collectCompletely(GCCause cause) {
collect(cause, true);
}

@Uninterruptible(reason = "Called from uninterruptible code.", mayBeInlined = true)
public boolean isCompleteCollection() {
return completeCollection;
}
Expand Down Expand Up @@ -1052,6 +1060,8 @@ private void scanGreyObjects(boolean isIncremental) {
try {
if (isIncremental) {
scanGreyObjectsLoop();
} else if (ParallelGC.isEnabled()) {
ParallelGC.singleton().waitForIdle();
} else {
HeapImpl.getHeapImpl().getOldGeneration().scanGreyObjects();
}
Expand All @@ -1072,6 +1082,7 @@ private static void scanGreyObjectsLoop() {
}

@AlwaysInline("GC performance")
@Uninterruptible(reason = "Called from uninterruptible code.", mayBeInlined = true)
@SuppressWarnings("static-method")
Object promoteObject(Object original, UnsignedWord header) {
HeapImpl heap = HeapImpl.getHeapImpl();
Expand Down Expand Up @@ -1105,6 +1116,7 @@ Object promoteObject(Object original, UnsignedWord header) {
return result;
}

@Uninterruptible(reason = "Called from uninterruptible code.", mayBeInlined = true)
private static Header<?> getChunk(Object obj, boolean isAligned) {
if (isAligned) {
return AlignedHeapChunk.getEnclosingChunk(obj);
Expand Down Expand Up @@ -1217,7 +1229,8 @@ public static boolean hasNeverCollectPolicy() {
return getPolicy() instanceof NeverCollect;
}

GreyToBlackObjectVisitor getGreyToBlackObjectVisitor() {
@Fold
public GreyToBlackObjectVisitor getGreyToBlackObjectVisitor() {
return greyToBlackObjectVisitor;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public class GenScavengeMemoryPoolMXBeans {

@Platforms(Platform.HOSTED_ONLY.class)
public static MemoryPoolMXBean[] createMemoryPoolMXBeans() {
if (SubstrateOptions.UseSerialGC.getValue()) {
if (SubstrateOptions.useMarkAndCopyGC()) {
mxBeans = new AbstractMemoryPoolMXBean[]{
new EdenMemoryPoolMXBean(YOUNG_GEN_SCAVENGER, COMPLETE_SCAVENGER),
new SurvivorMemoryPoolMXBean(YOUNG_GEN_SCAVENGER, COMPLETE_SCAVENGER),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
import org.graalvm.nativeimage.Platform;
import org.graalvm.nativeimage.Platforms;

import com.oracle.svm.core.AlwaysInline;
import com.oracle.svm.core.Uninterruptible;
import com.oracle.svm.core.heap.ObjectVisitor;
import com.oracle.svm.core.log.Log;

Expand Down Expand Up @@ -66,6 +68,8 @@ public String getName() {
* promotion was done by copying, or {@code null} if there was insufficient capacity in
* this generation.
*/
@AlwaysInline("GC performance")
@Uninterruptible(reason = "Called from uninterruptible code.", mayBeInlined = true)
protected abstract Object promoteAlignedObject(Object original, AlignedHeapChunk.AlignedHeader originalChunk, Space originalSpace);

/**
Expand All @@ -79,6 +83,8 @@ public String getName() {
* was promoted through HeapChunk motion, or {@code null} if there was insufficient
* capacity in this generation.
*/
@AlwaysInline("GC performance")
@Uninterruptible(reason = "Called from uninterruptible code.", mayBeInlined = true)
protected abstract Object promoteUnalignedObject(Object original, UnalignedHeapChunk.UnalignedHeader originalChunk, Space originalSpace);

/**
Expand Down
Loading