mirror of
https://github.com/openjdk/jdk.git
synced 2026-03-30 01:30:26 +00:00
8153745: Avoid spawning G1ParPreserveCMReferentsTask when there is no work to be done
Reviewed-by: brutisso, jmasa, tschatzl
This commit is contained in:
parent
a9e64aa572
commit
e79c2a2d8b
@ -4452,7 +4452,6 @@ void G1CollectedHeap::process_weak_jni_handles() {
|
||||
}
|
||||
|
||||
void G1CollectedHeap::preserve_cm_referents(G1ParScanThreadStateSet* per_thread_states) {
|
||||
double preserve_cm_referents_start = os::elapsedTime();
|
||||
// Any reference objects, in the collection set, that were 'discovered'
|
||||
// by the CM ref processor should have already been copied (either by
|
||||
// applying the external root copy closure to the discovered lists, or
|
||||
@ -4473,16 +4472,24 @@ void G1CollectedHeap::preserve_cm_referents(G1ParScanThreadStateSet* per_thread_
|
||||
// objects discovered by the STW ref processor in case one of these
|
||||
// referents points to another object which is also referenced by an
|
||||
// object discovered by the STW ref processor.
|
||||
double preserve_cm_referents_time = 0.0;
|
||||
|
||||
uint no_of_gc_workers = workers()->active_workers();
|
||||
// To avoid spawning task when there is no work to do, check that
|
||||
// a concurrent cycle is active and that some references have been
|
||||
// discovered.
|
||||
if (concurrent_mark()->cmThread()->during_cycle() &&
|
||||
ref_processor_cm()->has_discovered_references()) {
|
||||
double preserve_cm_referents_start = os::elapsedTime();
|
||||
uint no_of_gc_workers = workers()->active_workers();
|
||||
G1ParPreserveCMReferentsTask keep_cm_referents(this,
|
||||
per_thread_states,
|
||||
no_of_gc_workers,
|
||||
_task_queues);
|
||||
workers()->run_task(&keep_cm_referents);
|
||||
preserve_cm_referents_time = os::elapsedTime() - preserve_cm_referents_start;
|
||||
}
|
||||
|
||||
G1ParPreserveCMReferentsTask keep_cm_referents(this,
|
||||
per_thread_states,
|
||||
no_of_gc_workers,
|
||||
_task_queues);
|
||||
workers()->run_task(&keep_cm_referents);
|
||||
|
||||
g1_policy()->phase_times()->record_preserve_cm_referents_time_ms((os::elapsedTime() - preserve_cm_referents_start) * 1000.0);
|
||||
g1_policy()->phase_times()->record_preserve_cm_referents_time_ms(preserve_cm_referents_time * 1000.0);
|
||||
}
|
||||
|
||||
// Weak Reference processing during an evacuation pause (part 1).
|
||||
|
||||
@ -1090,6 +1090,15 @@ bool ReferenceProcessor::discover_reference(oop obj, ReferenceType rt) {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ReferenceProcessor::has_discovered_references() {
|
||||
for (uint i = 0; i < _max_num_q * number_of_subclasses_of_ref(); i++) {
|
||||
if (!_discovered_refs[i].is_empty()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// Preclean the discovered references by removing those
|
||||
// whose referents are alive, and by marking from those that
|
||||
// are not active. These lists can be handled here
|
||||
|
||||
@ -412,6 +412,9 @@ class ReferenceProcessor : public CHeapObj<mtGC> {
|
||||
// Discover a Reference object, using appropriate discovery criteria
|
||||
bool discover_reference(oop obj, ReferenceType rt);
|
||||
|
||||
// Has discovered references that need handling
|
||||
bool has_discovered_references();
|
||||
|
||||
// Process references found during GC (called by the garbage collector)
|
||||
ReferenceProcessorStats
|
||||
process_discovered_references(BoolObjectClosure* is_alive,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user