Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: openjdk/shenandoah
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 99272621
Choose a base ref
...
head repository: openjdk/shenandoah
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 36618788
Choose a head ref

Commits on Oct 15, 2024

  1. Copy the full SHA
    16985c3 View commit details
  2. Bug fix

    pengxiaolong committed Oct 15, 2024
    Copy the full SHA
    a2e5645 View commit details
  3. typo

    pengxiaolong committed Oct 15, 2024
    Copy the full SHA
    768d1dd View commit details
  4. Copy the full SHA
    b249165 View commit details

Commits on Oct 16, 2024

  1. set_mark_bitmap_reset flag for both young and old generation when upd…

    …ate it for global generation
    pengxiaolong committed Oct 16, 2024
    Copy the full SHA
    aaa7680 View commit details
  2. Copy the full SHA
    8e50542 View commit details
  3. Copy the full SHA
    9ca7ed3 View commit details
  4. fix

    pengxiaolong committed Oct 16, 2024
    Copy the full SHA
    21213fd View commit details
  5. Fix

    pengxiaolong committed Oct 16, 2024
    Copy the full SHA
    b882bda View commit details
  6. Simplify

    pengxiaolong committed Oct 16, 2024
    Copy the full SHA
    d2d350e View commit details
  7. Fix

    pengxiaolong committed Oct 16, 2024
    Copy the full SHA
    be66577 View commit details
  8. Refactor

    pengxiaolong committed Oct 16, 2024
    Copy the full SHA
    ab231bd View commit details

Commits on Oct 17, 2024

  1. fix test error

    pengxiaolong committed Oct 17, 2024
    Copy the full SHA
    f9254d6 View commit details
  2. typo

    pengxiaolong committed Oct 17, 2024
    Copy the full SHA
    902720b View commit details
  3. Copy the full SHA
    a6d7543 View commit details
  4. Copy the full SHA
    7b95320 View commit details
  5. Copy the full SHA
    8c5f516 View commit details
  6. Copy the full SHA
    c081b38 View commit details
  7. bug fix

    pengxiaolong committed Oct 17, 2024
    Copy the full SHA
    f262904 View commit details
  8. comments

    pengxiaolong committed Oct 17, 2024
    Copy the full SHA
    0fd8977 View commit details
  9. Copy the full SHA
    a4c6c19 View commit details
  10. typo in comments

    pengxiaolong committed Oct 17, 2024
    Copy the full SHA
    57ee258 View commit details
  11. Copy the full SHA
    bbeea38 View commit details
  12. Copy the full SHA
    f984398 View commit details
  13. Address review comments

    pengxiaolong committed Oct 17, 2024
    Copy the full SHA
    d49ae59 View commit details

Commits on Oct 18, 2024

  1. Copy the full SHA
    d4fddac View commit details
  2. Copy the full SHA
    d283592 View commit details

Commits on Oct 24, 2024

  1. Copy the full SHA
    34b64ee View commit details
  2. Copy the full SHA
    cf22fbc View commit details
  3. Revert "set need_bitmap_reset flag when change affiliation of heap re…

    …gion from OLD_GENERATION"
    
    This reverts commit d4fddac.
    pengxiaolong committed Oct 24, 2024
    Copy the full SHA
    375a63a View commit details
  4. Copy the full SHA
    8d068b3 View commit details
  5. Copy the full SHA
    e7328c0 View commit details

Commits on Oct 26, 2024

  1. Copy the full SHA
    79ecb90 View commit details

Commits on Oct 28, 2024

  1. Copy the full SHA
    0c334b6 View commit details
  2. fix test failures

    pengxiaolong committed Oct 28, 2024
    Copy the full SHA
    7c21b91 View commit details
  3. Copy the full SHA
    df91d46 View commit details

Commits on Oct 29, 2024

  1. Copy the full SHA
    3661878 View commit details
45 changes: 44 additions & 1 deletion src/hotspot/share/gc/shenandoah/shenandoahConcurrentGC.cpp
Original file line number Diff line number Diff line change
@@ -236,6 +236,11 @@ bool ShenandoahConcurrentGC::collect(GCCause::Cause cause) {
if (heap->mode()->is_generational()) {
ShenandoahGenerationalHeap::heap()->complete_concurrent_cycle();
}

// Instead of always reset before collect, some reset can be done after collect to save
// the time before before the cycle so the cycle can be started as soon as possible.
entry_reset_after_collect();

return true;
}

@@ -578,6 +583,16 @@ void ShenandoahConcurrentGC::entry_cleanup_complete() {
op_cleanup_complete();
}

void ShenandoahConcurrentGC::entry_reset_after_collect() {
ShenandoahHeap* const heap = ShenandoahHeap::heap();
TraceCollectorStats tcs(heap->monitoring_support()->concurrent_collection_counters());
const char* msg = conc_reset_after_collect_event_message();
ShenandoahConcurrentPhase gc_phase(msg, ShenandoahPhaseTimings::conc_reset_after_collect);
EventMark em("%s", msg);

op_reset_after_collect();
}

void ShenandoahConcurrentGC::op_reset() {
ShenandoahHeap* const heap = ShenandoahHeap::heap();
if (ShenandoahPacing) {
@@ -1178,7 +1193,27 @@ void ShenandoahConcurrentGC::op_final_roots() {
}

void ShenandoahConcurrentGC::op_cleanup_complete() {
ShenandoahHeap::heap()->free_set()->recycle_trash();
ShenandoahHeap* const heap = ShenandoahHeap::heap();
heap->free_set()->recycle_trash();
}

void ShenandoahConcurrentGC::op_reset_after_collect() {
ShenandoahWorkerScope scope(ShenandoahHeap::heap()->workers(),
ShenandoahWorkerPolicy::calc_workers_for_conc_reset(),
"reset after collection.");

ShenandoahHeap* const heap = ShenandoahHeap::heap();
if (heap->mode()->is_generational()) {
if (!_do_old_gc_bootstrap) {
// Only reset for young generation, bitmap for old generation must be retained,
// except there is collection(global/old/degen/full) trigged to collect regions in old gen.
heap->young_generation()->reset_mark_bitmap();
heap->young_generation()->unset_need_bitmap_reset();
}
} else {
_generation->reset_mark_bitmap();
_generation->unset_need_bitmap_reset();
}
}

bool ShenandoahConcurrentGC::check_cancellation_and_abort(ShenandoahDegenPoint point) {
@@ -1230,6 +1265,14 @@ const char* ShenandoahConcurrentGC::conc_reset_event_message() const {
}
}

const char* ShenandoahConcurrentGC::conc_reset_after_collect_event_message() const {
if (ShenandoahHeap::heap()->unload_classes()) {
SHENANDOAH_RETURN_EVENT_MESSAGE(_generation->type(), "Concurrent reset after collect", " (unload classes)");
} else {
SHENANDOAH_RETURN_EVENT_MESSAGE(_generation->type(), "Concurrent reset after collect", "");
}
}

const char* ShenandoahConcurrentGC::final_roots_event_message() const {
if (ShenandoahHeap::heap()->unload_classes()) {
SHENANDOAH_RETURN_EVENT_MESSAGE(_generation->type(), "Pause Final Roots", " (unload classes)");
4 changes: 4 additions & 0 deletions src/hotspot/share/gc/shenandoah/shenandoahConcurrentGC.hpp
Original file line number Diff line number Diff line change
@@ -129,9 +129,12 @@ class ShenandoahConcurrentGC : public ShenandoahGC {
void op_final_roots();

void op_cleanup_complete();
void op_reset_after_collect();

protected:
virtual void op_final_mark();
// Called when concurrent GC succeeds.
void entry_reset_after_collect();

private:
void start_mark();
@@ -145,6 +148,7 @@ class ShenandoahConcurrentGC : public ShenandoahGC {
const char* final_roots_event_message() const;
const char* conc_mark_event_message() const;
const char* conc_reset_event_message() const;
const char* conc_reset_after_collect_event_message() const;
const char* conc_weak_refs_event_message() const;
const char* conc_weak_roots_event_message() const;
const char* conc_cleanup_event_message() const;
2 changes: 2 additions & 0 deletions src/hotspot/share/gc/shenandoah/shenandoahFullGC.cpp
Original file line number Diff line number Diff line change
@@ -193,6 +193,8 @@ void ShenandoahFullGC::do_it(GCCause::Cause gc_cause) {

// d. Reset the bitmaps for new marking
heap->global_generation()->reset_mark_bitmap();
heap->global_generation()->set_need_bitmap_reset();
heap->global_generation()->set_mark_incomplete();
assert(heap->marking_context()->is_bitmap_clear(), "sanity");
assert(!heap->global_generation()->is_mark_complete(), "sanity");

62 changes: 49 additions & 13 deletions src/hotspot/share/gc/shenandoah/shenandoahGeneration.cpp
Original file line number Diff line number Diff line change
@@ -44,15 +44,17 @@

class ShenandoahResetUpdateRegionStateClosure : public ShenandoahHeapRegionClosure {
private:
ShenandoahHeap* _heap;
ShenandoahGeneration* const _generation;
ShenandoahHeap* const _heap;
ShenandoahMarkingContext* const _ctx;
public:
ShenandoahResetUpdateRegionStateClosure() :
ShenandoahResetUpdateRegionStateClosure(ShenandoahGeneration* generation) :
_generation(generation),
_heap(ShenandoahHeap::heap()),
_ctx(_heap->marking_context()) {}

void heap_region_do(ShenandoahHeapRegion* r) override {
if (r->is_active()) {
if (r->is_active() && _generation->contains(r)) {
// Reset live data and set TAMS optimistically. We would recheck these under the pause
// anyway to capture any updates that happened since now.
_ctx->capture_top_at_mark_start(r);
@@ -67,18 +69,21 @@ class ShenandoahResetBitmapTask : public WorkerTask {
private:
ShenandoahRegionIterator _regions;
ShenandoahGeneration* _generation;
bool const _include_not_affiliated;

public:
ShenandoahResetBitmapTask(ShenandoahGeneration* generation) :
WorkerTask("Shenandoah Reset Bitmap"), _generation(generation) {}
ShenandoahResetBitmapTask(ShenandoahGeneration* generation, bool const include_not_affiliated = true) :
WorkerTask("Shenandoah Reset Bitmap"),
_generation(generation),
_include_not_affiliated(include_not_affiliated){}

void work(uint worker_id) {
ShenandoahHeapRegion* region = _regions.next();
ShenandoahHeap* heap = ShenandoahHeap::heap();
ShenandoahMarkingContext* const ctx = heap->marking_context();
while (region != nullptr) {
auto const affiliation = region->affiliation();
bool needs_reset = affiliation == FREE || _generation->contains(affiliation);
bool needs_reset = (_include_not_affiliated && affiliation == FREE) || _generation->contains(affiliation);
if (needs_reset && heap->is_bitmap_slice_committed(region)) {
ctx->clear_bitmap(region);
}
@@ -189,14 +194,14 @@ void ShenandoahGeneration::log_status(const char *msg) const {
byte_size_in_proper_unit(v_available), proper_unit_for_byte_size(v_available));
}

void ShenandoahGeneration::reset_mark_bitmap() {
void ShenandoahGeneration::reset_mark_bitmap(bool include_not_affiliated) {
ShenandoahHeap* heap = ShenandoahHeap::heap();
heap->assert_gc_workers(heap->workers()->active_workers());

set_mark_incomplete();

ShenandoahResetBitmapTask task(this);
ShenandoahResetBitmapTask task(this, include_not_affiliated);
heap->workers()->run_task(&task);
// Always set mark incomplete after reseting mark bitmap.
set_mark_incomplete();
}

// The ideal is to swap the remembered set so the safepoint effort is no more than a few pointer manipulations.
@@ -229,11 +234,25 @@ void ShenandoahGeneration::merge_write_table() {
}

void ShenandoahGeneration::prepare_gc() {
ShenandoahHeap* const heap = ShenandoahHeap::heap();
if (need_bitmap_reset()) {
if (heap->mode()->is_generational() && is_global() && !heap->young_generation()->need_bitmap_reset()) {
assert(heap->young_generation()->is_bitmap_clear(), "Bitmap of young generation must be clear.");
//Only need to reset bitmap for old generation.
heap->old_generation()->reset_mark_bitmap(false);
set_mark_incomplete();
} else {
reset_mark_bitmap();
}
}
assert(!is_mark_complete(), "Must not.");
assert(is_bitmap_clear(), "Bitmap must be clear.");

reset_mark_bitmap();
// For next cycle
set_need_bitmap_reset();

// Capture Top At Mark Start for this generation (typically young) and reset mark bitmap.
ShenandoahResetUpdateRegionStateClosure cl;
// Capture Top At Mark Start for this generation (typically young).
ShenandoahResetUpdateRegionStateClosure cl(this);
parallel_region_iterate_free(&cl);
}

@@ -762,6 +781,22 @@ bool ShenandoahGeneration::is_bitmap_clear() {
return true;
}

bool ShenandoahGeneration::need_bitmap_reset() {
return _need_bitmap_reset.is_set();
}

void ShenandoahGeneration::set_need_bitmap_reset() {
_need_bitmap_reset.set();
if (ShenandoahHeap::heap()->mode()->is_generational() && is_global()) {
ShenandoahHeap::heap()->old_generation()->set_need_bitmap_reset();
ShenandoahHeap::heap()->young_generation()->set_need_bitmap_reset();
}
}

void ShenandoahGeneration::unset_need_bitmap_reset() {
_need_bitmap_reset.unset();
}

bool ShenandoahGeneration::is_mark_complete() {
return _is_marking_complete.is_set();
}
@@ -802,6 +837,7 @@ ShenandoahGeneration::ShenandoahGeneration(ShenandoahGenerationType type,
_heuristics(nullptr)
{
_is_marking_complete.set();
_need_bitmap_reset.set();
assert(max_workers > 0, "At least one queue");
for (uint i = 0; i < max_workers; ++i) {
ShenandoahObjToScanQueue* task_queue = new ShenandoahObjToScanQueue();
8 changes: 7 additions & 1 deletion src/hotspot/share/gc/shenandoah/shenandoahGeneration.hpp
Original file line number Diff line number Diff line change
@@ -49,6 +49,7 @@ class ShenandoahGeneration : public CHeapObj<mtGC>, public ShenandoahSpaceInfo {
// Marking task queues and completeness
ShenandoahObjToScanQueueSet* _task_queues;
ShenandoahSharedFlag _is_marking_complete;
ShenandoahSharedFlag _need_bitmap_reset;

ShenandoahReferenceProcessor* const _ref_processor;

@@ -159,7 +160,7 @@ class ShenandoahGeneration : public CHeapObj<mtGC>, public ShenandoahSpaceInfo {
void log_status(const char* msg) const;

// Used directly by FullGC
void reset_mark_bitmap();
void reset_mark_bitmap(bool include_not_affiliated = true);

// Used by concurrent and degenerated GC to reset remembered set.
void swap_remembered_set();
@@ -199,6 +200,11 @@ class ShenandoahGeneration : public CHeapObj<mtGC>, public ShenandoahSpaceInfo {
// Check the bitmap only for regions belong to this generation.
bool is_bitmap_clear();

// Fast check if the mark bitmap need to be reset for next cycle.
bool need_bitmap_reset();
void set_need_bitmap_reset();
void unset_need_bitmap_reset();

// We need to track the status of marking for different generations.
bool is_mark_complete();
virtual void set_mark_complete();
1 change: 1 addition & 0 deletions src/hotspot/share/gc/shenandoah/shenandoahPhaseTimings.hpp
Original file line number Diff line number Diff line change
@@ -50,6 +50,7 @@ class outputStream;

#define SHENANDOAH_PHASE_DO(f) \
f(conc_reset, "Concurrent Reset") \
f(conc_reset_after_collect, "Concurrent Reset After Collect") \
f(conc_reset_old, "Concurrent Reset (OLD)") \
f(init_mark_gross, "Pause Init Mark (G)") \
f(init_mark, "Pause Init Mark (N)") \