mirror of
https://github.com/openjdk/jdk.git
synced 2026-02-10 18:38:27 +00:00
8058801: G1TraceReclaimDeadHumongousObjectsAtYoungGC only prints humongous object liveness output when there is at least one candidate humongous object
If G1TraceReclaimDeadHumongousObjectsAtYoungGC is enabled, always print humongous object liveness output. Reviewed-by: tschatzl
This commit is contained in:
parent
8b424b422f
commit
3f18eda414
@ -3612,7 +3612,7 @@ void G1CollectedHeap::register_humongous_regions_with_in_cset_fast_test() {
|
||||
cl.candidate_humongous());
|
||||
_has_humongous_reclaim_candidates = cl.candidate_humongous() > 0;
|
||||
|
||||
if (_has_humongous_reclaim_candidates) {
|
||||
if (_has_humongous_reclaim_candidates || G1TraceReclaimDeadHumongousObjectsAtYoungGC) {
|
||||
clear_humongous_is_live_table();
|
||||
}
|
||||
}
|
||||
@ -6274,9 +6274,10 @@ class G1FreeHumongousRegionClosure : public HeapRegionClosure {
|
||||
g1h->humongous_region_is_always_live(region_idx)) {
|
||||
|
||||
if (G1TraceReclaimDeadHumongousObjectsAtYoungGC) {
|
||||
gclog_or_tty->print_cr("Live humongous %d region %d with remset "SIZE_FORMAT" code roots "SIZE_FORMAT" is marked %d live-other %d obj array %d",
|
||||
gclog_or_tty->print_cr("Live humongous %d region %d size "SIZE_FORMAT" with remset "SIZE_FORMAT" code roots "SIZE_FORMAT" is marked %d live-other %d obj array %d",
|
||||
r->is_humongous(),
|
||||
region_idx,
|
||||
obj->size()*HeapWordSize,
|
||||
r->rem_set()->occupied(),
|
||||
r->rem_set()->strong_code_roots_list_length(),
|
||||
next_bitmap->isMarked(r->bottom()),
|
||||
@ -6293,8 +6294,9 @@ class G1FreeHumongousRegionClosure : public HeapRegionClosure {
|
||||
r->bottom()));
|
||||
|
||||
if (G1TraceReclaimDeadHumongousObjectsAtYoungGC) {
|
||||
gclog_or_tty->print_cr("Reclaim humongous region %d start "PTR_FORMAT" region %d length "UINT32_FORMAT" with remset "SIZE_FORMAT" code roots "SIZE_FORMAT" is marked %d live-other %d obj array %d",
|
||||
gclog_or_tty->print_cr("Reclaim humongous region %d size "SIZE_FORMAT" start "PTR_FORMAT" region %d length "UINT32_FORMAT" with remset "SIZE_FORMAT" code roots "SIZE_FORMAT" is marked %d live-other %d obj array %d",
|
||||
r->is_humongous(),
|
||||
obj->size()*HeapWordSize,
|
||||
r->bottom(),
|
||||
region_idx,
|
||||
r->region_num(),
|
||||
@ -6333,7 +6335,8 @@ class G1FreeHumongousRegionClosure : public HeapRegionClosure {
|
||||
void G1CollectedHeap::eagerly_reclaim_humongous_regions() {
|
||||
assert_at_safepoint(true);
|
||||
|
||||
if (!G1ReclaimDeadHumongousObjectsAtYoungGC || !_has_humongous_reclaim_candidates) {
|
||||
if (!G1ReclaimDeadHumongousObjectsAtYoungGC ||
|
||||
(!_has_humongous_reclaim_candidates && !G1TraceReclaimDeadHumongousObjectsAtYoungGC)) {
|
||||
g1_policy()->phase_times()->record_fast_reclaim_humongous_time_ms(0.0, 0);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -0,0 +1,142 @@
|
||||
/*
|
||||
* Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
/*
|
||||
* @test TestG1TraceReclaimDeadHumongousObjectsAtYoungGC
|
||||
* @bug 8058801
|
||||
* @summary Ensure that the output for a G1TraceReclaimDeadHumongousObjectsAtYoungGC
|
||||
* includes the expected necessary messages.
|
||||
* @key gc
|
||||
* @library /testlibrary
|
||||
*/
|
||||
|
||||
import com.oracle.java.testlibrary.ProcessTools;
|
||||
import com.oracle.java.testlibrary.OutputAnalyzer;
|
||||
import java.util.LinkedList;
|
||||
|
||||
public class TestG1TraceReclaimDeadHumongousObjectsAtYoungGC {
|
||||
public static void main(String[] args) throws Exception {
|
||||
testGCLogs();
|
||||
testHumongousObjectGCLogs();
|
||||
}
|
||||
|
||||
private static void testGCLogs() throws Exception {
|
||||
|
||||
ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-XX:+UseG1GC",
|
||||
"-Xms128M",
|
||||
"-Xmx128M",
|
||||
"-Xmn16M",
|
||||
"-XX:G1HeapRegionSize=1M",
|
||||
"-XX:+PrintGC",
|
||||
"-XX:+UnlockExperimentalVMOptions",
|
||||
"-XX:G1LogLevel=finest",
|
||||
"-XX:+G1TraceReclaimDeadHumongousObjectsAtYoungGC",
|
||||
GCTest.class.getName());
|
||||
|
||||
OutputAnalyzer output = new OutputAnalyzer(pb.start());
|
||||
|
||||
// As G1ReclaimDeadHumongousObjectsAtYoungGC is set(default), below logs should be displayed.
|
||||
// And GCTest doesn't have humongous objects, so values should be zero.
|
||||
output.shouldContain("[Humongous Reclaim");
|
||||
output.shouldContain("[Humongous Total: 0]");
|
||||
output.shouldContain("[Humongous Candidate: 0]");
|
||||
output.shouldContain("[Humongous Reclaimed: 0]");
|
||||
|
||||
output.shouldHaveExitValue(0);
|
||||
}
|
||||
|
||||
private static void testHumongousObjectGCLogs() throws Exception {
|
||||
ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-XX:+UseG1GC",
|
||||
"-Xms128M",
|
||||
"-Xmx128M",
|
||||
"-Xmn16M",
|
||||
"-XX:G1HeapRegionSize=1M",
|
||||
"-XX:+PrintGC",
|
||||
"-XX:+UnlockExperimentalVMOptions",
|
||||
"-XX:G1LogLevel=finest",
|
||||
"-XX:+G1TraceReclaimDeadHumongousObjectsAtYoungGC",
|
||||
GCWithHumongousObjectTest.class.getName());
|
||||
|
||||
OutputAnalyzer output = new OutputAnalyzer(pb.start());
|
||||
|
||||
// As G1ReclaimDeadHumongousObjectsAtYoungGC is set(default), below logs should be displayed.
|
||||
output.shouldContain("[Humongous Reclaim");
|
||||
output.shouldContain("[Humongous Total");
|
||||
output.shouldContain("[Humongous Candidate");
|
||||
output.shouldContain("[Humongous Reclaimed");
|
||||
|
||||
// As G1TraceReclaimDeadHumongousObjectsAtYoungGC is set and GCWithHumongousObjectTest has humongous objects,
|
||||
// these logs should be displayed.
|
||||
output.shouldContain("Live humongous");
|
||||
output.shouldContain("Reclaim humongous region");
|
||||
output.shouldHaveExitValue(0);
|
||||
}
|
||||
|
||||
static class GCTest {
|
||||
private static byte[] garbage;
|
||||
|
||||
public static void main(String [] args) {
|
||||
System.out.println("Creating garbage");
|
||||
// create 128MB of garbage. This should result in at least one GC
|
||||
for (int i = 0; i < 1024; i++) {
|
||||
garbage = new byte[128 * 1024];
|
||||
}
|
||||
System.out.println("Done");
|
||||
}
|
||||
}
|
||||
|
||||
static class GCWithHumongousObjectTest {
|
||||
|
||||
public static final int M = 1024*1024;
|
||||
public static LinkedList<Object> garbageList = new LinkedList<Object>();
|
||||
// A large object referenced by a static.
|
||||
static int[] filler = new int[10 * M];
|
||||
|
||||
public static void genGarbage() {
|
||||
for (int i = 0; i < 32*1024; i++) {
|
||||
garbageList.add(new int[100]);
|
||||
}
|
||||
garbageList.clear();
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
||||
int[] large = new int[M];
|
||||
Object ref = large;
|
||||
|
||||
System.out.println("Creating garbage");
|
||||
for (int i = 0; i < 100; i++) {
|
||||
// A large object that will be reclaimed eagerly.
|
||||
large = new int[6*M];
|
||||
genGarbage();
|
||||
// Make sure that the compiler cannot completely remove
|
||||
// the allocation of the large object until here.
|
||||
System.out.println(large);
|
||||
}
|
||||
|
||||
// Keep the reference to the first object alive.
|
||||
System.out.println(ref);
|
||||
System.out.println("Done");
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user