Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
8276670: G1: Rename G1CardSetFreePool and related classes
Reviewed-by: tschatzl, ayang
  • Loading branch information
Hamlin Li committed Nov 27, 2021
1 parent b9eb532 commit e9b36a8
Show file tree
Hide file tree
Showing 15 changed files with 154 additions and 136 deletions.
7 changes: 3 additions & 4 deletions src/hotspot/share/gc/g1/g1CardSetMemory.cpp
Expand Up @@ -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,
Expand Down Expand Up @@ -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;
}
4 changes: 3 additions & 1 deletion src/hotspot/share/gc/g1/g1CardSetMemory.hpp
Expand Up @@ -136,6 +136,8 @@ class G1CardSetAllocator {
void print(outputStream* os);
};

typedef G1SegmentedArrayFreePool<mtGCCardSet> G1CardSetFreePool;

class G1CardSetMemoryManager : public CHeapObj<mtGCCardSet> {
G1CardSetConfiguration* _config;

Expand Down Expand Up @@ -163,7 +165,7 @@ class G1CardSetMemoryManager : public CHeapObj<mtGCCardSet> {
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
28 changes: 14 additions & 14 deletions src/hotspot/share/gc/g1/g1CollectedHeap.cpp
Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand All @@ -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"
Expand Down Expand Up @@ -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()),
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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;
}

Expand Down
14 changes: 7 additions & 7 deletions src/hotspot/share/gc/g1/g1CollectedHeap.hpp
Expand Up @@ -27,20 +27,20 @@

#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"
#include "gc/g1/g1ConcurrentMark.hpp"
#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"
Expand Down Expand Up @@ -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;
Expand All @@ -160,9 +160,9 @@ class G1CollectedHeap : public CollectedHeap {
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;
Expand Down Expand Up @@ -259,8 +259,8 @@ class G1CollectedHeap : public CollectedHeap {
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:

Expand Down
Expand Up @@ -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;
}

Expand All @@ -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()) {
Expand All @@ -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()) {
Expand All @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -148,49 +149,49 @@ 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;
}

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;
Expand Down

1 comment on commit e9b36a8

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.