Skip to content

Commit caf7f49

Browse files
committed
8268122: Add specific gc cause for G1 full collections
Reviewed-by: tschatzl, kbarrett
1 parent 43e38a1 commit caf7f49

File tree

5 files changed

+8
-2
lines changed

5 files changed

+8
-2
lines changed

src/hotspot/share/gc/g1/g1CollectedHeap.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1139,6 +1139,7 @@ void G1CollectedHeap::do_full_collection(bool clear_all_soft_refs) {
11391139
}
11401140

11411141
bool G1CollectedHeap::upgrade_to_full_collection() {
1142+
GCCauseSetter compaction(this, GCCause::_g1_compaction_pause);
11421143
log_info(gc, ergo)("Attempting full compaction clearing soft references");
11431144
bool success = do_full_collection(false /* explicit gc */,
11441145
true /* clear_all_soft_refs */,
@@ -1188,6 +1189,7 @@ HeapWord* G1CollectedHeap::satisfy_failed_allocation_helper(size_t word_size,
11881189
}
11891190

11901191
if (do_gc) {
1192+
GCCauseSetter compaction(this, GCCause::_g1_compaction_pause);
11911193
// Expansion didn't work, we'll try to do a Full GC.
11921194
// If maximum_compaction is set we clear all soft references and don't
11931195
// allow any dead wood to be left on the heap.

src/hotspot/share/gc/shared/gcCause.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,9 @@ const char* GCCause::to_string(GCCause::Cause cause) {
9393
case _g1_inc_collection_pause:
9494
return "G1 Evacuation Pause";
9595

96+
case _g1_compaction_pause:
97+
return "G1 Compaction Pause";
98+
9699
case _g1_humongous_allocation:
97100
return "G1 Humongous Allocation";
98101

src/hotspot/share/gc/shared/gcCause.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ class GCCause : public AllStatic {
7171
_adaptive_size_policy,
7272

7373
_g1_inc_collection_pause,
74+
_g1_compaction_pause,
7475
_g1_humongous_allocation,
7576
_g1_periodic_collection,
7677
_g1_preventive_collection,

test/jdk/jdk/jfr/event/gc/collection/TestGCCauseWithG1ConcurrentMark.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public static void main(String[] args) throws Exception {
4040
String testID = "G1ConcurrentMark";
4141
String[] vmFlags = {"-XX:+UseG1GC", "-XX:+ExplicitGCInvokesConcurrent"};
4242
String[] gcNames = {GCHelper.gcG1New, GCHelper.gcG1Old, GCHelper.gcG1Full};
43-
String[] gcCauses = {"G1 Evacuation Pause", "G1 Preventive Collection", "Allocation Failure", "System.gc()"};
43+
String[] gcCauses = {"G1 Evacuation Pause", "G1 Preventive Collection", "G1 Compaction Pause", "System.gc()"};
4444
GCGarbageCollectionUtil.test(testID, vmFlags, gcNames, gcCauses);
4545
}
4646
}

test/jdk/jdk/jfr/event/gc/collection/TestGCCauseWithG1FullCollection.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public static void main(String[] args) throws Exception {
4040
String testID = "G1FullCollection";
4141
String[] vmFlags = {"-XX:+UseG1GC"};
4242
String[] gcNames = {GCHelper.gcG1New, GCHelper.gcG1Old, GCHelper.gcG1Full};
43-
String[] gcCauses = {"G1 Evacuation Pause", "G1 Preventive Collection", "Allocation Failure", "System.gc()"};
43+
String[] gcCauses = {"G1 Evacuation Pause", "G1 Preventive Collection", "G1 Compaction Pause", "System.gc()"};
4444
GCGarbageCollectionUtil.test(testID, vmFlags, gcNames, gcCauses);
4545
}
4646
}

0 commit comments

Comments
 (0)