8246274: G1 old gen allocation tracking is not in a separate class
Add G1OldGenAllocationTracker Reviewed-by: tschatzl, phh
This commit is contained in:
parent
1b59097077
commit
9a88048a05
@ -871,7 +871,8 @@ HeapWord* G1CollectedHeap::attempt_allocation_humongous(size_t word_size) {
|
||||
result = humongous_obj_allocate(word_size);
|
||||
if (result != NULL) {
|
||||
size_t size_in_regions = humongous_obj_size_in_regions(word_size);
|
||||
policy()->add_bytes_allocated_in_old_since_last_gc(size_in_regions * HeapRegion::GrainBytes);
|
||||
policy()->old_gen_alloc_tracker()->
|
||||
add_allocated_bytes_since_last_gc(size_in_regions * HeapRegion::GrainBytes);
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -4092,7 +4093,8 @@ void G1CollectedHeap::post_evacuate_collection_set(G1EvacuationInfo& evacuation_
|
||||
}
|
||||
|
||||
void G1CollectedHeap::record_obj_copy_mem_stats() {
|
||||
policy()->add_bytes_allocated_in_old_since_last_gc(_old_evac_stats.allocated() * HeapWordSize);
|
||||
policy()->old_gen_alloc_tracker()->
|
||||
add_allocated_bytes_since_last_gc(_old_evac_stats.allocated() * HeapWordSize);
|
||||
|
||||
_gc_tracer_stw->report_evacuation_statistics(create_g1_evac_summary(&_survivor_evac_stats),
|
||||
create_g1_evac_summary(&_old_evac_stats));
|
||||
@ -4193,7 +4195,7 @@ class G1FreeCollectionSetTask : public AbstractGangTask {
|
||||
g1h->alloc_buffer_stats(G1HeapRegionAttr::Old)->add_failure_used_and_waste(_failure_used_words, _failure_waste_words);
|
||||
|
||||
G1Policy *policy = g1h->policy();
|
||||
policy->add_bytes_allocated_in_old_since_last_gc(_bytes_allocated_in_old_since_last_gc);
|
||||
policy->old_gen_alloc_tracker()->add_allocated_bytes_since_last_gc(_bytes_allocated_in_old_since_last_gc);
|
||||
policy->record_rs_length(_rs_length);
|
||||
policy->cset_regions_freed();
|
||||
}
|
||||
|
42
src/hotspot/share/gc/g1/g1OldGenAllocationTracker.cpp
Normal file
42
src/hotspot/share/gc/g1/g1OldGenAllocationTracker.cpp
Normal file
@ -0,0 +1,42 @@
|
||||
/*
|
||||
* Copyright (c) 2020, Amazon.com, Inc. 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.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "precompiled.hpp"
|
||||
#include "gc/g1/g1OldGenAllocationTracker.hpp"
|
||||
|
||||
G1OldGenAllocationTracker::G1OldGenAllocationTracker() :
|
||||
_last_cycle_old_bytes(0),
|
||||
_last_cycle_duration(0.0),
|
||||
_allocated_bytes_since_last_gc(0) {
|
||||
}
|
||||
|
||||
void G1OldGenAllocationTracker::reset_after_full_gc() {
|
||||
_last_cycle_duration = 0;
|
||||
reset_cycle_after_gc();
|
||||
}
|
||||
|
||||
void G1OldGenAllocationTracker::reset_after_young_gc(double allocation_duration_s) {
|
||||
_last_cycle_duration = allocation_duration_s;
|
||||
reset_cycle_after_gc();
|
||||
}
|
61
src/hotspot/share/gc/g1/g1OldGenAllocationTracker.hpp
Normal file
61
src/hotspot/share/gc/g1/g1OldGenAllocationTracker.hpp
Normal file
@ -0,0 +1,61 @@
|
||||
/*
|
||||
* Copyright (c) 2020, Amazon.com, Inc. 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.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef SHARE_VM_GC_G1_G1OLDGENALLOCATIONTRACKER_HPP
|
||||
#define SHARE_VM_GC_G1_G1OLDGENALLOCATIONTRACKER_HPP
|
||||
|
||||
#include "gc/g1/heapRegion.hpp"
|
||||
#include "memory/allocation.hpp"
|
||||
|
||||
// Track allocation details in the old generation.
|
||||
class G1OldGenAllocationTracker : public CHeapObj<mtGC> {
|
||||
// New bytes allocated in old gen between the end of the last GC and
|
||||
// the end of the GC before that.
|
||||
size_t _last_cycle_old_bytes;
|
||||
// The number of seconds between the end of the last GC and
|
||||
// the end of the GC before that.
|
||||
double _last_cycle_duration;
|
||||
|
||||
size_t _allocated_bytes_since_last_gc;
|
||||
|
||||
void reset_cycle_after_gc() {
|
||||
_last_cycle_old_bytes = _allocated_bytes_since_last_gc;
|
||||
_allocated_bytes_since_last_gc = 0;
|
||||
}
|
||||
|
||||
public:
|
||||
G1OldGenAllocationTracker();
|
||||
// Add the given number of bytes to the total number of allocated bytes in the old gen.
|
||||
void add_allocated_bytes_since_last_gc(size_t bytes) { _allocated_bytes_since_last_gc += bytes; }
|
||||
|
||||
size_t last_cycle_old_bytes() { return _last_cycle_old_bytes; }
|
||||
|
||||
double last_cycle_duration() { return _last_cycle_duration; }
|
||||
|
||||
// Reset stats after a collection.
|
||||
void reset_after_full_gc();
|
||||
void reset_after_young_gc(double allocation_duration_s);
|
||||
};
|
||||
|
||||
#endif // SHARE_VM_GC_G1_G1OLDGENALLOCATIONTRACKER_HPP
|
@ -73,7 +73,7 @@ G1Policy::G1Policy(STWGCTimer* gc_timer) :
|
||||
_rs_length(0),
|
||||
_rs_length_prediction(0),
|
||||
_pending_cards_at_gc_start(0),
|
||||
_bytes_allocated_in_old_since_last_gc(0),
|
||||
_old_gen_alloc_tracker(),
|
||||
_initial_mark_to_mixed(),
|
||||
_collection_set(NULL),
|
||||
_g1h(NULL),
|
||||
@ -460,7 +460,7 @@ void G1Policy::record_full_collection_end() {
|
||||
update_young_list_max_and_target_length();
|
||||
update_rs_length_prediction();
|
||||
|
||||
_bytes_allocated_in_old_since_last_gc = 0;
|
||||
_old_gen_alloc_tracker.reset_after_full_gc();
|
||||
|
||||
record_pause(FullGC, _full_collection_start_sec, end_sec);
|
||||
}
|
||||
@ -795,11 +795,11 @@ void G1Policy::record_collection_pause_end(double pause_time_ms) {
|
||||
// predicted target occupancy.
|
||||
size_t last_unrestrained_young_length = update_young_list_max_and_target_length();
|
||||
|
||||
update_ihop_prediction(app_time_ms / 1000.0,
|
||||
_bytes_allocated_in_old_since_last_gc,
|
||||
_old_gen_alloc_tracker.reset_after_young_gc(app_time_ms / 1000.0);
|
||||
update_ihop_prediction(_old_gen_alloc_tracker.last_cycle_duration(),
|
||||
_old_gen_alloc_tracker.last_cycle_old_bytes(),
|
||||
last_unrestrained_young_length * HeapRegion::GrainBytes,
|
||||
this_pause_was_young_only);
|
||||
_bytes_allocated_in_old_since_last_gc = 0;
|
||||
|
||||
_ihop_control->send_trace_event(_g1h->gc_tracer_stw());
|
||||
} else {
|
||||
|
@ -30,6 +30,7 @@
|
||||
#include "gc/g1/g1HeapRegionAttr.hpp"
|
||||
#include "gc/g1/g1InitialMarkToMixedTimeTracker.hpp"
|
||||
#include "gc/g1/g1MMUTracker.hpp"
|
||||
#include "gc/g1/g1OldGenAllocationTracker.hpp"
|
||||
#include "gc/g1/g1RemSetTrackingPolicy.hpp"
|
||||
#include "gc/g1/g1Predictions.hpp"
|
||||
#include "gc/g1/g1YoungGenSizer.hpp"
|
||||
@ -102,9 +103,9 @@ class G1Policy: public CHeapObj<mtGC> {
|
||||
|
||||
size_t _pending_cards_at_gc_start;
|
||||
|
||||
// The amount of allocated bytes in old gen during the last mutator and the following
|
||||
// young GC phase.
|
||||
size_t _bytes_allocated_in_old_since_last_gc;
|
||||
// Tracking the allocation in the old generation between
|
||||
// two GCs.
|
||||
G1OldGenAllocationTracker _old_gen_alloc_tracker;
|
||||
|
||||
G1InitialMarkToMixedTimeTracker _initial_mark_to_mixed;
|
||||
|
||||
@ -119,8 +120,7 @@ public:
|
||||
|
||||
G1RemSetTrackingPolicy* remset_tracker() { return &_remset_tracker; }
|
||||
|
||||
// Add the given number of bytes to the total number of allocated bytes in the old gen.
|
||||
void add_bytes_allocated_in_old_since_last_gc(size_t bytes) { _bytes_allocated_in_old_since_last_gc += bytes; }
|
||||
G1OldGenAllocationTracker* old_gen_alloc_tracker() { return &_old_gen_alloc_tracker; }
|
||||
|
||||
void set_region_eden(HeapRegion* hr) {
|
||||
hr->set_eden();
|
||||
|
Loading…
x
Reference in New Issue
Block a user