8278581: Improve reference processing statistics log output

Reviewed-by: tschatzl, kbarrett, sjohanss
This commit is contained in:
Albert Mingkun Yang 2022-01-12 08:28:51 +00:00
parent bd339aa6c0
commit 4f0b65023f
4 changed files with 19 additions and 14 deletions

View File

@ -483,7 +483,7 @@ void RefProcTask::process_discovered_list(uint worker_id,
keep_alive,
enqueue,
do_enqueue_and_clear);
_phase_times->add_ref_cleared(ref_type, removed);
_phase_times->add_ref_dropped(ref_type, removed);
}
}

View File

@ -197,7 +197,7 @@ void ReferenceProcessorPhaseTimes::reset() {
_soft_weak_final_refs_phase_worker_time_sec->reset();
for (int i = 0; i < number_of_subclasses_of_ref; i++) {
_ref_cleared[i] = 0;
_ref_dropped[i] = 0;
_ref_discovered[i] = 0;
}
@ -213,9 +213,9 @@ ReferenceProcessorPhaseTimes::~ReferenceProcessorPhaseTimes() {
delete _soft_weak_final_refs_phase_worker_time_sec;
}
void ReferenceProcessorPhaseTimes::add_ref_cleared(ReferenceType ref_type, size_t count) {
void ReferenceProcessorPhaseTimes::add_ref_dropped(ReferenceType ref_type, size_t count) {
ASSERT_REF_TYPE(ref_type);
Atomic::add(&_ref_cleared[ref_type_2_index(ref_type)], count, memory_order_relaxed);
Atomic::add(&_ref_dropped[ref_type_2_index(ref_type)], count, memory_order_relaxed);
}
void ReferenceProcessorPhaseTimes::set_ref_discovered(ReferenceType ref_type, size_t count) {
@ -270,13 +270,16 @@ void ReferenceProcessorPhaseTimes::print_reference(ReferenceType ref_type, uint
LogStream ls(lt);
ResourceMark rm;
ls.print_cr("%s%s:", Indents[base_indent], ref_type_2_string(ref_type));
uint const next_indent = base_indent + 1;
int const ref_type_index = ref_type_2_index(ref_type);
ls.print_cr("%sDiscovered: " SIZE_FORMAT, Indents[next_indent], _ref_discovered[ref_type_index]);
ls.print_cr("%sCleared: " SIZE_FORMAT, Indents[next_indent], _ref_cleared[ref_type_index]);
size_t discovered = _ref_discovered[ref_type_index];
size_t dropped = _ref_dropped[ref_type_index];
assert(discovered >= dropped, "invariant");
size_t processed = discovered - dropped;
ls.print_cr("%s%s Discovered: %zu, Dropped: %zu, Processed: %zu",
Indents[base_indent], ref_type_2_string(ref_type),
discovered, dropped, processed);
}
}

View File

@ -52,7 +52,7 @@ class ReferenceProcessorPhaseTimes : public CHeapObj<mtGC> {
// Total spent time for reference processing.
double _total_time_ms;
size_t _ref_cleared[number_of_subclasses_of_ref];
size_t _ref_dropped[number_of_subclasses_of_ref];
size_t _ref_discovered[number_of_subclasses_of_ref];
bool _processing_is_mt;
@ -83,7 +83,7 @@ public:
void set_total_time_ms(double total_time_ms) { _total_time_ms = total_time_ms; }
void add_ref_cleared(ReferenceType ref_type, size_t count);
void add_ref_dropped(ReferenceType ref_type, size_t count);
void set_ref_discovered(ReferenceType ref_type, size_t count);
size_t ref_discovered(ReferenceType ref_type);

View File

@ -80,9 +80,11 @@ public class TestPrintReferences {
private static String refRegex(String reftype) {
String countRegex = "[0-9]+";
return gcLogTimeRegex + indent(6) + reftype + ":\n" +
gcLogTimeRegex + indent(8) + "Discovered: " + countRegex + "\n" +
gcLogTimeRegex + indent(8) + "Cleared: " + countRegex + "\n";
return gcLogTimeRegex + indent(6) + reftype + " " +
"Discovered: " + countRegex + ", " +
"Dropped: " + countRegex + ", " +
"Processed: " + countRegex + "\n"
;
}
private static void checkRefsLogFormat(OutputAnalyzer output) {