8268122: Add specific gc cause for G1 full collections

Reviewed-by: tschatzl, kbarrett
This commit is contained in:
Stefan Johansson 2021-06-09 14:31:15 +00:00
parent 43e38a18b8
commit caf7f49887
5 changed files with 8 additions and 2 deletions

View File

@ -1139,6 +1139,7 @@ void G1CollectedHeap::do_full_collection(bool clear_all_soft_refs) {
}
bool G1CollectedHeap::upgrade_to_full_collection() {
GCCauseSetter compaction(this, GCCause::_g1_compaction_pause);
log_info(gc, ergo)("Attempting full compaction clearing soft references");
bool success = do_full_collection(false /* explicit gc */,
true /* clear_all_soft_refs */,
@ -1188,6 +1189,7 @@ HeapWord* G1CollectedHeap::satisfy_failed_allocation_helper(size_t word_size,
}
if (do_gc) {
GCCauseSetter compaction(this, GCCause::_g1_compaction_pause);
// Expansion didn't work, we'll try to do a Full GC.
// If maximum_compaction is set we clear all soft references and don't
// allow any dead wood to be left on the heap.

View File

@ -93,6 +93,9 @@ const char* GCCause::to_string(GCCause::Cause cause) {
case _g1_inc_collection_pause:
return "G1 Evacuation Pause";
case _g1_compaction_pause:
return "G1 Compaction Pause";
case _g1_humongous_allocation:
return "G1 Humongous Allocation";

View File

@ -71,6 +71,7 @@ class GCCause : public AllStatic {
_adaptive_size_policy,
_g1_inc_collection_pause,
_g1_compaction_pause,
_g1_humongous_allocation,
_g1_periodic_collection,
_g1_preventive_collection,

View File

@ -40,7 +40,7 @@ public class TestGCCauseWithG1ConcurrentMark {
String testID = "G1ConcurrentMark";
String[] vmFlags = {"-XX:+UseG1GC", "-XX:+ExplicitGCInvokesConcurrent"};
String[] gcNames = {GCHelper.gcG1New, GCHelper.gcG1Old, GCHelper.gcG1Full};
String[] gcCauses = {"G1 Evacuation Pause", "G1 Preventive Collection", "Allocation Failure", "System.gc()"};
String[] gcCauses = {"G1 Evacuation Pause", "G1 Preventive Collection", "G1 Compaction Pause", "System.gc()"};
GCGarbageCollectionUtil.test(testID, vmFlags, gcNames, gcCauses);
}
}

View File

@ -40,7 +40,7 @@ public class TestGCCauseWithG1FullCollection {
String testID = "G1FullCollection";
String[] vmFlags = {"-XX:+UseG1GC"};
String[] gcNames = {GCHelper.gcG1New, GCHelper.gcG1Old, GCHelper.gcG1Full};
String[] gcCauses = {"G1 Evacuation Pause", "G1 Preventive Collection", "Allocation Failure", "System.gc()"};
String[] gcCauses = {"G1 Evacuation Pause", "G1 Preventive Collection", "G1 Compaction Pause", "System.gc()"};
GCGarbageCollectionUtil.test(testID, vmFlags, gcNames, gcCauses);
}
}