< prev index next >
src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp
Print this page
@@ -523,11 +523,15 @@
ergo_verbose1(ErgoHeapSizing,
"attempt heap expansion",
ergo_format_reason("region allocation request failed")
ergo_format_byte("allocation request"),
word_size * HeapWordSize);
- if (expand(word_size * HeapWordSize)) {
+ double expand_heap_start_time_sec = os::elapsedTime();
+ bool expanded = expand(word_size * HeapWordSize);
+ double expand_time_ms = (os::elapsedTime() - expand_heap_start_time_sec) * MILLIUNITS;
+ g1_policy()->phase_times()->record_expand_heap_time(expand_time_ms);
+ if (expanded) {
// Given that expand() succeeded in expanding the heap, and we
// always expand the heap by an amount aligned to the heap
// region size, the free list should in theory not be empty.
// In either case allocate_free_region() will check for NULL.
res = _hrm.allocate_free_region(is_old);
@@ -1544,11 +1548,15 @@
ergo_format_byte("capacity")
ergo_format_byte("occupancy")
ergo_format_byte_perc("min desired capacity"),
capacity_after_gc, used_after_gc,
minimum_desired_capacity, (double) MinHeapFreeRatio);
+ double expand_heap_start_time_sec = os::elapsedTime();
expand(expand_bytes);
+ double expand_heap_end_time_sec = os::elapsedTime();
+ double expand_time_ms = (expand_heap_end_time_sec - expand_heap_start_time_sec) * MILLIUNITS;
+ g1_policy()->phase_times()->record_expand_heap_time(expand_time_ms);
// No expansion, now see if we want to shrink
} else if (capacity_after_gc > maximum_desired_capacity) {
// Capacity too large, compute shrinking size
size_t shrink_bytes = capacity_after_gc - maximum_desired_capacity;
@@ -3972,18 +3980,23 @@
_allocator->init_mutator_alloc_region();
{
size_t expand_bytes = g1_policy()->expansion_amount();
+ double expand_time_ms = 0.0;
if (expand_bytes > 0) {
+ double expand_heap_start_time_sec = os::elapsedTime();
size_t bytes_before = capacity();
// No need for an ergo verbose message here,
// expansion_amount() does this when it returns a value > 0.
if (!expand(expand_bytes)) {
// We failed to expand the heap. Cannot do anything about it.
}
+ double expand_heap_end_time_sec = os::elapsedTime();
+ expand_time_ms = (expand_heap_end_time_sec - expand_heap_start_time_sec) * MILLIUNITS;
}
+ g1_policy()->phase_times()->record_expand_heap_time(expand_time_ms);
}
// We redo the verification but now wrt to the new CSet which
// has just got initialized after the previous CSet was freed.
_cm->verify_no_cset_oops(true /* verify_stacks */,
< prev index next >