Skip to content
Closed
Show file tree
Hide file tree
Changes from all 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
55 changes: 25 additions & 30 deletions src/hotspot/share/gc/g1/g1CollectedHeap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -980,7 +980,11 @@ class PostCompactionPrinterClosure: public HeapRegionClosure {
: _hr_printer(hr_printer) { }
};

void G1CollectedHeap::print_hrm_post_compaction() {
void G1CollectedHeap::print_heap_after_full_collection() {
// Post collection region logging.
// We should do this after we potentially resize the heap so
// that all the COMMIT / UNCOMMIT events are generated before
// the compaction events.
if (_hr_printer.is_active()) {
PostCompactionPrinterClosure cl(hr_printer());
heap_region_iterate(&cl);
Expand Down Expand Up @@ -1092,17 +1096,6 @@ void G1CollectedHeap::verify_after_full_collection() {
_ref_processor_cm->verify_no_references_recorded();
}

void G1CollectedHeap::print_heap_after_full_collection(G1HeapTransition* heap_transition) {
// Post collection logging.
// We should do this after we potentially resize the heap so
// that all the COMMIT / UNCOMMIT events are generated before
// the compaction events.
print_hrm_post_compaction();
heap_transition->print();
print_heap_after_gc();
print_heap_regions();
}

bool G1CollectedHeap::do_full_collection(bool explicit_gc,
bool clear_all_soft_refs,
bool do_maximum_compaction) {
Expand Down Expand Up @@ -2572,9 +2565,6 @@ void G1CollectedHeap::trace_heap(GCWhen::Type when, const GCTracer* gc_tracer) {
void G1CollectedHeap::gc_prologue(bool full) {
assert(InlineCacheBuffer::is_empty(), "should have cleaned up ICBuffer");

// This summary needs to be printed before incrementing total collections.
rem_set()->print_periodic_summary_info("Before GC RS summary", total_collections());

// Update common counters.
increment_total_collections(full /* full gc */);
if (full || collector_state()->in_concurrent_start_gc()) {
Expand Down Expand Up @@ -2607,9 +2597,6 @@ void G1CollectedHeap::gc_epilogue(bool full) {
increment_old_marking_cycles_completed(false /* concurrent */, true /* liveness_completed */);
}

// We are at the end of the GC. Total collections has already been increased.
rem_set()->print_periodic_summary_info("After GC RS summary", total_collections() - 1);

#if COMPILER2_OR_JVMCI
assert(DerivedPointerTable::is_empty(), "derived pointer present");
#endif
Expand All @@ -2623,9 +2610,6 @@ void G1CollectedHeap::gc_epilogue(bool full) {
// policy with the new heap occupancy
Universe::heap()->update_capacity_and_used_at_gc();

// Print NUMA statistics.
_numa->print_statistics();

_collection_pause_end = Ticks::now();

_free_card_set_memory_task->notify_new_stats(&_young_gen_card_set_stats,
Expand Down Expand Up @@ -2944,6 +2928,25 @@ class G1YoungGCTraceTime {
}
};

G1CollectedHeap::G1HeapPrinterMark::G1HeapPrinterMark(G1CollectedHeap* g1h) : _g1h(g1h), _heap_transition(g1h) {
// This summary needs to be printed before incrementing total collections.
_g1h->rem_set()->print_periodic_summary_info("Before GC RS summary", _g1h->total_collections());
_g1h->print_heap_before_gc();
_g1h->print_heap_regions();
}

G1CollectedHeap::G1HeapPrinterMark::~G1HeapPrinterMark() {
_g1h->policy()->print_age_table();
_g1h->rem_set()->print_coarsen_stats();

_g1h->print_heap_regions();
_g1h->print_heap_after_gc();
// We are at the end of the GC. Total collections has already been increased.
_g1h->rem_set()->print_periodic_summary_info("After GC RS summary", _g1h->total_collections() - 1);
// Print NUMA statistics.
_g1h->numa()->print_statistics();
}

void G1CollectedHeap::do_collection_pause_at_safepoint_helper(double target_pause_time_ms) {
GCIdMark gc_id_mark;

Expand All @@ -2956,8 +2959,6 @@ void G1CollectedHeap::do_collection_pause_at_safepoint_helper(double target_paus

wait_for_root_region_scanning();

print_heap_before_gc();
print_heap_regions();
trace_heap_before_gc(_gc_tracer_stw);

_verifier->verify_region_sets_optional();
Expand Down Expand Up @@ -3000,7 +3001,7 @@ void G1CollectedHeap::do_collection_pause_at_safepoint_helper(double target_paus
false /* full_gc */,
collector_state()->in_mixed_phase() /* all_memory_pools_affected */);

G1HeapTransition heap_transition(this);
G1HeapPrinterMark hpm(this);

{
IsGCActiveMark x;
Expand Down Expand Up @@ -3079,16 +3080,13 @@ void G1CollectedHeap::do_collection_pause_at_safepoint_helper(double target_paus
}

policy()->print_phases();
heap_transition.print();

_hrm.verify_optional();
_verifier->verify_region_sets_optional();

TASKQUEUE_STATS_ONLY(print_taskqueue_stats());
TASKQUEUE_STATS_ONLY(reset_taskqueue_stats());

print_heap_after_gc();
print_heap_regions();
trace_heap_after_gc(_gc_tracer_stw);

gc_tracer_report_gc_end(concurrent_operation_is_full_mark, evacuation_info);
Expand Down Expand Up @@ -3821,9 +3819,6 @@ void G1CollectedHeap::post_evacuate_collection_set(G1EvacuationInfo& evacuation_

evacuation_info.set_collectionset_used_before(collection_set()->bytes_used_before());
evacuation_info.set_bytes_used(_bytes_used_during_gc);

policy()->print_age_table();
rem_set()->print_coarsen_stats();
}

void G1CollectedHeap::record_obj_copy_mem_stats() {
Expand Down
17 changes: 12 additions & 5 deletions src/hotspot/share/gc/g1/g1CollectedHeap.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -317,10 +317,6 @@ class G1CollectedHeap : public CollectedHeap {
// this method will be found dead by the marking cycle).
void allocate_dummy_regions() PRODUCT_RETURN;

// If the HR printer is active, dump the state of the regions in the
// heap after a compaction.
void print_hrm_post_compaction();

// Create a memory mapper for auxiliary data structures of the given size and
// translation factor.
static G1RegionToSpaceMapper* create_aux_memory_mapper(const char* description,
Expand Down Expand Up @@ -537,7 +533,7 @@ class G1CollectedHeap : public CollectedHeap {
void prepare_heap_for_mutators();
void abort_refinement();
void verify_after_full_collection();
void print_heap_after_full_collection(G1HeapTransition* heap_transition);
void print_heap_after_full_collection();

// Helper method for satisfy_failed_allocation()
HeapWord* satisfy_failed_allocation_helper(size_t word_size,
Expand Down Expand Up @@ -1476,6 +1472,8 @@ class G1CollectedHeap : public CollectedHeap {
void print_regions_on(outputStream* st) const;

public:
class G1HeapPrinterMark;

virtual void print_on(outputStream* st) const;
virtual void print_extended_on(outputStream* st) const;
virtual void print_on_error(outputStream* st) const;
Expand All @@ -1493,6 +1491,15 @@ class G1CollectedHeap : public CollectedHeap {
virtual bool print_location(outputStream* st, void* addr) const;
};

class G1CollectedHeap::G1HeapPrinterMark : public StackObj {
G1CollectedHeap* _g1h;
G1HeapTransition _heap_transition;

public:
G1HeapPrinterMark(G1CollectedHeap* g1h);
~G1HeapPrinterMark();
};

class G1ParEvacuateFollowersClosure : public VoidClosure {
private:
double _start_term;
Expand Down
5 changes: 1 addition & 4 deletions src/hotspot/share/gc/g1/g1FullCollector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -170,9 +170,6 @@ class PrepareRegionsClosure : public HeapRegionClosure {
void G1FullCollector::prepare_collection() {
_heap->policy()->record_full_collection_start();

_heap->print_heap_before_gc();
_heap->print_heap_regions();

_heap->abort_concurrent_cycle();
_heap->verify_before_full_collection(scope()->is_explicit_gc());

Expand Down Expand Up @@ -221,7 +218,7 @@ void G1FullCollector::complete_collection() {

_heap->verify_after_full_collection();

_heap->print_heap_after_full_collection(scope()->heap_transition());
_heap->print_heap_after_full_collection();
}

void G1FullCollector::before_marking_update_attribute_table(HeapRegion* hr) {
Expand Down
6 changes: 1 addition & 5 deletions src/hotspot/share/gc/g1/g1FullGCScope.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ G1FullGCScope::G1FullGCScope(G1MonitoringSupport* monitoring_support,
_cpu_time(),
_soft_refs(clear_soft, _g1h->soft_ref_policy()),
_monitoring_scope(monitoring_support, true /* full_gc */, true /* all_memory_pools_affected */),
_heap_transition(_g1h),
_heap_printer(_g1h),
_region_compaction_threshold(do_maximum_compaction ?
HeapRegion::GrainWords :
(1 - MarkSweepDeadRatio / 100.0) * HeapRegion::GrainWords) {
Expand Down Expand Up @@ -73,10 +73,6 @@ G1FullGCTracer* G1FullGCScope::tracer() {
return &_tracer;
}

G1HeapTransition* G1FullGCScope::heap_transition() {
return &_heap_transition;
}

size_t G1FullGCScope::region_compaction_threshold() {
return _region_compaction_threshold;
}
2 changes: 1 addition & 1 deletion src/hotspot/share/gc/g1/g1FullGCScope.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ class G1FullGCScope : public StackObj {
GCTraceCPUTime _cpu_time;
ClearedAllSoftRefs _soft_refs;
G1MonitoringScope _monitoring_scope;
G1HeapTransition _heap_transition;
G1CollectedHeap::G1HeapPrinterMark _heap_printer;
size_t _region_compaction_threshold;

public:
Expand Down