Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions src/hotspot/share/gc/serial/defNewGeneration.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@ class DefNewGeneration: public Generation {
// Return true if the expansion was successful.
bool expand(size_t bytes);

STWGCTimer* gc_timer() const { return _gc_timer; }

// Iteration
void object_iterate(ObjectClosure* blk);
Expand Down
26 changes: 23 additions & 3 deletions src/hotspot/share/gc/serial/serialHeap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -329,9 +329,9 @@ HeapWord* SerialHeap::mem_allocate_work(size_t size,
{
MutexLocker ml(Heap_lock);
log_trace(gc, alloc)("SerialHeap::mem_allocate_work: attempting locked slow path allocation");
// Note that only large objects get a shot at being
// allocated in later generations.
bool first_only = !should_try_older_generation_allocation(size);

bool first_only = !should_try_older_generation_allocation(size)
&& is_long_enough_from_prev_gc_pause_end();
Comment on lines -332 to +334
Copy link
Member

Choose a reason for hiding this comment

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

Is the first_only actually young_only? It means that the allocation is only attempted in young generation?

Copy link
Member Author

Choose a reason for hiding this comment

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

That's true. I believe Serial used to support >2 generations, so some generic names are left as is. Fixing it requires updating in multiple places, such as the method name older_generation, arg in attempt_allocation, etc. How about we do that invasive but pure refactoring in its own PR?

Copy link
Member

Choose a reason for hiding this comment

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

Yes, such refactoring should be finished in other issues.


result = attempt_allocation(size, is_tlab, first_only);
if (result != nullptr) {
Expand Down Expand Up @@ -634,6 +634,26 @@ void SerialHeap::scan_evacuated_objs(YoungGenScanClosure* young_cl,
guarantee(young_gen()->promo_failure_scan_is_complete(), "Failed to finish scan");
}

bool SerialHeap::is_long_enough_from_prev_gc_pause_end() const {
Ticks young_gc_pause_end = _young_gen->gc_timer()->gc_end();
Ticks full_gc_pause_end = SerialFullGC::gc_timer()->gc_end();

Ticks prev_gc_pause_end;
Tickspan gc_pause;
if (full_gc_pause_end < young_gc_pause_end) {
// Previous is young-gc
prev_gc_pause_end = young_gc_pause_end;
gc_pause = young_gc_pause_end - _young_gen->gc_timer()->gc_start();
} else {
// Previous is full-gc
prev_gc_pause_end = full_gc_pause_end;
gc_pause = full_gc_pause_end - SerialFullGC::gc_timer()->gc_start();
}
Tickspan since_end_gc_pause = Ticks::now() - prev_gc_pause_end;

return since_end_gc_pause.seconds() * 100 >= gc_pause.seconds() * GCTimeRatio;
}

void SerialHeap::try_collect_at_safepoint(bool full) {
assert(SafepointSynchronize::is_at_safepoint(), "precondition");
if (GCLocker::check_active_before_gc()) {
Expand Down
2 changes: 2 additions & 0 deletions src/hotspot/share/gc/serial/serialHeap.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,8 @@ class SerialHeap : public CollectedHeap {

bool is_in_reserved(const void* addr) const { return _reserved.contains(addr); }

bool is_long_enough_from_prev_gc_pause_end() const;

// Performance Counter support
GCPolicyCounters* counters() { return _gc_policy_counters; }

Expand Down