Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
87 commits
Select commit Hold shift + click to select a range
0372026
Card table as DCQ
tschatzl Feb 11, 2025
7782295
* remove some commented out debug code
tschatzl Feb 24, 2025
9e26abb
* remove mention of "enqueue" or "enqueuing" for actions related to p…
tschatzl Feb 24, 2025
3004a96
* fix crash when writing dirty cards for memory regions during card t…
tschatzl Feb 24, 2025
b8100b9
* mdoerr review: fix comments in ppc code
tschatzl Feb 24, 2025
0100d8e
* only provide byte map base for JavaThreads
tschatzl Feb 25, 2025
9ef9c5f
* remove unnecessarily added logging
tschatzl Feb 25, 2025
e51eec8
* ayang review 1
tschatzl Feb 28, 2025
7d361fc
* ayang review 1 (ctd)
tschatzl Feb 28, 2025
d87935a
* fix assert
tschatzl Feb 28, 2025
810bf2d
* fix comment (trailing whitespace)
tschatzl Mar 3, 2025
b3dd008
ayang review 2
tschatzl Mar 3, 2025
8f46dc9
* iwalulya initial comments
tschatzl Mar 4, 2025
9e2ee54
* do not change card table base for gc threads during swapping
tschatzl Mar 4, 2025
442d9ea
* iwalulya review 2
tschatzl Mar 4, 2025
fc674f0
* ayang review - fix comment
tschatzl Mar 4, 2025
b4d19d9
iwalulya review
tschatzl Mar 4, 2025
4a97811
ayang review
tschatzl Mar 4, 2025
a457e6e
* fix whitespace
tschatzl Mar 5, 2025
350a4fa
* iwalulya review
tschatzl Mar 6, 2025
c994000
* ayang review 3
tschatzl Mar 7, 2025
93b884f
* fix card table verification crashes: in the first refinement phase,…
tschatzl Mar 8, 2025
758fac0
* optimized RISCV gen_write_ref_array_post_barrier() implementation c…
tschatzl Mar 11, 2025
aec9505
Merge branch 'master' into 8342382-card-table-instead-of-dcq
tschatzl Mar 12, 2025
3766b76
* ayang review
tschatzl Mar 12, 2025
7861117
* when aborting refinement during full collection, the global card ta…
tschatzl Mar 13, 2025
51a9eed
* ayang review
tschatzl Mar 14, 2025
b073017
Merge branch 'master' into 8342381-card-table-instead-of-dcq
tschatzl Mar 14, 2025
447fe39
* more documentation on why we need to rendezvous the gc threads
tschatzl Mar 15, 2025
4d0afd5
* obsolete G1UpdateBufferSize
tschatzl Mar 17, 2025
ff9eb26
Merge branch 'master' into 8342382-card-table-instead-of-dcq3
tschatzl Mar 18, 2025
c833bc8
* factor out card table and refinement table merging into a single
tschatzl Mar 18, 2025
f419556
* fix IR code generation tests that change due to barrier cost changes
tschatzl Mar 19, 2025
5e76a51
* make young gen length revising independent of refinement thread
tschatzl Mar 20, 2025
d931104
Merge branch 'master' into submit/8342382-card-table-instead-of-dcq
tschatzl Mar 21, 2025
6d574da
Merge branch 'master' into 8342382-card-table-instead-of-dcq
tschatzl Mar 26, 2025
51fb6e6
Merge branch 'master' into 8342382-card-table-instead-of-dcq
tschatzl Apr 1, 2025
27b3dd6
Merge branch 'master' into 8342382-card-table-instead-of-dcq
tschatzl Apr 4, 2025
1c5a669
* missing file from merge
tschatzl Apr 4, 2025
c5d5f3a
Reorder includes
robcasloz Apr 9, 2025
9481821
Refine needs_liveness_data
robcasloz Apr 9, 2025
855ec8d
Do not unnecessarily pass around tmp2 in x86
robcasloz Apr 9, 2025
d4649ed
* ayang review: revising young gen length
tschatzl Apr 9, 2025
63b1de8
Merge branch 'master' into 8342382-card-table-instead-of-dcq
tschatzl Apr 10, 2025
39aa903
* fixes after merge related to 32 bit x86 removal
tschatzl Apr 10, 2025
fcf96a2
Merge branch 'master' into 8342382-card-table-instead-of-dcq
tschatzl Apr 10, 2025
fd77531
* remove support for 32 bit x86 in the barrier generation code, follo…
tschatzl Apr 10, 2025
068d2a3
* indentation fix
tschatzl Apr 10, 2025
e683152
* ayang review (part 1)
tschatzl Apr 11, 2025
a3b2386
* ayang review (part 2 - yield duration changes)
tschatzl Apr 11, 2025
e4bf1ac
Merge branch 'master' into 8342382-card-table-instead-of-dcq
tschatzl Apr 23, 2025
51dfbe5
Merge branch 'master' into card-table-as-dcq-merge
tschatzl Apr 29, 2025
8b56880
* ayang review: remove sweep_epoch
tschatzl Apr 29, 2025
1def83a
Merge branch 'master' into 8342382-card-table-instead-of-dcq
tschatzl May 15, 2025
c07a73d
Merge branch 'master' into 8342382-card-table-instead-of-dcq
tschatzl Jun 10, 2025
750ed2d
Merge branch 'master' into 8342382-card-table-instead-of-dcq
tschatzl Jun 27, 2025
441c234
Merge branch 'master' into 8342382-card-table-instead-of-dcq
tschatzl Jul 7, 2025
5ab928e
Merge branch 'master' into pull/23739
tschatzl Jul 14, 2025
4b21868
Merge branch 'master' into 8342382-card-table-instead-of-dcq
tschatzl Jul 17, 2025
cea0e1b
Merge branch 'master' into 8342382-card-table-instead-of-dcq
tschatzl Jul 23, 2025
dd83638
* remove unused G1DetachedRefinementStats_lock
tschatzl Jul 23, 2025
23aa2c8
Merge branch 'master' into 8342382-card-table-instead-of-dcq
tschatzl Jul 28, 2025
188fc81
Merge branch 'master' into 8342382-card-table-instead-of-dcq
tschatzl Aug 5, 2025
7fe518e
Merge branch 'master' into 8342382-card-table-instead-of-dcq
tschatzl Aug 12, 2025
6c88f1d
Merge branch 'master' into 8342382-card-table-instead-of-dcq
tschatzl Aug 22, 2025
e8a8282
* forgot to actually save the files
tschatzl Aug 22, 2025
cc4b7a0
* fix merge error
tschatzl Aug 22, 2025
4a41b40
Merge branch 'master' into 8342382-card-table-instead-of-dcq
tschatzl Sep 1, 2025
b3873d6
* commit merge changes
tschatzl Sep 1, 2025
104d506
* improve logging for refinement, making it similar to marking logging
tschatzl Sep 3, 2025
2a614a2
Merge branch 'master' into 8342382-card-table-instead-of-dcq
tschatzl Sep 4, 2025
4601bf8
* sort includes
tschatzl Sep 8, 2025
87b4136
* iwalulya: remove confusing comment
tschatzl Sep 10, 2025
e7c3a06
Merge branch 'master' into 8342382-card-table-instead-of-dcq
tschatzl Sep 10, 2025
de1469d
Merge branch 'master' into 8342382-card-table-instead-of-dcq
tschatzl Sep 10, 2025
d0ca906
* aph review, fix some comment
tschatzl Sep 10, 2025
b47c7b0
* walulyai review
tschatzl Sep 10, 2025
c469c13
* walulyai review
tschatzl Sep 10, 2025
74e9240
* therealaph suggestion for avoiding the register aliasin in gen_writ…
tschatzl Sep 12, 2025
1ced9f9
Merge branch 'master' into 8342382-card-table-instead-of-dcq
tschatzl Sep 12, 2025
bf8cab3
* iwalulya review
tschatzl Sep 12, 2025
b5d22d5
Merge branch 'master' into 8342382-card-table-instead-of-dcq
tschatzl Sep 22, 2025
53ef008
* improved gen_write_ref_array_post_barrier() for riscv, contributed …
tschatzl Sep 22, 2025
6e37f8d
* iwalulya: "Amount of" -> "Number of" in new flag description
tschatzl Sep 22, 2025
311bb3e
* walulyai: remove cost_per_pending_card_ms_default array since we on…
tschatzl Sep 22, 2025
d80d690
* walulyai: remove unnecessarily introduced newline
tschatzl Sep 22, 2025
3c889e9
* walulyai: bufferNodeList can be removed
tschatzl Sep 22, 2025
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
10 changes: 5 additions & 5 deletions src/hotspot/share/gc/g1/g1CollectedHeap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -798,13 +798,13 @@ void G1CollectedHeap::prepare_for_mutator_after_full_collection() {
}

void G1CollectedHeap::abort_refinement() {
G1ConcurrentRefineWorkState& refine_state = concurrent_refine()->refine_state();
if (refine_state.is_in_progress()) {
G1ConcurrentRefineSweepState& sweep_state = concurrent_refine()->sweep_state();
if (sweep_state.is_in_progress()) {
// Record any available refinement statistics.
policy()->record_refinement_stats(refine_state.stats());
refine_state.complete(false /* concurrent */, false /* print_log */);
policy()->record_refinement_stats(sweep_state.stats());
sweep_state.complete_work(false /* concurrent */, false /* print_log */);
}
refine_state.reset_stats();
sweep_state.reset_stats();
}

void G1CollectedHeap::verify_after_full_collection() {
Expand Down
59 changes: 29 additions & 30 deletions src/hotspot/share/gc/g1/g1ConcurrentRefine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -122,41 +122,41 @@ void G1ConcurrentRefineThreadControl::stop() {
}
}

G1ConcurrentRefineWorkState::G1ConcurrentRefineWorkState(uint max_reserved_regions) :
G1ConcurrentRefineSweepState::G1ConcurrentRefineSweepState(uint max_reserved_regions) :
_state(State::Idle),
_refine_work_epoch(0),
_sweep_start_epoch(0),
_sweep_table(new G1CardTableClaimTable(G1CollectedHeap::get_chunks_per_region_for_merge())),
_stats()
{
_sweep_table->initialize(max_reserved_regions);
}

G1ConcurrentRefineWorkState::~G1ConcurrentRefineWorkState() {
G1ConcurrentRefineSweepState::~G1ConcurrentRefineSweepState() {
delete _sweep_table;
}

void G1ConcurrentRefineWorkState::set_state_start_time() {
void G1ConcurrentRefineSweepState::set_state_start_time() {
_state_start[static_cast<uint>(_state)] = Ticks::now();
}

Tickspan G1ConcurrentRefineWorkState::get_duration(State start, State end) {
Tickspan G1ConcurrentRefineSweepState::get_duration(State start, State end) {
return _state_start[static_cast<uint>(end)] - _state_start[static_cast<uint>(start)];
}

void G1ConcurrentRefineWorkState::reset_stats() {
void G1ConcurrentRefineSweepState::reset_stats() {
stats()->reset();
}

void G1ConcurrentRefineWorkState::add_yield_duration(jlong duration) {
void G1ConcurrentRefineSweepState::add_yield_duration(jlong duration) {
stats()->inc_yield_duration(duration);
}

size_t G1ConcurrentRefineWorkState::refinement_epoch() {
size_t G1ConcurrentRefineSweepState::refinement_epoch() {
return G1CollectedHeap::heap()->refinement_epoch();
}

bool G1ConcurrentRefineWorkState::advance_state(State next_state) {
bool result = _refine_work_epoch == refinement_epoch();
bool G1ConcurrentRefineSweepState::advance_state(State next_state) {
bool result = _sweep_start_epoch == refinement_epoch();
if (result) {
_state = next_state;
} else {
Expand All @@ -165,23 +165,23 @@ bool G1ConcurrentRefineWorkState::advance_state(State next_state) {
return result;
}

void G1ConcurrentRefineWorkState::assert_state(State expected) {
void G1ConcurrentRefineSweepState::assert_state(State expected) {
assert(_state == expected, "must be %s but is %s", state_name(expected), state_name(_state));
}

void G1ConcurrentRefineWorkState::start_refine_work() {
void G1ConcurrentRefineSweepState::start_work() {
assert_state(State::Idle);

set_state_start_time();

_refine_work_epoch = refinement_epoch();
_sweep_start_epoch = refinement_epoch();

_stats.reset();

advance_state(State::SwapGlobalCT);
}

bool G1ConcurrentRefineWorkState::swap_global_card_table() {
bool G1ConcurrentRefineSweepState::swap_global_card_table() {
assert_state(State::SwapGlobalCT);

set_state_start_time();
Expand All @@ -200,7 +200,7 @@ bool G1ConcurrentRefineWorkState::swap_global_card_table() {
return advance_state(State::SwapJavaThreadsCT);
}

bool G1ConcurrentRefineWorkState::swap_java_threads_ct() {
bool G1ConcurrentRefineSweepState::swap_java_threads_ct() {
assert_state(State::SwapJavaThreadsCT);

set_state_start_time();
Expand All @@ -217,14 +217,13 @@ bool G1ConcurrentRefineWorkState::swap_java_threads_ct() {
G1ThreadLocalData::set_byte_map_base(t, bs->card_table()->byte_map_base());
}
} cl;

Handshake::execute(&cl);
}

return advance_state(State::SwapGCThreadsCT);
}

bool G1ConcurrentRefineWorkState::swap_gc_threads_ct() {
bool G1ConcurrentRefineSweepState::swap_gc_threads_ct() {
assert_state(State::SwapGCThreadsCT);

set_state_start_time();
Expand Down Expand Up @@ -259,7 +258,7 @@ bool G1ConcurrentRefineWorkState::swap_gc_threads_ct() {
return advance_state(State::SnapshotHeap);
}

void G1ConcurrentRefineWorkState::snapshot_heap(bool concurrent) {
void G1ConcurrentRefineSweepState::snapshot_heap(bool concurrent) {
if (concurrent) {
assert_state(State::SnapshotHeap);

Expand All @@ -276,13 +275,13 @@ void G1ConcurrentRefineWorkState::snapshot_heap(bool concurrent) {
}
}

void G1ConcurrentRefineWorkState::sweep_rt_start() {
void G1ConcurrentRefineSweepState::sweep_refinement_table_start() {
assert_state(State::SweepRT);

set_state_start_time();
}

bool G1ConcurrentRefineWorkState::sweep_rt_step() {
bool G1ConcurrentRefineSweepState::sweep_refinement_table_step() {
assert_state(State::SweepRT);

G1ConcurrentRefine* cr = G1CollectedHeap::heap()->concurrent_refine();
Expand All @@ -298,7 +297,7 @@ bool G1ConcurrentRefineWorkState::sweep_rt_step() {
}
}

bool G1ConcurrentRefineWorkState::complete(bool concurrent, bool print_log) {
bool G1ConcurrentRefineSweepState::complete_work(bool concurrent, bool print_log) {
if (concurrent) {
assert_state(State::CompleteRefineWork);
} else {
Expand Down Expand Up @@ -338,7 +337,7 @@ bool G1ConcurrentRefineWorkState::complete(bool concurrent, bool print_log) {
return has_sweep_rt_work;
}

void G1ConcurrentRefineWorkState::snapshot_heap_into(G1CardTableClaimTable* sweep_table) {
void G1ConcurrentRefineSweepState::snapshot_heap_into(G1CardTableClaimTable* sweep_table) {
// G1CollectedHeap::heap_region_iterate() below will only visit committed regions. Initialize
// all entries in the state table here to not require special handling when iterating over it.
sweep_table->reset_all_to_claimed();
Expand All @@ -364,7 +363,7 @@ void G1ConcurrentRefineWorkState::snapshot_heap_into(G1CardTableClaimTable* swee
G1CollectedHeap::heap()->heap_region_iterate(&cl);
}

bool G1ConcurrentRefineWorkState::is_in_progress() const {
bool G1ConcurrentRefineSweepState::is_in_progress() const {
return _state != State::Idle;
}

Expand All @@ -388,15 +387,15 @@ G1ConcurrentRefine::G1ConcurrentRefine(G1CollectedHeap* g1h) :
_heap_was_locked(false),
_threads_needed(g1h->policy(), adjust_threads_period_ms()),
_thread_control(G1ConcRefinementThreads),
_refine_state(g1h->max_reserved_regions())
_sweep_state(g1h->max_reserved_regions())
{ }

jint G1ConcurrentRefine::initialize() {
return _thread_control.initialize(this);
}

G1ConcurrentRefineWorkState& G1ConcurrentRefine::refine_state_for_merge() {
bool has_sweep_claims = refine_state().complete(false);
G1ConcurrentRefineSweepState& G1ConcurrentRefine::sweep_state_for_merge() {
bool has_sweep_claims = sweep_state().complete_work(false);
if (has_sweep_claims) {
log_debug(gc, refine)("Continue existing work");
} else {
Expand All @@ -407,9 +406,9 @@ G1ConcurrentRefineWorkState& G1ConcurrentRefine::refine_state_for_merge() {
// creating the snapshot right now.
log_debug(gc, refine)("Create work from scratch");

refine_state().snapshot_heap(false /* concurrent */);
sweep_state().snapshot_heap(false /* concurrent */);
}
return refine_state();
return sweep_state();
}

void G1ConcurrentRefine::run_with_refinement_workers(WorkerTask* task) {
Expand All @@ -418,8 +417,8 @@ void G1ConcurrentRefine::run_with_refinement_workers(WorkerTask* task) {

void G1ConcurrentRefine::notify_region_reclaimed(G1HeapRegion* r) {
assert_at_safepoint();
if (_refine_state.is_in_progress()) {
_refine_state.sweep_table()->claim_all_cards(r->hrm_index());
if (_sweep_state.is_in_progress()) {
_sweep_state.sweep_table()->claim_all_cards(r->hrm_index());
}
}

Expand Down
67 changes: 46 additions & 21 deletions src/hotspot/share/gc/g1/g1ConcurrentRefine.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,34 @@ class G1ConcurrentRefineThreadControl {
void stop();
};

// Tracks the current refinement state from idle to completion (and reset back
// to idle).
class G1ConcurrentRefineWorkState {
// Tracks the current state of re-examining the dirty cards from idle to completion
// (and reset back to idle).
//
// The process steps are as follows:
//
// 1) Swap global card table pointers
//
// 2) Swap Java Thread's card table pointers
//
// 3) Synchronize GC Threads
// Ensures memory visibility
//
// After this point mutator threads should not mark the refinement table.
//
// 4) Snapshot the heap
// Determines which regions need to be swept.
//
// 5) Sweep Refinement table
// Examines non-Clean cards on the refinement table.
//
// 6) Completion Work
// Calculates statistics about the process to be used in various parts of
// the garbage collection.
//
// All but step 4 are interruptible by safepoints. In case of a garbage collection,
// the garbage collection will interrupt this process, and go to Idle state.
//
class G1ConcurrentRefineSweepState {

enum class State : uint {
Idle, // Refinement is doing nothing.
Expand All @@ -97,20 +122,20 @@ class G1ConcurrentRefineWorkState {
static const char* state_name(State state) {
static const char* _state_names[] = {
"Idle",
"Swap Global CT",
"Swap JavaThread CT",
"Swap GC Thread CT",
"Swap Global Card Table",
"Swap JavaThread Card Table",
"Synchronize GC Threads",
"Snapshot Heap",
"Sweep RT",
"Complete Refine Work"
"Sweep Refinement Table",
"Complete Sweep Work"
};

return _state_names[static_cast<uint>(state)];
}

// Current epoch the work has been started; used to determine if there has been
// The epoch the sweep has started; used to determine if there has been
// a forced card table swap due to a garbage collection while doing work.
size_t _refine_work_epoch;
size_t _sweep_start_epoch;

// Current heap snapshot.
G1CardTableClaimTable* _sweep_table;
Expand All @@ -131,22 +156,22 @@ class G1ConcurrentRefineWorkState {

void assert_state(State expected);

static void snapshot_heap_into(G1CardTableClaimTable* sweep_table);

public:
G1ConcurrentRefineWorkState(uint max_reserved_regions);
~G1ConcurrentRefineWorkState();
G1ConcurrentRefineSweepState(uint max_reserved_regions);
~G1ConcurrentRefineSweepState();

void start_refine_work();
void start_work();

bool swap_global_card_table();
bool swap_java_threads_ct();
bool swap_gc_threads_ct();
void snapshot_heap(bool concurrent = true);
void sweep_rt_start();
bool sweep_rt_step();

bool complete(bool concurrent, bool print_log = true);
void sweep_refinement_table_start();
bool sweep_refinement_table_step();

static void snapshot_heap_into(G1CardTableClaimTable* sweep_table);
bool complete_work(bool concurrent, bool print_log = true);

G1CardTableClaimTable* sweep_table() { return _sweep_table; }
G1ConcurrentRefineStats* stats() { return &_stats; }
Expand Down Expand Up @@ -195,7 +220,7 @@ class G1ConcurrentRefine : public CHeapObj<mtGC> {
G1ConcurrentRefineThreadsNeeded _threads_needed;
G1ConcurrentRefineThreadControl _thread_control;

G1ConcurrentRefineWorkState _refine_state;
G1ConcurrentRefineSweepState _sweep_state;

G1ConcurrentRefine(G1CollectedHeap* g1h);

Expand Down Expand Up @@ -230,9 +255,9 @@ class G1ConcurrentRefine : public CHeapObj<mtGC> {
public:
~G1ConcurrentRefine();

G1ConcurrentRefineWorkState& refine_state() { return _refine_state; }
G1ConcurrentRefineSweepState& sweep_state() { return _sweep_state; }

G1ConcurrentRefineWorkState& refine_state_for_merge();
G1ConcurrentRefineSweepState& sweep_state_for_merge();

void run_with_refinement_workers(WorkerTask* task);

Expand Down
10 changes: 5 additions & 5 deletions src/hotspot/share/gc/g1/g1ConcurrentRefineThread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -137,9 +137,9 @@ bool G1ConcurrentRefineThread::wait_for_work() {
}

void G1ConcurrentRefineThread::do_refinement() {
G1ConcurrentRefineWorkState& state = _cr->refine_state();
G1ConcurrentRefineSweepState& state = _cr->sweep_state();

state.start_refine_work();
state.start_work();
log_debug(gc,refine)("Concurrent Refine Work Start (threads wanted: %u)", _cr->num_threads_wanted());

// Swap card tables.
Expand Down Expand Up @@ -178,9 +178,9 @@ void G1ConcurrentRefineThread::do_refinement() {
// 5. Sweep refinement table until done
bool interrupted_by_gc = false;

state.sweep_rt_start();
state.sweep_refinement_table_start();
while (true) {
bool completed = state.sweep_rt_step();
bool completed = state.sweep_refinement_table_step();

if (completed) {
break;
Expand All @@ -206,7 +206,7 @@ void G1ConcurrentRefineThread::do_refinement() {
if (!interrupted_by_gc) {
state.add_yield_duration(G1CollectedHeap::heap()->safepoint_duration() - synchronize_duration_at_sweep_start);

state.complete(true);
state.complete_work(true);

G1CollectedHeap* g1h = G1CollectedHeap::heap();
G1Policy* policy = g1h->policy();
Expand Down
4 changes: 2 additions & 2 deletions src/hotspot/share/gc/g1/g1ConcurrentRefineThread.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ class G1ConcurrentRefineThread: public ConcurrentGCThread {
// precondition: this is the current thread.
bool deactivate();

// Attempt to do some refinement work.
// precondition: this is the current thread.
// Swap card table and do a complete re-examination/refinement pass over the
// refinement table.
void do_refinement();

// Update concurrent refine threads stats.
Expand Down
2 changes: 1 addition & 1 deletion src/hotspot/share/gc/g1/g1Policy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -937,7 +937,7 @@ void G1Policy::record_young_collection_end(bool concurrent_operation_is_full_mar

{
double mutator_end_time = phase_times()->cur_collection_start_sec() * MILLIUNITS;
G1ConcurrentRefineStats* stats = _g1h->concurrent_refine()->refine_state().stats();
G1ConcurrentRefineStats* stats = _g1h->concurrent_refine()->sweep_state().stats();
// Record any available refinement statistics.
record_refinement_stats(stats);

Expand Down
Loading