提交 dfbf6345 编写于 作者: T tonyp

7011855: G1: non-product flag to artificially grow the heap

Summary: It introduces non-product cmd line parameter G1DummyRegionsPerGC which indicates how many "dummy" regions to allocate at the end of each GC. This allows the G1 heap to grow artificially and makes concurrent marking cycles more frequent irrespective of what the application that is running is doing. The dummy regions will be found totally empty during cleanup so this parameter can also be used to stress the concurrent cleanup operation.
Reviewed-by: brutisso, johnc
上级 bec47dff
...@@ -2113,6 +2113,28 @@ bool G1CollectedHeap::should_do_concurrent_full_gc(GCCause::Cause cause) { ...@@ -2113,6 +2113,28 @@ bool G1CollectedHeap::should_do_concurrent_full_gc(GCCause::Cause cause) {
(cause == GCCause::_java_lang_system_gc && ExplicitGCInvokesConcurrent)); (cause == GCCause::_java_lang_system_gc && ExplicitGCInvokesConcurrent));
} }
#ifndef PRODUCT
void G1CollectedHeap::allocate_dummy_regions() {
// Let's fill up most of the region
size_t word_size = HeapRegion::GrainWords - 1024;
// And as a result the region we'll allocate will be humongous.
guarantee(isHumongous(word_size), "sanity");
for (uintx i = 0; i < G1DummyRegionsPerGC; ++i) {
// Let's use the existing mechanism for the allocation
HeapWord* dummy_obj = humongous_obj_allocate(word_size);
if (dummy_obj != NULL) {
MemRegion mr(dummy_obj, word_size);
CollectedHeap::fill_with_object(mr);
} else {
// If we can't allocate once, we probably cannot allocate
// again. Let's get out of the loop.
break;
}
}
}
#endif // !PRODUCT
void G1CollectedHeap::increment_full_collections_completed(bool concurrent) { void G1CollectedHeap::increment_full_collections_completed(bool concurrent) {
MonitorLockerEx x(FullGCCount_lock, Mutex::_no_safepoint_check_flag); MonitorLockerEx x(FullGCCount_lock, Mutex::_no_safepoint_check_flag);
...@@ -3338,6 +3360,8 @@ G1CollectedHeap::do_collection_pause_at_safepoint(double target_pause_time_ms) { ...@@ -3338,6 +3360,8 @@ G1CollectedHeap::do_collection_pause_at_safepoint(double target_pause_time_ms) {
doConcurrentMark(); doConcurrentMark();
} }
allocate_dummy_regions();
#if YOUNG_LIST_VERBOSE #if YOUNG_LIST_VERBOSE
gclog_or_tty->print_cr("\nEnd of the pause.\nYoung_list:"); gclog_or_tty->print_cr("\nEnd of the pause.\nYoung_list:");
_young_list->print(); _young_list->print();
......
...@@ -298,6 +298,14 @@ private: ...@@ -298,6 +298,14 @@ private:
// started is maintained in _total_full_collections in CollectedHeap. // started is maintained in _total_full_collections in CollectedHeap.
volatile unsigned int _full_collections_completed; volatile unsigned int _full_collections_completed;
// This is a non-product method that is helpful for testing. It is
// called at the end of a GC and artificially expands the heap by
// allocating a number of dead regions. This way we can induce very
// frequent marking cycles and stress the cleanup / concurrent
// cleanup code more (as all the regions that will be allocated by
// this method will be found dead by the marking cycle).
void allocate_dummy_regions() PRODUCT_RETURN;
// These are macros so that, if the assert fires, we get the correct // These are macros so that, if the assert fires, we get the correct
// line number, file, etc. // line number, file, etc.
......
...@@ -300,6 +300,11 @@ ...@@ -300,6 +300,11 @@
develop(uintx, G1StressConcRegionFreeingDelayMillis, 0, \ develop(uintx, G1StressConcRegionFreeingDelayMillis, 0, \
"Artificial delay during concurrent region freeing") \ "Artificial delay during concurrent region freeing") \
\ \
develop(uintx, G1DummyRegionsPerGC, 0, \
"The number of dummy regions G1 will allocate at the end of " \
"each evacuation pause in order to artificially fill up the " \
"heap and stress the marking implementation.") \
\
develop(bool, ReduceInitialCardMarksForG1, false, \ develop(bool, ReduceInitialCardMarksForG1, false, \
"When ReduceInitialCardMarks is true, this flag setting " \ "When ReduceInitialCardMarks is true, this flag setting " \
" controls whether G1 allows the RICM optimization") \ " controls whether G1 allows the RICM optimization") \
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册