Skip to content

8359701: G1: Move heap expansion time tracking of G1CollectedHeap:expand to call site #25835

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 3 commits into from
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
15 changes: 5 additions & 10 deletions src/hotspot/share/gc/g1/g1CollectedHeap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1001,7 +1001,7 @@ HeapWord* G1CollectedHeap::expand_and_allocate(size_t word_size) {
return nullptr;
}

bool G1CollectedHeap::expand(size_t expand_bytes, WorkerThreads* pretouch_workers, double* expand_time_ms) {
bool G1CollectedHeap::expand(size_t expand_bytes, WorkerThreads* pretouch_workers) {
size_t aligned_expand_bytes = os::align_up_vm_page_size(expand_bytes);
aligned_expand_bytes = align_up(aligned_expand_bytes, G1HeapRegion::GrainBytes);

Expand All @@ -1013,15 +1013,10 @@ bool G1CollectedHeap::expand(size_t expand_bytes, WorkerThreads* pretouch_worker
return false;
}

double expand_heap_start_time_sec = os::elapsedTime();
uint regions_to_expand = (uint)(aligned_expand_bytes / G1HeapRegion::GrainBytes);
assert(regions_to_expand > 0, "Must expand by at least one region");

uint expanded_by = _hrm.expand_by(regions_to_expand, pretouch_workers);
if (expand_time_ms != nullptr) {
*expand_time_ms = (os::elapsedTime() - expand_heap_start_time_sec) * MILLIUNITS;
}

assert(expanded_by > 0, "must have failed during commit.");

size_t actual_expand_bytes = expanded_by * G1HeapRegion::GrainBytes;
Expand Down Expand Up @@ -2397,11 +2392,11 @@ void G1CollectedHeap::expand_heap_after_young_collection(){
if (expand_bytes > 0) {
// No need for an ergo logging here,
// expansion_amount() does this when it returns a value > 0.
double expand_ms = 0.0;
if (!expand(expand_bytes, _workers, &expand_ms)) {
// We failed to expand the heap. Cannot do anything about it.
Ticks expand_start = Ticks::now();
if (expand(expand_bytes, _workers)) {
double expand_ms = (Ticks::now() - expand_start).seconds() * MILLIUNITS;
phase_times()->record_expand_heap_time(expand_ms);
}
phase_times()->record_expand_heap_time(expand_ms);
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/hotspot/share/gc/g1/g1CollectedHeap.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -572,7 +572,7 @@ class G1CollectedHeap : public CollectedHeap {
// Returns true if the heap was expanded by the requested amount;
// false otherwise.
// (Rounds up to a G1HeapRegion boundary.)
bool expand(size_t expand_bytes, WorkerThreads* pretouch_workers, double* expand_time_ms = nullptr);
bool expand(size_t expand_bytes, WorkerThreads* pretouch_workers);
bool expand_single_region(uint node_index);

// Returns the PLAB statistics for a given destination.
Expand Down