Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

8317755: G1: Periodic GC interval should test for the last whole heap GC #16107

Closed
Closed
Changes from 3 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
8 changes: 5 additions & 3 deletions src/hotspot/share/gc/g1/g1PeriodicGCTask.cpp
Original file line number Diff line number Diff line change
@@ -45,10 +45,12 @@ bool G1PeriodicGCTask::should_start_periodic_gc(G1CollectedHeap* g1h,
return false;
}

// Check if enough time has passed since the last whole heap GC.
uintx time_since_last_gc = (uintx)g1h->millis_since_last_whole_heap_examined();
// Check if enough time has passed since the last GC.
uintx time_since_last_gc = G1PeriodicGCCheckWholeHeap ?
(uintx)g1h->millis_since_last_whole_heap_examined() :
(uintx)g1h->time_since_last_collection().milliseconds();
if ((time_since_last_gc < G1PeriodicGCInterval)) {
log_debug(gc, periodic)("Last whole heap GC occurred " UINTX_FORMAT "ms before which is below threshold " UINTX_FORMAT "ms. Skipping.",
log_debug(gc, periodic)("Last GC occurred " UINTX_FORMAT "ms before which is below threshold " UINTX_FORMAT "ms. Skipping.",
time_since_last_gc, G1PeriodicGCInterval);
return false;
}
5 changes: 5 additions & 0 deletions src/hotspot/share/gc/g1/g1_globals.hpp
Original file line number Diff line number Diff line change
@@ -291,6 +291,11 @@
"triggering a periodic gc. A value of zero disables periodically "\
"enforced gc cycles.") \
\
product(bool, G1PeriodicGCCheckWholeHeap, false, \
"Check for recent whole heap GC instead of any recent GC for " \
"periodic GC triggers. Enabling this would trigger periodic GC " \
"even when young GCs happened recently.") \
\
product(bool, G1PeriodicGCInvokesConcurrent, true, \
"Determines the kind of periodic GC. Set to true to have G1 " \
"perform a concurrent GC as periodic GC, otherwise use a STW " \
84 changes: 83 additions & 1 deletion test/hotspot/jtreg/gc/g1/TestPeriodicCollectionWholeHeap.java
Original file line number Diff line number Diff line change
@@ -30,20 +30,41 @@
* @run driver gc.g1.TestPeriodicCollectionWholeHeap young-only
*/

/**
* @test id=young-only-whole
* @requires vm.gc.G1 & vm.flagless
* @library /test/lib /
* @run driver gc.g1.TestPeriodicCollectionWholeHeap young-only-whole
*/

/**
* @test id=concurrent
* @requires vm.gc.G1 & vm.flagless
* @library /test/lib /
* @run driver gc.g1.TestPeriodicCollectionWholeHeap concurrent
*/

/**
* @test id=concurrent-whole
* @requires vm.gc.G1 & vm.flagless
* @library /test/lib /
* @run driver gc.g1.TestPeriodicCollectionWholeHeap concurrent-whole
*/

/**
* @test id=full
* @requires vm.gc.G1 & vm.flagless
* @library /test/lib /
* @run driver gc.g1.TestPeriodicCollectionWholeHeap full
*/

/**
* @test id=full-whole
* @requires vm.gc.G1 & vm.flagless
* @library /test/lib /
* @run driver gc.g1.TestPeriodicCollectionWholeHeap full-whole
*/

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
@@ -73,10 +94,29 @@ public static void main(String[] args) throws Exception {

switch(mode) {

// Young GC should not prevent periodic GC to start.
// Young GC should prevent periodic GC to start.
case "young-only": {
List<String> opts = new ArrayList<>();
opts.add("-XX:G1PeriodicGCInterval=3000");
opts.add("-XX:-G1PeriodicGCCheckWholeHeap");
opts.addAll(commonOpts);

ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(opts);
OutputAnalyzer output = new OutputAnalyzer(pb.start());

output.shouldContain(MSG_YOUNG);
output.shouldNotContain(MSG_CONCURRENT);
output.shouldNotContain(MSG_FULL);
output.shouldNotContain(MSG_PERIODIC);

break;
}

// Young GC should not prevent periodic GC to start.
case "young-only-whole": {
List<String> opts = new ArrayList<>();
opts.add("-XX:G1PeriodicGCInterval=3000");
opts.add("-XX:+G1PeriodicGCCheckWholeHeap");
opts.addAll(commonOpts);

ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(opts);
@@ -95,6 +135,27 @@ public static void main(String[] args) throws Exception {
List<String> opts = new ArrayList<>();
opts.add("-XX:G1PeriodicGCInterval=3000");
opts.add("-XX:+ExplicitGCInvokesConcurrent");
opts.add("-XX:-G1PeriodicGCCheckWholeHeap");
opts.addAll(commonOpts);
opts.add("1000");

ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(opts);
OutputAnalyzer output = new OutputAnalyzer(pb.start());

output.shouldContain(MSG_YOUNG);
output.shouldContain(MSG_CONCURRENT);
output.shouldNotContain(MSG_FULL);
output.shouldNotContain(MSG_PERIODIC);

break;
}

// Periodic GC should not start when concurrent GCs are running frequently.
case "concurrent-whole": {
List<String> opts = new ArrayList<>();
opts.add("-XX:G1PeriodicGCInterval=3000");
opts.add("-XX:+ExplicitGCInvokesConcurrent");
opts.add("-XX:+G1PeriodicGCCheckWholeHeap");
opts.addAll(commonOpts);
opts.add("1000");

@@ -114,6 +175,27 @@ public static void main(String[] args) throws Exception {
List<String> opts = new ArrayList<>();
opts.add("-XX:G1PeriodicGCInterval=3000");
opts.add("-XX:-ExplicitGCInvokesConcurrent");
opts.add("-XX:-G1PeriodicGCCheckWholeHeap");
opts.addAll(commonOpts);
opts.add("1000");

ProcessBuilder pb = ProcessTools.createJavaProcessBuilder(opts);
OutputAnalyzer output = new OutputAnalyzer(pb.start());

output.shouldContain(MSG_YOUNG);
output.shouldNotContain(MSG_CONCURRENT);
output.shouldContain(MSG_FULL);
output.shouldNotContain(MSG_PERIODIC);

break;
}

// Periodic GC should not start when Full GCs are running frequently.
case "full-whole": {
List<String> opts = new ArrayList<>();
opts.add("-XX:G1PeriodicGCInterval=3000");
opts.add("-XX:-ExplicitGCInvokesConcurrent");
opts.add("-XX:+G1PeriodicGCCheckWholeHeap");
opts.addAll(commonOpts);
opts.add("1000");