提交 0dfd4203 编写于 作者: T tongbao.ztb 提交者: 云矅

[Misc] Print the young generation histogram once after parnew gc

Summary:
- Port D65580 to dragonwell
- Print the young generation histogram once after parnew gc with the manageable flag: PrintYoungGenHistoAfterParNewGC

Test Plan: hotspot/test/gc/parNew/testPrintYoungGenHisto.sh

Reviewers: 传胜

Differential Revision: https://aone.alibaba-inc.com/code/D849729
上级 461eaf12
/*
* Copyright (c) 2001, 2014, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2001, 2019, 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
......@@ -40,6 +40,7 @@
#include "memory/genOopClosures.inline.hpp"
#include "memory/generation.hpp"
#include "memory/generation.inline.hpp"
#include "memory/heapInspection.hpp"
#include "memory/referencePolicy.hpp"
#include "memory/resourceArea.hpp"
#include "memory/sharedHeap.hpp"
......@@ -1096,6 +1097,13 @@ void ParNewGeneration::collect(bool full,
_gc_timer->register_gc_end();
// print the young generation histo once after parnew gc then reset the PrintYoungGenHistoAfterParNewGC
if (PrintYoungGenHistoAfterParNewGC) {
HeapInspection inspect(false, false, false, NULL);
inspect.heap_inspection(tty);
PrintYoungGenHistoAfterParNewGC = false;
}
gc_tracer.report_gc_end(_gc_timer->gc_end(), _gc_timer->time_partitions());
}
......
/*
* Copyright (c) 2002, 2014, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2002, 2019, 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
......@@ -26,6 +26,7 @@
#include "classfile/classLoaderData.hpp"
#include "gc_interface/collectedHeap.hpp"
#include "memory/genCollectedHeap.hpp"
#include "memory/generation.hpp"
#include "memory/heapInspection.hpp"
#include "memory/resourceArea.hpp"
#include "runtime/os.hpp"
......@@ -487,8 +488,14 @@ size_t HeapInspection::populate_table(KlassInfoTable* cit, BoolObjectClosure *fi
ResourceMark rm;
RecordInstanceClosure ric(cit, filter);
if (PrintYoungGenHistoAfterParNewGC && UseParNewGC) {
assert(GenCollectedHeap::heap()->n_gens() == 2, "When using ParNew GC, there are only two generations");
GenCollectedHeap::heap()->get_gen(0)->object_iterate(&ric);
return ric.missed_count();
} else {
Universe::heap()->object_iterate(&ric);
return ric.missed_count();
}
}
void HeapInspection::heap_inspection(outputStream* st) {
......
......@@ -27,6 +27,10 @@
// globals_extension.hpp extension
#define AJVM_FLAGS(develop, develop_pd, product, product_pd, diagnostic, experimental, notproduct, manageable, product_rw, lp64_product) \
\
manageable(bool, PrintYoungGenHistoAfterParNewGC, false, \
"print the young generation class histogram after parNew GC") \
//add new AJVM specific flags here
......
/*
* Copyright (c) 2019 Alibaba Group Holding Limited. 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. Alibaba designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* 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.
*
*/
import java.util.ArrayList;
public class TestPrintYoungGenHistoAfterParNewGC {
public static void main(String []args) {
int count = 0;
ArrayList list = new ArrayList();
for (int i = 0; ; i++) {
byte[] data = new byte[1024];
list.add(data);
InnerA aa = new InnerA();
InnerA bb = new InnerA();
if (i % 100000 == 0) {
count++;
list.clear();
if (count > 1000000) {
break;
}
}
}
}
public static class InnerA {
String name;
int id;
String number;
public InnerA() {
name = "hello";
id = 23333;
number = "010110";
}
}
}
#!/bin/sh
#
# Copyright (c) 2019 Alibaba Group Holding Limited. 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. Alibaba designates this
# particular file as subject to the "Classpath" exception as provided
# by Oracle in the LICENSE file that accompanied this code.
#
# 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.
#
# @test
# @summary Test for the young generation histogram once after a parnew gc
# @build TestPrintYoungGenHistoAfterParNewGC
# @run shell testPrintYoungGenHisto.sh
TMP1=tmp_$$
# testing set the VM flag PrintYoungGenHistoAfterParNewGC on the fly by using vm tools(jinfo -flag)
printYongGenHistoTest() {
echo "Tetsting setting the PrintYoungGenHistoAfterParNewGC flag by using the vm tools(jinfo -flag)"
${TESTJAVA}/bin/java ${TESTVMOPTS} -Xmx1g -Xmn500m -verbose:gc -XX:+UseConcMarkSweepGC -XX:+PrintGCDetails \
-cp ${TESTCLASSES} TestPrintYoungGenHistoAfterParNewGC >${TMP1} 2>&1 &
PID=$(ps aux | grep TestPrintYoungGenHistoAfterParNewGC | grep -v "grep" | awk '{print $2}')
echo "hello"
echo $PID
${TESTJAVA}/bin/jinfo -flag +PrintYoungGenHistoAfterParNewGC $PID
sleep 1s
cat ${TMP1}
RESULT=$(cat ${TMP1} | grep -o 'Total' | wc -l)
if [ $RESULT -gt 0 ]
then echo "--- passed as expected "
else
echo "--- failed"
exit 1
fi
kill -9 $PID
}
printYongGenHistoTest
rm ${TMP1}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册