8276670: G1: Rename G1CardSetFreePool and related classes
Reviewed-by: tschatzl, ayang
This commit is contained in:
parent
b9eb532de2
commit
e9b36a8316
@ -30,7 +30,6 @@
|
||||
#include "runtime/atomic.hpp"
|
||||
#include "utilities/ostream.hpp"
|
||||
|
||||
|
||||
template <class Elem>
|
||||
G1CardSetAllocator<Elem>::G1CardSetAllocator(const char* name,
|
||||
const G1CardSetAllocOptions* buffer_options,
|
||||
@ -202,11 +201,11 @@ size_t G1CardSetMemoryManager::wasted_mem_size() const {
|
||||
return result;
|
||||
}
|
||||
|
||||
G1CardSetMemoryStats G1CardSetMemoryManager::memory_stats() const {
|
||||
G1CardSetMemoryStats result;
|
||||
G1SegmentedArrayMemoryStats G1CardSetMemoryManager::memory_stats() const {
|
||||
G1SegmentedArrayMemoryStats result;
|
||||
for (uint i = 0; i < num_mem_object_types(); i++) {
|
||||
result._num_mem_sizes[i] += _allocators[i].mem_size();
|
||||
result._num_buffers[i] += _allocators[i].num_buffers();
|
||||
result._num_segments[i] += _allocators[i].num_buffers();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
@ -136,6 +136,8 @@ public:
|
||||
void print(outputStream* os);
|
||||
};
|
||||
|
||||
typedef G1SegmentedArrayFreePool<mtGCCardSet> G1CardSetFreePool;
|
||||
|
||||
class G1CardSetMemoryManager : public CHeapObj<mtGCCardSet> {
|
||||
G1CardSetConfiguration* _config;
|
||||
|
||||
@ -163,7 +165,7 @@ public:
|
||||
size_t mem_size() const;
|
||||
size_t wasted_mem_size() const;
|
||||
|
||||
G1CardSetMemoryStats memory_stats() const;
|
||||
G1SegmentedArrayMemoryStats memory_stats() const;
|
||||
};
|
||||
|
||||
#endif // SHARE_GC_G1_G1CARDSETMEMORY_HPP
|
||||
|
@ -33,7 +33,6 @@
|
||||
#include "gc/g1/g1Arguments.hpp"
|
||||
#include "gc/g1/g1BarrierSet.hpp"
|
||||
#include "gc/g1/g1BatchedTask.hpp"
|
||||
#include "gc/g1/g1CardSetFreeMemoryTask.hpp"
|
||||
#include "gc/g1/g1CollectedHeap.inline.hpp"
|
||||
#include "gc/g1/g1CollectionSet.hpp"
|
||||
#include "gc/g1/g1CollectionSetCandidates.hpp"
|
||||
@ -65,13 +64,14 @@
|
||||
#include "gc/g1/g1RootClosures.hpp"
|
||||
#include "gc/g1/g1RootProcessor.hpp"
|
||||
#include "gc/g1/g1SATBMarkQueueSet.hpp"
|
||||
#include "gc/g1/g1SegmentedArrayFreeMemoryTask.hpp"
|
||||
#include "gc/g1/g1ServiceThread.hpp"
|
||||
#include "gc/g1/g1ThreadLocalData.hpp"
|
||||
#include "gc/g1/g1Trace.hpp"
|
||||
#include "gc/g1/g1ServiceThread.hpp"
|
||||
#include "gc/g1/g1UncommitRegionTask.hpp"
|
||||
#include "gc/g1/g1VMOperations.hpp"
|
||||
#include "gc/g1/g1YoungGCEvacFailureInjector.hpp"
|
||||
#include "gc/g1/g1YoungCollector.hpp"
|
||||
#include "gc/g1/g1YoungGCEvacFailureInjector.hpp"
|
||||
#include "gc/g1/heapRegion.inline.hpp"
|
||||
#include "gc/g1/heapRegionRemSet.inline.hpp"
|
||||
#include "gc/g1/heapRegionSet.inline.hpp"
|
||||
@ -87,17 +87,17 @@
|
||||
#include "gc/shared/locationPrinter.inline.hpp"
|
||||
#include "gc/shared/oopStorageParState.hpp"
|
||||
#include "gc/shared/preservedMarks.inline.hpp"
|
||||
#include "gc/shared/suspendibleThreadSet.hpp"
|
||||
#include "gc/shared/referenceProcessor.inline.hpp"
|
||||
#include "gc/shared/taskTerminator.hpp"
|
||||
#include "gc/shared/suspendibleThreadSet.hpp"
|
||||
#include "gc/shared/taskqueue.inline.hpp"
|
||||
#include "gc/shared/taskTerminator.hpp"
|
||||
#include "gc/shared/tlab_globals.hpp"
|
||||
#include "gc/shared/weakProcessor.inline.hpp"
|
||||
#include "gc/shared/workerPolicy.hpp"
|
||||
#include "gc/shared/weakProcessor.inline.hpp"
|
||||
#include "logging/log.hpp"
|
||||
#include "memory/allocation.hpp"
|
||||
#include "memory/iterator.hpp"
|
||||
#include "memory/heapInspection.hpp"
|
||||
#include "memory/iterator.hpp"
|
||||
#include "memory/metaspaceUtils.hpp"
|
||||
#include "memory/resourceArea.hpp"
|
||||
#include "memory/universe.hpp"
|
||||
@ -1431,7 +1431,7 @@ G1CollectedHeap::G1CollectedHeap() :
|
||||
CollectedHeap(),
|
||||
_service_thread(NULL),
|
||||
_periodic_gc_task(NULL),
|
||||
_free_card_set_memory_task(NULL),
|
||||
_free_segmented_array_memory_task(NULL),
|
||||
_workers(NULL),
|
||||
_card_table(NULL),
|
||||
_collection_pause_end(Ticks::now()),
|
||||
@ -1723,8 +1723,8 @@ jint G1CollectedHeap::initialize() {
|
||||
_periodic_gc_task = new G1PeriodicGCTask("Periodic GC Task");
|
||||
_service_thread->register_task(_periodic_gc_task);
|
||||
|
||||
_free_card_set_memory_task = new G1CardSetFreeMemoryTask("Card Set Free Memory Task");
|
||||
_service_thread->register_task(_free_card_set_memory_task);
|
||||
_free_segmented_array_memory_task = new G1SegmentedArrayFreeMemoryTask("Card Set Free Memory Task");
|
||||
_service_thread->register_task(_free_segmented_array_memory_task);
|
||||
|
||||
{
|
||||
G1DirtyCardQueueSet& dcqs = G1BarrierSet::dirty_card_queue_set();
|
||||
@ -2616,8 +2616,8 @@ void G1CollectedHeap::gc_epilogue(bool full) {
|
||||
|
||||
_collection_pause_end = Ticks::now();
|
||||
|
||||
_free_card_set_memory_task->notify_new_stats(&_young_gen_card_set_stats,
|
||||
&_collection_set_candidates_card_set_stats);
|
||||
_free_segmented_array_memory_task->notify_new_stats(&_young_gen_card_set_stats,
|
||||
&_collection_set_candidates_card_set_stats);
|
||||
}
|
||||
|
||||
uint G1CollectedHeap::uncommit_regions(uint region_limit) {
|
||||
@ -2941,11 +2941,11 @@ bool G1CollectedHeap::should_sample_collection_set_candidates() const {
|
||||
return candidates != NULL && candidates->num_remaining() > 0;
|
||||
}
|
||||
|
||||
void G1CollectedHeap::set_collection_set_candidates_stats(G1CardSetMemoryStats& stats) {
|
||||
void G1CollectedHeap::set_collection_set_candidates_stats(G1SegmentedArrayMemoryStats& stats) {
|
||||
_collection_set_candidates_card_set_stats = stats;
|
||||
}
|
||||
|
||||
void G1CollectedHeap::set_young_gen_card_set_stats(const G1CardSetMemoryStats& stats) {
|
||||
void G1CollectedHeap::set_young_gen_card_set_stats(const G1SegmentedArrayMemoryStats& stats) {
|
||||
_young_gen_card_set_stats = stats;
|
||||
}
|
||||
|
||||
|
@ -27,7 +27,6 @@
|
||||
|
||||
#include "gc/g1/g1BarrierSet.hpp"
|
||||
#include "gc/g1/g1BiasedArray.hpp"
|
||||
#include "gc/g1/g1CardSetFreeMemoryTask.hpp"
|
||||
#include "gc/g1/g1CardTable.hpp"
|
||||
#include "gc/g1/g1CollectionSet.hpp"
|
||||
#include "gc/g1/g1CollectorState.hpp"
|
||||
@ -35,12 +34,13 @@
|
||||
#include "gc/g1/g1EdenRegions.hpp"
|
||||
#include "gc/g1/g1EvacStats.hpp"
|
||||
#include "gc/g1/g1GCPauseType.hpp"
|
||||
#include "gc/g1/g1HeapRegionAttr.hpp"
|
||||
#include "gc/g1/g1HeapTransition.hpp"
|
||||
#include "gc/g1/g1HeapVerifier.hpp"
|
||||
#include "gc/g1/g1HRPrinter.hpp"
|
||||
#include "gc/g1/g1HeapRegionAttr.hpp"
|
||||
#include "gc/g1/g1MonitoringSupport.hpp"
|
||||
#include "gc/g1/g1NUMA.hpp"
|
||||
#include "gc/g1/g1SegmentedArrayFreeMemoryTask.hpp"
|
||||
#include "gc/g1/g1SurvivorRegions.hpp"
|
||||
#include "gc/g1/g1YoungGCEvacFailureInjector.hpp"
|
||||
#include "gc/g1/heapRegionManager.hpp"
|
||||
@ -143,7 +143,7 @@ class G1CollectedHeap : public CollectedHeap {
|
||||
private:
|
||||
G1ServiceThread* _service_thread;
|
||||
G1ServiceTask* _periodic_gc_task;
|
||||
G1CardSetFreeMemoryTask* _free_card_set_memory_task;
|
||||
G1SegmentedArrayFreeMemoryTask* _free_segmented_array_memory_task;
|
||||
|
||||
WorkerThreads* _workers;
|
||||
G1CardTable* _card_table;
|
||||
@ -160,9 +160,9 @@ private:
|
||||
HeapRegionSet _humongous_set;
|
||||
|
||||
// Young gen memory statistics before GC.
|
||||
G1CardSetMemoryStats _young_gen_card_set_stats;
|
||||
G1SegmentedArrayMemoryStats _young_gen_card_set_stats;
|
||||
// Collection set candidates memory statistics after GC.
|
||||
G1CardSetMemoryStats _collection_set_candidates_card_set_stats;
|
||||
G1SegmentedArrayMemoryStats _collection_set_candidates_card_set_stats;
|
||||
|
||||
// The block offset table for the G1 heap.
|
||||
G1BlockOffsetTable* _bot;
|
||||
@ -259,8 +259,8 @@ public:
|
||||
void set_humongous_stats(uint num_humongous_total, uint num_humongous_candidates);
|
||||
|
||||
bool should_sample_collection_set_candidates() const;
|
||||
void set_collection_set_candidates_stats(G1CardSetMemoryStats& stats);
|
||||
void set_young_gen_card_set_stats(const G1CardSetMemoryStats& stats);
|
||||
void set_collection_set_candidates_stats(G1SegmentedArrayMemoryStats& stats);
|
||||
void set_young_gen_card_set_stats(const G1SegmentedArrayMemoryStats& stats);
|
||||
|
||||
private:
|
||||
|
||||
|
@ -23,22 +23,23 @@
|
||||
*/
|
||||
|
||||
#include "precompiled.hpp"
|
||||
#include "gc/g1/g1CardSetFreeMemoryTask.hpp"
|
||||
#include "ci/ciUtilities.hpp"
|
||||
#include "gc/g1/g1CardSetMemory.inline.hpp"
|
||||
#include "gc/g1/g1CollectedHeap.hpp"
|
||||
#include "gc/g1/g1SegmentedArrayFreeMemoryTask.hpp"
|
||||
#include "gc/g1/g1_globals.hpp"
|
||||
#include "gc/g1/heapRegionRemSet.hpp"
|
||||
#include "gc/shared/gcTraceTime.inline.hpp"
|
||||
#include "gc/shared/suspendibleThreadSet.hpp"
|
||||
#include "heapRegionRemSet.hpp"
|
||||
#include "ci/ciUtilities.hpp"
|
||||
#include "runtime/os.hpp"
|
||||
|
||||
constexpr const char* G1CardSetFreeMemoryTask::_state_names[];
|
||||
constexpr const char* G1SegmentedArrayFreeMemoryTask::_state_names[];
|
||||
|
||||
const char* G1CardSetFreeMemoryTask::get_state_name(State value) const {
|
||||
const char* G1SegmentedArrayFreeMemoryTask::get_state_name(State value) const {
|
||||
return _state_names[static_cast<std::underlying_type_t<State>>(value)];
|
||||
}
|
||||
|
||||
bool G1CardSetFreeMemoryTask::deadline_exceeded(jlong deadline) {
|
||||
bool G1SegmentedArrayFreeMemoryTask::deadline_exceeded(jlong deadline) {
|
||||
return os::elapsed_counter() >= deadline;
|
||||
}
|
||||
|
||||
@ -47,31 +48,31 @@ static size_t keep_size(size_t free, size_t used, double percent) {
|
||||
return MIN2(free, to_keep);
|
||||
}
|
||||
|
||||
bool G1CardSetFreeMemoryTask::calculate_return_infos(jlong deadline) {
|
||||
bool G1SegmentedArrayFreeMemoryTask::calculate_return_infos(jlong deadline) {
|
||||
// Ignore the deadline in this step as it is very short.
|
||||
|
||||
G1CardSetMemoryStats used = _total_used;
|
||||
G1CardSetMemoryStats free = G1CardSetFreePool::free_list_sizes();
|
||||
G1SegmentedArrayMemoryStats used = _total_used;
|
||||
G1SegmentedArrayMemoryStats free = G1SegmentedArrayFreePool<mtGCCardSet>::free_list_sizes();
|
||||
|
||||
_return_info = new G1ReturnMemoryProcessorSet(used.num_pools());
|
||||
for (uint i = 0; i < used.num_pools(); i++) {
|
||||
size_t return_to_vm_size = keep_size(free._num_mem_sizes[i],
|
||||
used._num_mem_sizes[i],
|
||||
G1RemSetFreeMemoryKeepExcessRatio);
|
||||
log_trace(gc, task)("Card Set Free Memory: Type %s: Free: %zu (%zu) "
|
||||
log_trace(gc, task)("Segmented Array Free Memory: Type %s: Free: %zu (%zu) "
|
||||
"Used: %zu Keep: %zu",
|
||||
G1CardSetConfiguration::mem_object_type_name_str(i),
|
||||
free._num_mem_sizes[i], free._num_buffers[i],
|
||||
free._num_mem_sizes[i], free._num_segments[i],
|
||||
used._num_mem_sizes[i], return_to_vm_size);
|
||||
|
||||
_return_info->append(new G1ReturnMemoryProcessor(return_to_vm_size));
|
||||
}
|
||||
|
||||
G1CardSetFreePool::update_unlink_processors(_return_info);
|
||||
G1SegmentedArrayFreePool<mtGCCardSet>::update_unlink_processors(_return_info);
|
||||
return false;
|
||||
}
|
||||
|
||||
bool G1CardSetFreeMemoryTask::return_memory_to_vm(jlong deadline) {
|
||||
bool G1SegmentedArrayFreeMemoryTask::return_memory_to_vm(jlong deadline) {
|
||||
for (int i = 0; i < _return_info->length(); i++) {
|
||||
G1ReturnMemoryProcessor* info = _return_info->at(i);
|
||||
if (!info->finished_return_to_vm()) {
|
||||
@ -83,7 +84,7 @@ bool G1CardSetFreeMemoryTask::return_memory_to_vm(jlong deadline) {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool G1CardSetFreeMemoryTask::return_memory_to_os(jlong deadline) {
|
||||
bool G1SegmentedArrayFreeMemoryTask::return_memory_to_os(jlong deadline) {
|
||||
for (int i = 0; i < _return_info->length(); i++) {
|
||||
G1ReturnMemoryProcessor* info = _return_info->at(i);
|
||||
if (!info->finished_return_to_os()) {
|
||||
@ -95,7 +96,7 @@ bool G1CardSetFreeMemoryTask::return_memory_to_os(jlong deadline) {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool G1CardSetFreeMemoryTask::cleanup_return_infos() {
|
||||
bool G1SegmentedArrayFreeMemoryTask::cleanup_return_infos() {
|
||||
for (int i = 0; i < _return_info->length(); i++) {
|
||||
G1ReturnMemoryProcessor* info = _return_info->at(i);
|
||||
delete info;
|
||||
@ -106,12 +107,12 @@ bool G1CardSetFreeMemoryTask::cleanup_return_infos() {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool G1CardSetFreeMemoryTask::free_excess_card_set_memory() {
|
||||
bool G1SegmentedArrayFreeMemoryTask::free_excess_segmented_array_memory() {
|
||||
jlong start = os::elapsed_counter();
|
||||
jlong end = start +
|
||||
(os::elapsed_frequency() / 1000) * G1RemSetFreeMemoryStepDurationMillis;
|
||||
|
||||
log_trace(gc, task)("Card Set Free Memory: Step start %1.3f end %1.3f",
|
||||
log_trace(gc, task)("Segmented Array Free Memory: Step start %1.3f end %1.3f",
|
||||
TimeHelper::counter_to_millis(start), TimeHelper::counter_to_millis(end));
|
||||
|
||||
State next_state;
|
||||
@ -148,7 +149,7 @@ bool G1CardSetFreeMemoryTask::free_excess_card_set_memory() {
|
||||
break;
|
||||
}
|
||||
default:
|
||||
log_error(gc, task)("Should not try to free excess card set memory in %s state", get_state_name(_state));
|
||||
log_error(gc, task)("Should not try to free excess segmented array memory in %s state", get_state_name(_state));
|
||||
ShouldNotReachHere();
|
||||
break;
|
||||
}
|
||||
@ -156,41 +157,41 @@ bool G1CardSetFreeMemoryTask::free_excess_card_set_memory() {
|
||||
set_state(next_state);
|
||||
} while (_state != State::Inactive && !deadline_exceeded(end));
|
||||
|
||||
log_trace(gc, task)("Card Set Free Memory: Step took %1.3fms, done %s",
|
||||
log_trace(gc, task)("Segmented Array Free Memory: Step took %1.3fms, done %s",
|
||||
TimeHelper::counter_to_millis(os::elapsed_counter() - start),
|
||||
bool_to_str(_state == State::CalculateUsed));
|
||||
|
||||
return is_active();
|
||||
}
|
||||
|
||||
void G1CardSetFreeMemoryTask::set_state(State new_state) {
|
||||
log_trace(gc, task)("Card Set Free Memory: State change from %s to %s",
|
||||
void G1SegmentedArrayFreeMemoryTask::set_state(State new_state) {
|
||||
log_trace(gc, task)("Segmented Array Free Memory: State change from %s to %s",
|
||||
get_state_name(_state),
|
||||
get_state_name(new_state));
|
||||
_state = new_state;
|
||||
}
|
||||
|
||||
bool G1CardSetFreeMemoryTask::is_active() const {
|
||||
bool G1SegmentedArrayFreeMemoryTask::is_active() const {
|
||||
return _state != State::Inactive;
|
||||
}
|
||||
|
||||
jlong G1CardSetFreeMemoryTask::reschedule_delay_ms() const {
|
||||
jlong G1SegmentedArrayFreeMemoryTask::reschedule_delay_ms() const {
|
||||
return G1RemSetFreeMemoryRescheduleDelayMillis;
|
||||
}
|
||||
|
||||
G1CardSetFreeMemoryTask::G1CardSetFreeMemoryTask(const char* name) :
|
||||
G1SegmentedArrayFreeMemoryTask::G1SegmentedArrayFreeMemoryTask(const char* name) :
|
||||
G1ServiceTask(name), _state(State::CalculateUsed), _return_info(nullptr) { }
|
||||
|
||||
void G1CardSetFreeMemoryTask::execute() {
|
||||
void G1SegmentedArrayFreeMemoryTask::execute() {
|
||||
SuspendibleThreadSetJoiner sts;
|
||||
|
||||
if (free_excess_card_set_memory()) {
|
||||
if (free_excess_segmented_array_memory()) {
|
||||
schedule(reschedule_delay_ms());
|
||||
}
|
||||
}
|
||||
|
||||
void G1CardSetFreeMemoryTask::notify_new_stats(G1CardSetMemoryStats* young_gen_stats,
|
||||
G1CardSetMemoryStats* collection_set_candidate_stats) {
|
||||
void G1SegmentedArrayFreeMemoryTask::notify_new_stats(G1SegmentedArrayMemoryStats* young_gen_stats,
|
||||
G1SegmentedArrayMemoryStats* collection_set_candidate_stats) {
|
||||
assert_at_safepoint_on_vm_thread();
|
||||
|
||||
_total_used = *young_gen_stats;
|
@ -22,17 +22,18 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef SHARE_GC_G1_G1CARDSETFREEMEMORYTASK_HPP
|
||||
#define SHARE_GC_G1_G1CARDSETFREEMEMORYTASK_HPP
|
||||
#ifndef SHARE_GC_G1_G1SEGMENTEDARRAYFREEMEMORYTASK_HPP
|
||||
#define SHARE_GC_G1_G1SEGMENTEDARRAYFREEMEMORYTASK_HPP
|
||||
|
||||
#include "gc/g1/g1ServiceThread.hpp"
|
||||
#include "gc/g1/g1CardSetMemory.hpp"
|
||||
#include "gc/g1/g1SegmentedArrayFreePool.hpp"
|
||||
#include "gc/g1/g1ServiceThread.hpp"
|
||||
#include "gc/g1/heapRegionRemSet.hpp"
|
||||
#include "utilities/growableArray.hpp"
|
||||
#include "utilities/ticks.hpp"
|
||||
|
||||
// Task handling deallocation of free card set memory.
|
||||
class G1CardSetFreeMemoryTask : public G1ServiceTask {
|
||||
// Task handling deallocation of free segmented array memory.
|
||||
class G1SegmentedArrayFreeMemoryTask : public G1ServiceTask {
|
||||
|
||||
enum class State : uint {
|
||||
Inactive,
|
||||
@ -52,11 +53,11 @@ class G1CardSetFreeMemoryTask : public G1ServiceTask {
|
||||
|
||||
State _state;
|
||||
|
||||
// Current total card set memory usage.
|
||||
G1CardSetMemoryStats _total_used;
|
||||
// Current total segmented array memory usage.
|
||||
G1SegmentedArrayMemoryStats _total_used;
|
||||
|
||||
typedef G1CardSetFreePool::G1ReturnMemoryProcessor G1ReturnMemoryProcessor;
|
||||
typedef G1CardSetFreePool::G1ReturnMemoryProcessorSet G1ReturnMemoryProcessorSet;
|
||||
typedef G1SegmentedArrayFreePool<mtGCCardSet>::G1ReturnMemoryProcessor G1ReturnMemoryProcessor;
|
||||
typedef G1SegmentedArrayFreePool<mtGCCardSet>::G1ReturnMemoryProcessorSet G1ReturnMemoryProcessorSet;
|
||||
|
||||
G1ReturnMemoryProcessorSet* _return_info;
|
||||
|
||||
@ -70,9 +71,9 @@ class G1CardSetFreeMemoryTask : public G1ServiceTask {
|
||||
bool return_memory_to_os(jlong deadline);
|
||||
bool cleanup_return_infos();
|
||||
|
||||
// Free excess card set memory, main method. Returns true if there is more work
|
||||
// Free excess segmented array memory, main method. Returns true if there is more work
|
||||
// to do.
|
||||
bool free_excess_card_set_memory();
|
||||
bool free_excess_segmented_array_memory();
|
||||
|
||||
void set_state(State new_state);
|
||||
// Returns whether we are currently processing a recent request.
|
||||
@ -82,14 +83,14 @@ class G1CardSetFreeMemoryTask : public G1ServiceTask {
|
||||
jlong reschedule_delay_ms() const;
|
||||
|
||||
public:
|
||||
explicit G1CardSetFreeMemoryTask(const char* name);
|
||||
explicit G1SegmentedArrayFreeMemoryTask(const char* name);
|
||||
|
||||
void execute() override;
|
||||
|
||||
// Notify the task of new used remembered set memory statistics for the young
|
||||
// generation and the collection set candidate sets.
|
||||
void notify_new_stats(G1CardSetMemoryStats* young_gen_stats,
|
||||
G1CardSetMemoryStats* collection_set_candidate_stats);
|
||||
void notify_new_stats(G1SegmentedArrayMemoryStats* young_gen_stats,
|
||||
G1SegmentedArrayMemoryStats* collection_set_candidate_stats);
|
||||
};
|
||||
|
||||
#endif // SHARE_GC_G1_G1CARDSETFREEMEMORYTASK_HPP
|
||||
#endif // SHARE_GC_G1_G1SEGMENTEDARRAYFREEMEMORYTASK_HPP
|
@ -24,7 +24,6 @@
|
||||
|
||||
#include "precompiled.hpp"
|
||||
|
||||
#include "gc/g1/g1CardSetMemory.hpp"
|
||||
#include "gc/g1/g1SegmentedArrayFreePool.hpp"
|
||||
#include "gc/g1/g1SegmentedArray.inline.hpp"
|
||||
#include "logging/log.hpp"
|
||||
@ -33,19 +32,19 @@
|
||||
#include "utilities/formatBuffer.hpp"
|
||||
#include "utilities/ostream.hpp"
|
||||
|
||||
|
||||
G1CardSetMemoryStats::G1CardSetMemoryStats() {
|
||||
G1SegmentedArrayMemoryStats::G1SegmentedArrayMemoryStats() {
|
||||
clear();
|
||||
}
|
||||
|
||||
void G1CardSetMemoryStats::clear() {
|
||||
void G1SegmentedArrayMemoryStats::clear() {
|
||||
for (uint i = 0; i < num_pools(); i++) {
|
||||
_num_mem_sizes[i] = 0;
|
||||
_num_buffers[i] = 0;
|
||||
_num_segments[i] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
void G1CardSetFreePool::update_unlink_processors(G1ReturnMemoryProcessorSet* unlink_processor) {
|
||||
template<MEMFLAGS flag>
|
||||
void G1SegmentedArrayFreePool<flag>::update_unlink_processors(G1ReturnMemoryProcessorSet* unlink_processor) {
|
||||
uint num_free_lists = _freelist_pool.num_free_lists();
|
||||
|
||||
for (uint i = 0; i < num_free_lists; i++) {
|
||||
@ -53,7 +52,8 @@ void G1CardSetFreePool::update_unlink_processors(G1ReturnMemoryProcessorSet* unl
|
||||
}
|
||||
}
|
||||
|
||||
void G1CardSetFreePool::G1ReturnMemoryProcessor::visit_free_list(G1CardSetBufferList* source) {
|
||||
template<MEMFLAGS flag>
|
||||
void G1SegmentedArrayFreePool<flag>::G1ReturnMemoryProcessor::visit_free_list(G1SegmentedArrayBufferList<flag>* source) {
|
||||
assert(_source == nullptr, "already visited");
|
||||
if (_return_to_vm_size > 0) {
|
||||
_source = source;
|
||||
@ -75,15 +75,16 @@ void G1CardSetFreePool::G1ReturnMemoryProcessor::visit_free_list(G1CardSetBuffer
|
||||
}
|
||||
}
|
||||
|
||||
bool G1CardSetFreePool::G1ReturnMemoryProcessor::return_to_vm(jlong deadline) {
|
||||
template<MEMFLAGS flag>
|
||||
bool G1SegmentedArrayFreePool<flag>::G1ReturnMemoryProcessor::return_to_vm(jlong deadline) {
|
||||
assert(!finished_return_to_vm(), "already returned everything to the VM");
|
||||
assert(_first != nullptr, "must have element to return");
|
||||
|
||||
size_t keep_size = 0;
|
||||
size_t keep_num = 0;
|
||||
|
||||
G1CardSetBuffer* cur = _first;
|
||||
G1CardSetBuffer* last = nullptr;
|
||||
G1SegmentedArrayBuffer<flag>* cur = _first;
|
||||
G1SegmentedArrayBuffer<flag>* last = nullptr;
|
||||
|
||||
while (cur != nullptr && _return_to_vm_size > 0) {
|
||||
size_t cur_size = cur->mem_size();
|
||||
@ -110,7 +111,7 @@ bool G1CardSetFreePool::G1ReturnMemoryProcessor::return_to_vm(jlong deadline) {
|
||||
_source->bulk_add(*_first, *last, keep_num, keep_size);
|
||||
_first = cur;
|
||||
|
||||
log_trace(gc, task)("Card Set Free Memory: Returned to VM %zu buffers size %zu", keep_num, keep_size);
|
||||
log_trace(gc, task)("Segmented Array Free Memory: Returned to VM %zu buffers size %zu", keep_num, keep_size);
|
||||
|
||||
// _return_to_vm_size may be larger than what is available in the list at the
|
||||
// time we actually get the list. I.e. the list and _return_to_vm_size may be
|
||||
@ -124,7 +125,8 @@ bool G1CardSetFreePool::G1ReturnMemoryProcessor::return_to_vm(jlong deadline) {
|
||||
return _source != nullptr;
|
||||
}
|
||||
|
||||
bool G1CardSetFreePool::G1ReturnMemoryProcessor::return_to_os(jlong deadline) {
|
||||
template<MEMFLAGS flag>
|
||||
bool G1SegmentedArrayFreePool<flag>::G1ReturnMemoryProcessor::return_to_os(jlong deadline) {
|
||||
assert(finished_return_to_vm(), "not finished returning to VM");
|
||||
assert(!finished_return_to_os(), "already returned everything to the OS");
|
||||
|
||||
@ -133,7 +135,7 @@ bool G1CardSetFreePool::G1ReturnMemoryProcessor::return_to_os(jlong deadline) {
|
||||
size_t mem_size_deleted = 0;
|
||||
|
||||
while (_first != nullptr) {
|
||||
G1CardSetBuffer* next = _first->next();
|
||||
G1SegmentedArrayBuffer<flag>* next = _first->next();
|
||||
num_delete++;
|
||||
mem_size_deleted += _first->mem_size();
|
||||
delete _first;
|
||||
@ -145,45 +147,45 @@ bool G1CardSetFreePool::G1ReturnMemoryProcessor::return_to_os(jlong deadline) {
|
||||
}
|
||||
}
|
||||
|
||||
log_trace(gc, task)("Card Set Free Memory: Return to OS %zu buffers size %zu", num_delete, mem_size_deleted);
|
||||
log_trace(gc, task)("Segmented Array Free Memory: Return to OS %zu buffers size %zu", num_delete, mem_size_deleted);
|
||||
|
||||
return _first != nullptr;
|
||||
}
|
||||
|
||||
G1CardSetFreePool G1CardSetFreePool::_freelist_pool(G1CardSetConfiguration::num_mem_object_types());
|
||||
template<MEMFLAGS flag>
|
||||
G1SegmentedArrayFreePool<flag> G1SegmentedArrayFreePool<flag>::_freelist_pool(G1CardSetConfiguration::num_mem_object_types());
|
||||
|
||||
G1CardSetFreePool::G1CardSetFreePool(uint num_free_lists) :
|
||||
template<MEMFLAGS flag>
|
||||
G1SegmentedArrayFreePool<flag>::G1SegmentedArrayFreePool(uint num_free_lists) :
|
||||
_num_free_lists(num_free_lists) {
|
||||
|
||||
_free_lists = NEW_C_HEAP_ARRAY(G1CardSetBufferList, _num_free_lists, mtGC);
|
||||
_free_lists = NEW_C_HEAP_ARRAY(G1SegmentedArrayBufferList<flag>, _num_free_lists, mtGC);
|
||||
for (uint i = 0; i < _num_free_lists; i++) {
|
||||
new (&_free_lists[i]) G1CardSetBufferList();
|
||||
new (&_free_lists[i]) G1SegmentedArrayBufferList<flag>();
|
||||
}
|
||||
}
|
||||
|
||||
G1CardSetFreePool::~G1CardSetFreePool() {
|
||||
template<MEMFLAGS flag>
|
||||
G1SegmentedArrayFreePool<flag>::~G1SegmentedArrayFreePool() {
|
||||
for (uint i = 0; i < _num_free_lists; i++) {
|
||||
_free_lists[i].~G1CardSetBufferList();
|
||||
_free_lists[i].~G1SegmentedArrayBufferList<flag>();
|
||||
}
|
||||
FREE_C_HEAP_ARRAY(mtGC, _free_lists);
|
||||
}
|
||||
|
||||
G1CardSetBufferList* G1CardSetFreePool::free_list(uint i) {
|
||||
assert(i < _num_free_lists, "must be");
|
||||
return &_free_lists[i];
|
||||
}
|
||||
|
||||
G1CardSetMemoryStats G1CardSetFreePool::memory_sizes() const {
|
||||
G1CardSetMemoryStats free_list_stats;
|
||||
template<MEMFLAGS flag>
|
||||
G1SegmentedArrayMemoryStats G1SegmentedArrayFreePool<flag>::memory_sizes() const {
|
||||
G1SegmentedArrayMemoryStats free_list_stats;
|
||||
assert(free_list_stats.num_pools() == num_free_lists(), "must be");
|
||||
for (uint i = 0; i < num_free_lists(); i++) {
|
||||
free_list_stats._num_mem_sizes[i] = _free_lists[i].mem_size();
|
||||
free_list_stats._num_buffers[i] = _free_lists[i].num_buffers();
|
||||
free_list_stats._num_segments[i] = _free_lists[i].num_buffers();
|
||||
}
|
||||
return free_list_stats;
|
||||
}
|
||||
|
||||
size_t G1CardSetFreePool::mem_size() const {
|
||||
template<MEMFLAGS flag>
|
||||
size_t G1SegmentedArrayFreePool<flag>::mem_size() const {
|
||||
size_t result = 0;
|
||||
for (uint i = 0; i < _num_free_lists; i++) {
|
||||
result += _free_lists[i].mem_size();
|
||||
@ -191,10 +193,13 @@ size_t G1CardSetFreePool::mem_size() const {
|
||||
return result;
|
||||
}
|
||||
|
||||
void G1CardSetFreePool::print_on(outputStream* out) {
|
||||
template<MEMFLAGS flag>
|
||||
void G1SegmentedArrayFreePool<flag>::print_on(outputStream* out) {
|
||||
out->print_cr(" Free Pool: size %zu", free_list_pool()->mem_size());
|
||||
for (uint i = 0; i < _num_free_lists; i++) {
|
||||
FormatBuffer<> fmt(" %s", G1CardSetConfiguration::mem_object_type_name_str(i));
|
||||
_free_lists[i].print_on(out, fmt);
|
||||
}
|
||||
}
|
||||
|
||||
template class G1SegmentedArrayFreePool<mtGCCardSet>;
|
||||
|
@ -21,6 +21,7 @@
|
||||
* questions.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef SHARE_GC_G1_G1SEGMENTEDARRAYFREEPOOL_HPP
|
||||
#define SHARE_GC_G1_G1SEGMENTEDARRAYFREEPOOL_HPP
|
||||
|
||||
@ -28,23 +29,23 @@
|
||||
#include "gc/g1/g1SegmentedArray.hpp"
|
||||
#include "utilities/growableArray.hpp"
|
||||
|
||||
// Statistics for a fixed set of buffer lists. Contains the number of buffers and memory
|
||||
// Statistics for a segmented array. Contains the number of segments and memory
|
||||
// used for each. Note that statistics are typically not taken atomically so there
|
||||
// can be inconsistencies. The user must be prepared for them.
|
||||
class G1CardSetMemoryStats {
|
||||
class G1SegmentedArrayMemoryStats {
|
||||
public:
|
||||
|
||||
size_t _num_mem_sizes[G1CardSetConfiguration::num_mem_object_types()];
|
||||
size_t _num_buffers[G1CardSetConfiguration::num_mem_object_types()];
|
||||
size_t _num_segments[G1CardSetConfiguration::num_mem_object_types()];
|
||||
|
||||
// Returns all-zero statistics.
|
||||
G1CardSetMemoryStats();
|
||||
G1SegmentedArrayMemoryStats();
|
||||
|
||||
void add(G1CardSetMemoryStats const other) {
|
||||
STATIC_ASSERT(ARRAY_SIZE(_num_buffers) == ARRAY_SIZE(_num_mem_sizes));
|
||||
void add(G1SegmentedArrayMemoryStats const other) {
|
||||
STATIC_ASSERT(ARRAY_SIZE(_num_segments) == ARRAY_SIZE(_num_mem_sizes));
|
||||
for (uint i = 0; i < ARRAY_SIZE(_num_mem_sizes); i++) {
|
||||
_num_mem_sizes[i] += other._num_mem_sizes[i];
|
||||
_num_buffers[i] += other._num_buffers[i];
|
||||
_num_segments[i] += other._num_segments[i];
|
||||
}
|
||||
}
|
||||
|
||||
@ -53,46 +54,49 @@ public:
|
||||
uint num_pools() const { return G1CardSetConfiguration::num_mem_object_types(); }
|
||||
};
|
||||
|
||||
typedef G1SegmentedArrayBuffer<mtGCCardSet> G1CardSetBuffer;
|
||||
typedef G1SegmentedArrayBufferList<mtGCCardSet> G1CardSetBufferList;
|
||||
|
||||
// A set of free lists holding memory buffers for use by G1CardSetAllocators.
|
||||
class G1CardSetFreePool {
|
||||
// A set of free lists holding memory buffers for use by G1SegmentedArray,
|
||||
// e.g. G1CardSetAllocators::SegmentedArray
|
||||
template<MEMFLAGS flag>
|
||||
class G1SegmentedArrayFreePool {
|
||||
// The global free pool.
|
||||
static G1CardSetFreePool _freelist_pool;
|
||||
static G1SegmentedArrayFreePool _freelist_pool;
|
||||
|
||||
const uint _num_free_lists;
|
||||
G1CardSetBufferList* _free_lists;
|
||||
G1SegmentedArrayBufferList<flag>* _free_lists;
|
||||
|
||||
public:
|
||||
static G1CardSetFreePool* free_list_pool() { return &_freelist_pool; }
|
||||
static G1CardSetMemoryStats free_list_sizes() { return _freelist_pool.memory_sizes(); }
|
||||
static G1SegmentedArrayFreePool* free_list_pool() { return &_freelist_pool; }
|
||||
static G1SegmentedArrayMemoryStats free_list_sizes() { return _freelist_pool.memory_sizes(); }
|
||||
|
||||
class G1ReturnMemoryProcessor;
|
||||
typedef GrowableArrayCHeap<G1ReturnMemoryProcessor*, mtGC> G1ReturnMemoryProcessorSet;
|
||||
|
||||
static void update_unlink_processors(G1ReturnMemoryProcessorSet* unlink_processors);
|
||||
|
||||
explicit G1CardSetFreePool(uint num_free_lists);
|
||||
~G1CardSetFreePool();
|
||||
explicit G1SegmentedArrayFreePool(uint num_free_lists);
|
||||
~G1SegmentedArrayFreePool();
|
||||
|
||||
G1CardSetBufferList* free_list(uint i);
|
||||
G1SegmentedArrayBufferList<flag>* free_list(uint i) {
|
||||
assert(i < _num_free_lists, "must be");
|
||||
return &_free_lists[i];
|
||||
}
|
||||
|
||||
uint num_free_lists() const { return _num_free_lists; }
|
||||
|
||||
G1CardSetMemoryStats memory_sizes() const;
|
||||
G1SegmentedArrayMemoryStats memory_sizes() const;
|
||||
size_t mem_size() const;
|
||||
|
||||
void print_on(outputStream* out);
|
||||
};
|
||||
|
||||
// Data structure containing current in-progress state for returning memory to the
|
||||
// operating system for a single G1CardSetBufferList.
|
||||
class G1CardSetFreePool::G1ReturnMemoryProcessor : public CHeapObj<mtGC> {
|
||||
G1CardSetBufferList* _source;
|
||||
// operating system for a single G1SegmentedArrayBufferList.
|
||||
template<MEMFLAGS flag>
|
||||
class G1SegmentedArrayFreePool<flag>::G1ReturnMemoryProcessor : public CHeapObj<mtGC> {
|
||||
G1SegmentedArrayBufferList<flag>* _source;
|
||||
size_t _return_to_vm_size;
|
||||
|
||||
G1CardSetBuffer* _first;
|
||||
G1SegmentedArrayBuffer<flag>* _first;
|
||||
size_t _unlinked_bytes;
|
||||
size_t _num_unlinked;
|
||||
|
||||
@ -101,10 +105,10 @@ public:
|
||||
_source(nullptr), _return_to_vm_size(return_to_vm), _first(nullptr), _unlinked_bytes(0), _num_unlinked(0) {
|
||||
}
|
||||
|
||||
// Updates the instance members about the given card set buffer list for the purpose
|
||||
// of giving back memory. Only necessary members are updated, e.g. if there is
|
||||
// nothing to return to the VM, do not set the source list.
|
||||
void visit_free_list(G1CardSetBufferList* source);
|
||||
// Updates the instance members about the given segmented array buffer list for
|
||||
// the purpose of giving back memory. Only necessary members are updated,
|
||||
// e.g. if there is nothing to return to the VM, do not set the source list.
|
||||
void visit_free_list(G1SegmentedArrayBufferList<flag>* source);
|
||||
|
||||
bool finished_return_to_vm() const { return _return_to_vm_size == 0; }
|
||||
bool finished_return_to_os() const { return _first == nullptr; }
|
||||
|
@ -330,7 +330,7 @@ class G1PrepareEvacuationTask : public WorkerTask {
|
||||
uint _worker_humongous_total;
|
||||
uint _worker_humongous_candidates;
|
||||
|
||||
G1CardSetMemoryStats _card_set_stats;
|
||||
G1SegmentedArrayMemoryStats _card_set_stats;
|
||||
|
||||
void sample_card_set_size(HeapRegion* hr) {
|
||||
// Sample card set sizes for young gen and humongous before GC: this makes
|
||||
@ -446,7 +446,7 @@ class G1PrepareEvacuationTask : public WorkerTask {
|
||||
return false;
|
||||
}
|
||||
|
||||
G1CardSetMemoryStats card_set_stats() const {
|
||||
G1SegmentedArrayMemoryStats card_set_stats() const {
|
||||
return _card_set_stats;
|
||||
}
|
||||
};
|
||||
@ -456,7 +456,7 @@ class G1PrepareEvacuationTask : public WorkerTask {
|
||||
volatile uint _humongous_total;
|
||||
volatile uint _humongous_candidates;
|
||||
|
||||
G1CardSetMemoryStats _all_card_set_stats;
|
||||
G1SegmentedArrayMemoryStats _all_card_set_stats;
|
||||
|
||||
public:
|
||||
G1PrepareEvacuationTask(G1CollectedHeap* g1h) :
|
||||
@ -490,7 +490,7 @@ public:
|
||||
return _humongous_total;
|
||||
}
|
||||
|
||||
const G1CardSetMemoryStats all_card_set_stats() const {
|
||||
const G1SegmentedArrayMemoryStats all_card_set_stats() const {
|
||||
return _all_card_set_stats;
|
||||
}
|
||||
};
|
||||
|
@ -33,7 +33,6 @@
|
||||
class WorkerTask;
|
||||
class G1Allocator;
|
||||
class G1BatchedTask;
|
||||
class G1CardSetMemoryStats;
|
||||
class G1CollectedHeap;
|
||||
class G1CollectionSet;
|
||||
class G1CollectorState;
|
||||
@ -49,6 +48,7 @@ class G1ParScanThreadStateSet;
|
||||
class G1Policy;
|
||||
class G1RedirtyCardsQueueSet;
|
||||
class G1RemSet;
|
||||
class G1SegmentedArrayMemoryStats;
|
||||
class G1SurvivorRegions;
|
||||
class G1YoungGCEvacFailureInjector;
|
||||
class STWGCTimer;
|
||||
|
@ -82,7 +82,7 @@ public:
|
||||
|
||||
class G1SampleCollectionSetCandidatesClosure : public HeapRegionClosure {
|
||||
public:
|
||||
G1CardSetMemoryStats _total;
|
||||
G1SegmentedArrayMemoryStats _total;
|
||||
|
||||
bool do_heap_region(HeapRegion* r) override {
|
||||
_total.add(r->rem_set()->card_set_memory_stats());
|
||||
|
@ -38,7 +38,6 @@
|
||||
#include "utilities/macros.hpp"
|
||||
|
||||
class G1CardSetConfiguration;
|
||||
class G1CardSetMemoryManager;
|
||||
class G1CollectedHeap;
|
||||
class G1CMBitMap;
|
||||
class G1Predictions;
|
||||
|
@ -81,7 +81,7 @@ HeapRegionRemSet::HeapRegionRemSet(HeapRegion* hr,
|
||||
G1CardSetConfiguration* config) :
|
||||
_m(Mutex::service - 1, FormatBuffer<128>("HeapRegionRemSet#%u_lock", hr->hrm_index())),
|
||||
_code_roots(),
|
||||
_card_set_mm(config, G1CardSetFreePool::free_list_pool()),
|
||||
_card_set_mm(config, G1SegmentedArrayFreePool<mtGCCardSet>::free_list_pool()),
|
||||
_card_set(config, &_card_set_mm),
|
||||
_hr(hr),
|
||||
_state(Untracked) { }
|
||||
@ -105,6 +105,10 @@ void HeapRegionRemSet::clear_locked(bool only_cardset) {
|
||||
assert(occupied() == 0, "Should be clear.");
|
||||
}
|
||||
|
||||
G1SegmentedArrayMemoryStats HeapRegionRemSet::card_set_memory_stats() const {
|
||||
return _card_set_mm.memory_stats();
|
||||
}
|
||||
|
||||
void HeapRegionRemSet::print_static_mem_size(outputStream* out) {
|
||||
out->print_cr(" Static structures = " SIZE_FORMAT, HeapRegionRemSet::static_mem_size());
|
||||
}
|
||||
|
@ -33,6 +33,7 @@
|
||||
#include "runtime/safepoint.hpp"
|
||||
#include "utilities/bitMap.hpp"
|
||||
|
||||
class G1CardSetMemoryManager;
|
||||
class outputStream;
|
||||
|
||||
class HeapRegionRemSet : public CHeapObj<mtGC> {
|
||||
@ -125,7 +126,7 @@ public:
|
||||
void clear(bool only_cardset = false);
|
||||
void clear_locked(bool only_cardset = false);
|
||||
|
||||
G1CardSetMemoryStats card_set_memory_stats() const { return _card_set_mm.memory_stats(); }
|
||||
G1SegmentedArrayMemoryStats card_set_memory_stats() const;
|
||||
|
||||
// The actual # of bytes this hr_remset takes up. Also includes the strong code
|
||||
// root set.
|
||||
|
@ -25,10 +25,12 @@
|
||||
#include "gc/g1/g1CardSet.inline.hpp"
|
||||
#include "gc/g1/g1CardSetContainers.hpp"
|
||||
#include "gc/g1/g1CardSetMemory.hpp"
|
||||
#include "gc/g1/g1SegmentedArrayFreePool.hpp"
|
||||
#include "gc/g1/heapRegionRemSet.hpp"
|
||||
#include "gc/shared/gcTraceTime.inline.hpp"
|
||||
#include "gc/shared/workerThread.hpp"
|
||||
#include "logging/log.hpp"
|
||||
#include "memory/allocation.hpp"
|
||||
#include "unittest.hpp"
|
||||
#include "utilities/powerOfTwo.hpp"
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user