mirror of
https://github.com/openjdk/jdk.git
synced 2026-02-24 09:10:08 +00:00
Merge
This commit is contained in:
commit
2685f965d3
@ -626,6 +626,7 @@ CMSCollector::CMSCollector(ConcurrentMarkSweepGeneration* cmsGen,
|
||||
|
||||
NOT_PRODUCT(_overflow_counter = CMSMarkStackOverflowInterval;)
|
||||
_gc_counters = new CollectorCounters("CMS", 1);
|
||||
_cgc_counters = new CollectorCounters("CMS stop-the-world phases", 2);
|
||||
_completed_initialization = true;
|
||||
_inter_sweep_timer.start(); // start of time
|
||||
}
|
||||
@ -5546,18 +5547,18 @@ void CMSCollector::reset_stw() {
|
||||
|
||||
void CMSCollector::do_CMS_operation(CMS_op_type op, GCCause::Cause gc_cause) {
|
||||
GCTraceCPUTime tcpu;
|
||||
TraceCollectorStats tcs(counters());
|
||||
TraceCollectorStats tcs(cgc_counters());
|
||||
|
||||
switch (op) {
|
||||
case CMS_op_checkpointRootsInitial: {
|
||||
GCTraceTime(Info, gc) t("Pause Initial Mark", NULL, GCCause::_no_gc, true);
|
||||
SvcGCMarker sgcm(SvcGCMarker::OTHER);
|
||||
SvcGCMarker sgcm(SvcGCMarker::CONCURRENT);
|
||||
checkpointRootsInitial();
|
||||
break;
|
||||
}
|
||||
case CMS_op_checkpointRootsFinal: {
|
||||
GCTraceTime(Info, gc) t("Pause Remark", NULL, GCCause::_no_gc, true);
|
||||
SvcGCMarker sgcm(SvcGCMarker::OTHER);
|
||||
SvcGCMarker sgcm(SvcGCMarker::CONCURRENT);
|
||||
checkpointRootsFinal();
|
||||
break;
|
||||
}
|
||||
|
||||
@ -555,6 +555,7 @@ class CMSCollector: public CHeapObj<mtGC> {
|
||||
|
||||
// Performance Counters
|
||||
CollectorCounters* _gc_counters;
|
||||
CollectorCounters* _cgc_counters;
|
||||
|
||||
// Initialization Errors
|
||||
bool _completed_initialization;
|
||||
@ -929,7 +930,8 @@ class CMSCollector: public CHeapObj<mtGC> {
|
||||
NOT_PRODUCT(bool is_cms_reachable(HeapWord* addr);)
|
||||
|
||||
// Performance Counter Support
|
||||
CollectorCounters* counters() { return _gc_counters; }
|
||||
CollectorCounters* counters() { return _gc_counters; }
|
||||
CollectorCounters* cgc_counters() { return _cgc_counters; }
|
||||
|
||||
// Timer stuff
|
||||
void startTimer() { assert(!_timer.is_active(), "Error"); _timer.start(); }
|
||||
|
||||
@ -3228,7 +3228,7 @@ G1CollectedHeap::do_collection_pause_at_safepoint(double target_pause_time_ms) {
|
||||
Threads::number_of_non_daemon_threads());
|
||||
workers()->set_active_workers(active_workers);
|
||||
|
||||
g1_policy()->note_gc_start(active_workers);
|
||||
g1_policy()->note_gc_start();
|
||||
|
||||
TraceCollectorStats tcs(g1mm()->incremental_collection_counters());
|
||||
TraceMemoryManagerStats tms(false /* fullGC */, gc_cause());
|
||||
|
||||
@ -186,8 +186,8 @@ void G1CollectorPolicy::init() {
|
||||
_collection_set->start_incremental_building();
|
||||
}
|
||||
|
||||
void G1CollectorPolicy::note_gc_start(uint num_active_workers) {
|
||||
phase_times()->note_gc_start(num_active_workers);
|
||||
void G1CollectorPolicy::note_gc_start() {
|
||||
phase_times()->note_gc_start();
|
||||
}
|
||||
|
||||
// Create the jstat counters for the policy.
|
||||
|
||||
@ -317,7 +317,7 @@ public:
|
||||
|
||||
void init();
|
||||
|
||||
virtual void note_gc_start(uint num_active_workers);
|
||||
virtual void note_gc_start();
|
||||
|
||||
// Create jstat counters for the policy.
|
||||
virtual void initialize_gc_policy_counters();
|
||||
|
||||
@ -1072,8 +1072,6 @@ void G1ConcurrentMark::checkpointRootsFinal(bool clear_all_soft_refs) {
|
||||
return;
|
||||
}
|
||||
|
||||
SvcGCMarker sgcm(SvcGCMarker::OTHER);
|
||||
|
||||
if (VerifyDuringGC) {
|
||||
HandleMark hm; // handle scope
|
||||
g1h->prepare_for_verify();
|
||||
|
||||
@ -33,7 +33,7 @@
|
||||
#include "runtime/timer.hpp"
|
||||
#include "runtime/os.hpp"
|
||||
|
||||
static const char* Indents[5] = {"", " ", " ", " ", " "};
|
||||
static const char* Indents[5] = {"", " ", " ", " ", " "};
|
||||
|
||||
G1GCPhaseTimes::G1GCPhaseTimes(uint max_gc_threads) :
|
||||
_max_gc_threads(max_gc_threads)
|
||||
@ -94,11 +94,8 @@ G1GCPhaseTimes::G1GCPhaseTimes(uint max_gc_threads) :
|
||||
_gc_par_phases[PreserveCMReferents] = new WorkerDataArray<double>(max_gc_threads, "Parallel Preserve CM Refs (ms):");
|
||||
}
|
||||
|
||||
void G1GCPhaseTimes::note_gc_start(uint active_gc_threads) {
|
||||
assert(active_gc_threads > 0, "The number of threads must be > 0");
|
||||
assert(active_gc_threads <= _max_gc_threads, "The number of active threads must be <= the max number of threads");
|
||||
void G1GCPhaseTimes::note_gc_start() {
|
||||
_gc_start_counter = os::elapsed_counter();
|
||||
_active_gc_threads = active_gc_threads;
|
||||
_cur_expand_heap_time_ms = 0.0;
|
||||
_external_accounted_time_ms = 0.0;
|
||||
|
||||
@ -109,31 +106,55 @@ void G1GCPhaseTimes::note_gc_start(uint active_gc_threads) {
|
||||
}
|
||||
}
|
||||
|
||||
#define ASSERT_PHASE_UNINITIALIZED(phase) \
|
||||
assert(_gc_par_phases[phase]->get(i) == uninitialized, "Phase " #phase " reported for thread that was not started");
|
||||
|
||||
double G1GCPhaseTimes::worker_time(GCParPhases phase, uint worker) {
|
||||
double value = _gc_par_phases[phase]->get(worker);
|
||||
if (value != WorkerDataArray<double>::uninitialized()) {
|
||||
return value;
|
||||
}
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
void G1GCPhaseTimes::note_gc_end() {
|
||||
_gc_pause_time_ms = TimeHelper::counter_to_millis(os::elapsed_counter() - _gc_start_counter);
|
||||
for (uint i = 0; i < _active_gc_threads; i++) {
|
||||
double worker_time = _gc_par_phases[GCWorkerEnd]->get(i) - _gc_par_phases[GCWorkerStart]->get(i);
|
||||
record_time_secs(GCWorkerTotal, i , worker_time);
|
||||
|
||||
double worker_known_time =
|
||||
_gc_par_phases[ExtRootScan]->get(i) +
|
||||
_gc_par_phases[SATBFiltering]->get(i) +
|
||||
_gc_par_phases[UpdateRS]->get(i) +
|
||||
_gc_par_phases[ScanRS]->get(i) +
|
||||
_gc_par_phases[CodeRoots]->get(i) +
|
||||
_gc_par_phases[ObjCopy]->get(i) +
|
||||
_gc_par_phases[Termination]->get(i);
|
||||
double uninitialized = WorkerDataArray<double>::uninitialized();
|
||||
|
||||
record_time_secs(Other, i, worker_time - worker_known_time);
|
||||
}
|
||||
for (uint i = 0; i < _max_gc_threads; i++) {
|
||||
double worker_start = _gc_par_phases[GCWorkerStart]->get(i);
|
||||
if (worker_start != uninitialized) {
|
||||
assert(_gc_par_phases[GCWorkerEnd]->get(i) != uninitialized, "Worker started but not ended.");
|
||||
double total_worker_time = _gc_par_phases[GCWorkerEnd]->get(i) - _gc_par_phases[GCWorkerStart]->get(i);
|
||||
record_time_secs(GCWorkerTotal, i , total_worker_time);
|
||||
|
||||
for (int i = 0; i < GCParPhasesSentinel; i++) {
|
||||
if (_gc_par_phases[i] != NULL) {
|
||||
_gc_par_phases[i]->verify(_active_gc_threads);
|
||||
double worker_known_time =
|
||||
worker_time(ExtRootScan, i)
|
||||
+ worker_time(SATBFiltering, i)
|
||||
+ worker_time(UpdateRS, i)
|
||||
+ worker_time(ScanRS, i)
|
||||
+ worker_time(CodeRoots, i)
|
||||
+ worker_time(ObjCopy, i)
|
||||
+ worker_time(Termination, i);
|
||||
|
||||
record_time_secs(Other, i, total_worker_time - worker_known_time);
|
||||
} else {
|
||||
// Make sure all slots are uninitialized since this thread did not seem to have been started
|
||||
ASSERT_PHASE_UNINITIALIZED(GCWorkerEnd);
|
||||
ASSERT_PHASE_UNINITIALIZED(ExtRootScan);
|
||||
ASSERT_PHASE_UNINITIALIZED(SATBFiltering);
|
||||
ASSERT_PHASE_UNINITIALIZED(UpdateRS);
|
||||
ASSERT_PHASE_UNINITIALIZED(ScanRS);
|
||||
ASSERT_PHASE_UNINITIALIZED(CodeRoots);
|
||||
ASSERT_PHASE_UNINITIALIZED(ObjCopy);
|
||||
ASSERT_PHASE_UNINITIALIZED(Termination);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#undef ASSERT_PHASE_UNINITIALIZED
|
||||
|
||||
// record the time a phase took in seconds
|
||||
void G1GCPhaseTimes::record_time_secs(GCParPhases phase, uint worker_i, double secs) {
|
||||
_gc_par_phases[phase]->set(worker_i, secs);
|
||||
@ -150,12 +171,12 @@ void G1GCPhaseTimes::record_thread_work_item(GCParPhases phase, uint worker_i, s
|
||||
|
||||
// return the average time for a phase in milliseconds
|
||||
double G1GCPhaseTimes::average_time_ms(GCParPhases phase) {
|
||||
return _gc_par_phases[phase]->average(_active_gc_threads) * 1000.0;
|
||||
return _gc_par_phases[phase]->average() * 1000.0;
|
||||
}
|
||||
|
||||
size_t G1GCPhaseTimes::sum_thread_work_items(GCParPhases phase) {
|
||||
assert(_gc_par_phases[phase]->thread_work_items() != NULL, "No sub count");
|
||||
return _gc_par_phases[phase]->thread_work_items()->sum(_active_gc_threads);
|
||||
return _gc_par_phases[phase]->thread_work_items()->sum();
|
||||
}
|
||||
|
||||
template <class T>
|
||||
@ -164,19 +185,19 @@ void G1GCPhaseTimes::details(T* phase, const char* indent) {
|
||||
if (log.is_level(LogLevel::Trace)) {
|
||||
outputStream* trace_out = log.trace_stream();
|
||||
trace_out->print("%s", indent);
|
||||
phase->print_details_on(trace_out, _active_gc_threads);
|
||||
phase->print_details_on(trace_out);
|
||||
}
|
||||
}
|
||||
|
||||
void G1GCPhaseTimes::log_phase(WorkerDataArray<double>* phase, uint indent, outputStream* out, bool print_sum) {
|
||||
out->print("%s", Indents[indent]);
|
||||
phase->print_summary_on(out, _active_gc_threads, print_sum);
|
||||
phase->print_summary_on(out, print_sum);
|
||||
details(phase, Indents[indent]);
|
||||
|
||||
WorkerDataArray<size_t>* work_items = phase->thread_work_items();
|
||||
if (work_items != NULL) {
|
||||
out->print("%s", Indents[indent + 1]);
|
||||
work_items->print_summary_on(out, _active_gc_threads, true);
|
||||
work_items->print_summary_on(out, true);
|
||||
details(work_items, Indents[indent + 1]);
|
||||
}
|
||||
}
|
||||
|
||||
@ -32,7 +32,6 @@ class LineBuffer;
|
||||
template <class T> class WorkerDataArray;
|
||||
|
||||
class G1GCPhaseTimes : public CHeapObj<mtGC> {
|
||||
uint _active_gc_threads;
|
||||
uint _max_gc_threads;
|
||||
jlong _gc_start_counter;
|
||||
double _gc_pause_time_ms;
|
||||
@ -123,6 +122,7 @@ class G1GCPhaseTimes : public CHeapObj<mtGC> {
|
||||
double _cur_verify_before_time_ms;
|
||||
double _cur_verify_after_time_ms;
|
||||
|
||||
double worker_time(GCParPhases phase, uint worker);
|
||||
void note_gc_end();
|
||||
|
||||
template <class T>
|
||||
@ -133,7 +133,7 @@ class G1GCPhaseTimes : public CHeapObj<mtGC> {
|
||||
|
||||
public:
|
||||
G1GCPhaseTimes(uint max_gc_threads);
|
||||
void note_gc_start(uint active_gc_threads);
|
||||
void note_gc_start();
|
||||
void print();
|
||||
|
||||
// record the time a phase took in seconds
|
||||
|
||||
@ -76,6 +76,7 @@ G1MonitoringSupport::G1MonitoringSupport(G1CollectedHeap* g1h) :
|
||||
_g1h(g1h),
|
||||
_incremental_collection_counters(NULL),
|
||||
_full_collection_counters(NULL),
|
||||
_conc_collection_counters(NULL),
|
||||
_old_collection_counters(NULL),
|
||||
_old_space_counters(NULL),
|
||||
_young_collection_counters(NULL),
|
||||
@ -104,6 +105,9 @@ G1MonitoringSupport::G1MonitoringSupport(G1CollectedHeap* g1h) :
|
||||
// old generation collection.
|
||||
_full_collection_counters =
|
||||
new CollectorCounters("G1 stop-the-world full collections", 1);
|
||||
// name "collector.2". STW phases as part of a concurrent collection.
|
||||
_conc_collection_counters =
|
||||
new CollectorCounters("G1 stop-the-world phases", 2);
|
||||
|
||||
// timer sampling for all counters supporting sampling only update the
|
||||
// used value. See the take_sample() method. G1 requires both used and
|
||||
|
||||
@ -122,6 +122,8 @@ class G1MonitoringSupport : public CHeapObj<mtGC> {
|
||||
CollectorCounters* _incremental_collection_counters;
|
||||
// full stop-the-world collections
|
||||
CollectorCounters* _full_collection_counters;
|
||||
// stop-the-world phases in G1
|
||||
CollectorCounters* _conc_collection_counters;
|
||||
// young collection set counters. The _eden_counters,
|
||||
// _from_counters, and _to_counters are associated with
|
||||
// this "generational" counter.
|
||||
@ -210,6 +212,9 @@ class G1MonitoringSupport : public CHeapObj<mtGC> {
|
||||
CollectorCounters* full_collection_counters() {
|
||||
return _full_collection_counters;
|
||||
}
|
||||
CollectorCounters* conc_collection_counters() {
|
||||
return _conc_collection_counters;
|
||||
}
|
||||
GenerationCounters* young_collection_counters() {
|
||||
return _young_collection_counters;
|
||||
}
|
||||
|
||||
@ -217,6 +217,8 @@ void VM_CGC_Operation::doit() {
|
||||
GCTraceCPUTime tcpu;
|
||||
G1CollectedHeap* g1h = G1CollectedHeap::heap();
|
||||
GCTraceTime(Info, gc) t(_printGCMessage, g1h->concurrent_mark()->gc_timer_cm(), GCCause::_no_gc, true);
|
||||
TraceCollectorStats tcs(g1h->g1mm()->conc_collection_counters());
|
||||
SvcGCMarker sgcm(SvcGCMarker::CONCURRENT);
|
||||
IsGCActiveMark x;
|
||||
_cl->do_void();
|
||||
}
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -27,67 +27,178 @@
|
||||
#include "utilities/ostream.hpp"
|
||||
|
||||
template <>
|
||||
void WorkerDataArray<double>::WDAPrinter::summary(outputStream* out, const char* title, double min, double avg, double max, double diff, double sum, bool print_sum) {
|
||||
out->print("%-25s Min: %4.1lf, Avg: %4.1lf, Max: %4.1lf, Diff: %4.1lf", title, min * MILLIUNITS, avg * MILLIUNITS, max * MILLIUNITS, diff* MILLIUNITS);
|
||||
size_t WorkerDataArray<size_t>::uninitialized() {
|
||||
return (size_t)-1;
|
||||
}
|
||||
|
||||
template <>
|
||||
double WorkerDataArray<double>::uninitialized() {
|
||||
return -1.0;
|
||||
}
|
||||
|
||||
template <>
|
||||
void WorkerDataArray<double>::WDAPrinter::summary(outputStream* out, double min, double avg, double max, double diff, double sum, bool print_sum) {
|
||||
out->print(" Min: %4.1lf, Avg: %4.1lf, Max: %4.1lf, Diff: %4.1lf", min * MILLIUNITS, avg * MILLIUNITS, max * MILLIUNITS, diff* MILLIUNITS);
|
||||
if (print_sum) {
|
||||
out->print_cr(", Sum: %4.1lf", sum * MILLIUNITS);
|
||||
} else {
|
||||
out->cr();
|
||||
out->print(", Sum: %4.1lf", sum * MILLIUNITS);
|
||||
}
|
||||
}
|
||||
|
||||
template <>
|
||||
void WorkerDataArray<size_t>::WDAPrinter::summary(outputStream* out, const char* title, size_t min, double avg, size_t max, size_t diff, size_t sum, bool print_sum) {
|
||||
out->print("%-25s Min: " SIZE_FORMAT ", Avg: %4.1lf, Max: " SIZE_FORMAT ", Diff: " SIZE_FORMAT, title, min, avg, max, diff);
|
||||
void WorkerDataArray<size_t>::WDAPrinter::summary(outputStream* out, size_t min, double avg, size_t max, size_t diff, size_t sum, bool print_sum) {
|
||||
out->print(" Min: " SIZE_FORMAT ", Avg: %4.1lf, Max: " SIZE_FORMAT ", Diff: " SIZE_FORMAT, min, avg, max, diff);
|
||||
if (print_sum) {
|
||||
out->print_cr(", Sum: " SIZE_FORMAT, sum);
|
||||
} else {
|
||||
out->cr();
|
||||
out->print(", Sum: " SIZE_FORMAT, sum);
|
||||
}
|
||||
}
|
||||
|
||||
template <>
|
||||
void WorkerDataArray<double>::WDAPrinter::details(const WorkerDataArray<double>* phase, outputStream* out, uint active_threads) {
|
||||
void WorkerDataArray<double>::WDAPrinter::details(const WorkerDataArray<double>* phase, outputStream* out) {
|
||||
out->print("%-25s", "");
|
||||
for (uint i = 0; i < active_threads; ++i) {
|
||||
out->print(" %4.1lf", phase->get(i) * 1000.0);
|
||||
for (uint i = 0; i < phase->_length; ++i) {
|
||||
double value = phase->get(i);
|
||||
if (value != phase->uninitialized()) {
|
||||
out->print(" %4.1lf", phase->get(i) * 1000.0);
|
||||
} else {
|
||||
out->print(" -");
|
||||
}
|
||||
}
|
||||
out->cr();
|
||||
}
|
||||
|
||||
template <>
|
||||
void WorkerDataArray<size_t>::WDAPrinter::details(const WorkerDataArray<size_t>* phase, outputStream* out, uint active_threads) {
|
||||
void WorkerDataArray<size_t>::WDAPrinter::details(const WorkerDataArray<size_t>* phase, outputStream* out) {
|
||||
out->print("%-25s", "");
|
||||
for (uint i = 0; i < active_threads; ++i) {
|
||||
out->print(" " SIZE_FORMAT, phase->get(i));
|
||||
for (uint i = 0; i < phase->_length; ++i) {
|
||||
size_t value = phase->get(i);
|
||||
if (value != phase->uninitialized()) {
|
||||
out->print(" " SIZE_FORMAT, phase->get(i));
|
||||
} else {
|
||||
out->print(" -");
|
||||
}
|
||||
}
|
||||
out->cr();
|
||||
}
|
||||
|
||||
#ifndef PRODUCT
|
||||
void WorkerDataArray_test() {
|
||||
const uint length = 3;
|
||||
const char* title = "Test array";
|
||||
|
||||
WorkerDataArray<size_t> array(length, title);
|
||||
assert(strncmp(array.title(), title, strlen(title)) == 0 , "Expected titles to match");
|
||||
#include "memory/resourceArea.hpp"
|
||||
|
||||
const size_t expected[length] = {5, 3, 7};
|
||||
for (uint i = 0; i < length; i++) {
|
||||
array.set(i, expected[i]);
|
||||
}
|
||||
for (uint i = 0; i < length; i++) {
|
||||
assert(array.get(i) == expected[i], "Expected elements to match");
|
||||
}
|
||||
void WorkerDataArray_test_verify_string(const char* expected_string, const char* actual_string) {
|
||||
const size_t expected_len = strlen(expected_string);
|
||||
|
||||
assert(array.sum(length) == (5 + 3 + 7), "Expected sums to match");
|
||||
assert(array.average(length) == 5.0, "Expected averages to match");
|
||||
assert(expected_len == strlen(actual_string),
|
||||
"Wrong string length, expected " SIZE_FORMAT " but got " SIZE_FORMAT "(Expected '%s' but got: '%s')",
|
||||
expected_len, strlen(actual_string), expected_string, actual_string);
|
||||
|
||||
for (uint i = 0; i < length; i++) {
|
||||
array.add(i, 1);
|
||||
}
|
||||
for (uint i = 0; i < length; i++) {
|
||||
assert(array.get(i) == expected[i] + 1, "Expected add to increment values");
|
||||
// Can't use strncmp here because floating point values use different decimal points for different locales.
|
||||
// Allow strings to differ in "." vs. "," only. This should still catch most errors.
|
||||
for (size_t i = 0; i < expected_len; i++) {
|
||||
char e = expected_string[i];
|
||||
char a = actual_string[i];
|
||||
if (e != a) {
|
||||
if ((e == '.' || e == ',') && (a == '.' || a == ',')) {
|
||||
// Most likely just a difference in locale
|
||||
} else {
|
||||
assert(false, "Expected '%s' but got: '%s'", expected_string, actual_string);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void WorkerDataArray_test_verify_array(WorkerDataArray<size_t>& array, size_t expected_sum, double expected_avg, const char* expected_summary, const char* exected_details) {
|
||||
const double epsilon = 0.0001;
|
||||
assert(array.sum() == expected_sum, "Wrong sum, expected: " SIZE_FORMAT " but got: " SIZE_FORMAT, expected_sum, array.sum());
|
||||
assert(fabs(array.average() - expected_avg) < epsilon, "Wrong average, expected: %f but got: %f", expected_avg, array.average());
|
||||
|
||||
ResourceMark rm;
|
||||
stringStream out;
|
||||
array.print_summary_on(&out);
|
||||
WorkerDataArray_test_verify_string(expected_summary, out.as_string());
|
||||
out.reset();
|
||||
array.print_details_on(&out);
|
||||
WorkerDataArray_test_verify_string(exected_details, out.as_string());
|
||||
}
|
||||
|
||||
void WorkerDataArray_test_verify_array(WorkerDataArray<double>& array, double expected_sum, double expected_avg, const char* expected_summary, const char* exected_details) {
|
||||
const double epsilon = 0.0001;
|
||||
assert(fabs(array.sum() - expected_sum) < epsilon, "Wrong sum, expected: %f but got: %f", expected_sum, array.sum());
|
||||
assert(fabs(array.average() - expected_avg) < epsilon, "Wrong average, expected: %f but got: %f", expected_avg, array.average());
|
||||
|
||||
ResourceMark rm;
|
||||
stringStream out;
|
||||
array.print_summary_on(&out);
|
||||
WorkerDataArray_test_verify_string(expected_summary, out.as_string());
|
||||
out.reset();
|
||||
array.print_details_on(&out);
|
||||
WorkerDataArray_test_verify_string(exected_details, out.as_string());
|
||||
}
|
||||
|
||||
void WorkerDataArray_test_basic() {
|
||||
WorkerDataArray<size_t> array(3, "Test array");
|
||||
array.set(0, 5);
|
||||
array.set(1, 3);
|
||||
array.set(2, 7);
|
||||
|
||||
WorkerDataArray_test_verify_array(array, 15, 5.0,
|
||||
"Test array Min: 3, Avg: 5.0, Max: 7, Diff: 4, Sum: 15, Workers: 3\n",
|
||||
" 5 3 7\n" );
|
||||
}
|
||||
|
||||
void WorkerDataArray_test_add() {
|
||||
WorkerDataArray<size_t> array(3, "Test array");
|
||||
array.set(0, 5);
|
||||
array.set(1, 3);
|
||||
array.set(2, 7);
|
||||
|
||||
for (uint i = 0; i < 3; i++) {
|
||||
array.add(i, 1);
|
||||
}
|
||||
|
||||
WorkerDataArray_test_verify_array(array, 18, 6.0,
|
||||
"Test array Min: 4, Avg: 6.0, Max: 8, Diff: 4, Sum: 18, Workers: 3\n",
|
||||
" 6 4 8\n" );
|
||||
}
|
||||
|
||||
void WorkerDataArray_test_with_uninitialized() {
|
||||
WorkerDataArray<size_t> array(3, "Test array");
|
||||
array.set(0, 5);
|
||||
array.set(1, WorkerDataArray<size_t>::uninitialized());
|
||||
array.set(2, 7);
|
||||
|
||||
WorkerDataArray_test_verify_array(array, 12, 6,
|
||||
"Test array Min: 5, Avg: 6.0, Max: 7, Diff: 2, Sum: 12, Workers: 2\n",
|
||||
" 5 - 7\n" );
|
||||
}
|
||||
|
||||
void WorkerDataArray_test_uninitialized() {
|
||||
WorkerDataArray<size_t> array(3, "Test array");
|
||||
array.set(0, WorkerDataArray<size_t>::uninitialized());
|
||||
array.set(1, WorkerDataArray<size_t>::uninitialized());
|
||||
array.set(2, WorkerDataArray<size_t>::uninitialized());
|
||||
|
||||
WorkerDataArray_test_verify_array(array, 0, 0.0,
|
||||
"Test array skipped\n",
|
||||
" - - -\n" );
|
||||
}
|
||||
|
||||
void WorkerDataArray_test_double_with_uninitialized() {
|
||||
WorkerDataArray<double> array(3, "Test array");
|
||||
array.set(0, 5.1 / MILLIUNITS);
|
||||
array.set(1, WorkerDataArray<double>::uninitialized());
|
||||
array.set(2, 7.2 / MILLIUNITS);
|
||||
|
||||
WorkerDataArray_test_verify_array(array, 12.3 / MILLIUNITS, 6.15 / MILLIUNITS,
|
||||
"Test array Min: 5.1, Avg: 6.1, Max: 7.2, Diff: 2.1, Sum: 12.3, Workers: 2\n",
|
||||
" 5.1 - 7.2\n" );
|
||||
}
|
||||
|
||||
void WorkerDataArray_test() {
|
||||
WorkerDataArray_test_basic();
|
||||
WorkerDataArray_test_add();
|
||||
WorkerDataArray_test_with_uninitialized();
|
||||
WorkerDataArray_test_uninitialized();
|
||||
WorkerDataArray_test_double_with_uninitialized();
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -32,16 +32,13 @@ class outputStream;
|
||||
|
||||
template <class T>
|
||||
class WorkerDataArray : public CHeapObj<mtGC> {
|
||||
friend class WDAPrinter;
|
||||
T* _data;
|
||||
uint _length;
|
||||
const char* _title;
|
||||
|
||||
WorkerDataArray<size_t>* _thread_work_items;
|
||||
|
||||
NOT_PRODUCT(inline T uninitialized() const;)
|
||||
|
||||
void set_all(T value);
|
||||
|
||||
public:
|
||||
WorkerDataArray(uint length, const char* title);
|
||||
~WorkerDataArray();
|
||||
@ -52,37 +49,38 @@ class WorkerDataArray : public CHeapObj<mtGC> {
|
||||
return _thread_work_items;
|
||||
}
|
||||
|
||||
static T uninitialized();
|
||||
|
||||
void set(uint worker_i, T value);
|
||||
T get(uint worker_i) const;
|
||||
|
||||
void add(uint worker_i, T value);
|
||||
|
||||
double average(uint active_threads) const;
|
||||
T sum(uint active_threads) const;
|
||||
// The sum() and average() methods below consider uninitialized slots to be 0.
|
||||
double average() const;
|
||||
T sum() const;
|
||||
|
||||
const char* title() const {
|
||||
return _title;
|
||||
}
|
||||
|
||||
void clear();
|
||||
|
||||
void reset() PRODUCT_RETURN;
|
||||
void verify(uint active_threads) const PRODUCT_RETURN;
|
||||
void reset();
|
||||
void set_all(T value);
|
||||
|
||||
|
||||
private:
|
||||
class WDAPrinter {
|
||||
public:
|
||||
static void summary(outputStream* out, const char* title, double min, double avg, double max, double diff, double sum, bool print_sum);
|
||||
static void summary(outputStream* out, const char* title, size_t min, double avg, size_t max, size_t diff, size_t sum, bool print_sum);
|
||||
static void summary(outputStream* out, double min, double avg, double max, double diff, double sum, bool print_sum);
|
||||
static void summary(outputStream* out, size_t min, double avg, size_t max, size_t diff, size_t sum, bool print_sum);
|
||||
|
||||
static void details(const WorkerDataArray<double>* phase, outputStream* out, uint active_threads);
|
||||
static void details(const WorkerDataArray<size_t>* phase, outputStream* out, uint active_threads);
|
||||
static void details(const WorkerDataArray<double>* phase, outputStream* out);
|
||||
static void details(const WorkerDataArray<size_t>* phase, outputStream* out);
|
||||
};
|
||||
|
||||
public:
|
||||
void print_summary_on(outputStream* out, uint active_threads, bool print_sum = true) const;
|
||||
void print_details_on(outputStream* out, uint active_threads) const;
|
||||
void print_summary_on(outputStream* out, bool print_sum = true) const;
|
||||
void print_details_on(outputStream* out) const;
|
||||
};
|
||||
|
||||
#endif // SHARE_VM_GC_G1_WORKERDATAARRAY_HPP
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -50,7 +50,6 @@ void WorkerDataArray<T>::set(uint worker_i, T value) {
|
||||
template <typename T>
|
||||
T WorkerDataArray<T>::get(uint worker_i) const {
|
||||
assert(worker_i < _length, "Worker %d is greater than max: %d", worker_i, _length);
|
||||
assert(_data[worker_i] != uninitialized(), "No data added for worker %d", worker_i);
|
||||
return _data[worker_i];
|
||||
}
|
||||
|
||||
@ -78,24 +77,30 @@ void WorkerDataArray<T>::add(uint worker_i, T value) {
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
double WorkerDataArray<T>::average(uint active_threads) const {
|
||||
return sum(active_threads) / (double) active_threads;
|
||||
double WorkerDataArray<T>::average() const {
|
||||
uint contributing_threads = 0;
|
||||
for (uint i = 0; i < _length; ++i) {
|
||||
if (get(i) != uninitialized()) {
|
||||
contributing_threads++;
|
||||
}
|
||||
}
|
||||
if (contributing_threads == 0) {
|
||||
return 0.0;
|
||||
}
|
||||
return sum() / (double) contributing_threads;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
T WorkerDataArray<T>::sum(uint active_threads) const {
|
||||
T s = get(0);
|
||||
for (uint i = 1; i < active_threads; ++i) {
|
||||
s += get(i);
|
||||
T WorkerDataArray<T>::sum() const {
|
||||
T s = 0;
|
||||
for (uint i = 0; i < _length; ++i) {
|
||||
if (get(i) != uninitialized()) {
|
||||
s += get(i);
|
||||
}
|
||||
}
|
||||
return s;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void WorkerDataArray<T>::clear() {
|
||||
set_all(0);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void WorkerDataArray<T>::set_all(T value) {
|
||||
for (uint i = 0; i < _length; i++) {
|
||||
@ -104,27 +109,42 @@ void WorkerDataArray<T>::set_all(T value) {
|
||||
}
|
||||
|
||||
template <class T>
|
||||
void WorkerDataArray<T>::print_summary_on(outputStream* out, uint active_threads, bool print_sum) const {
|
||||
T max = get(0);
|
||||
T min = max;
|
||||
T sum = 0;
|
||||
for (uint i = 1; i < active_threads; ++i) {
|
||||
T value = get(i);
|
||||
max = MAX2(max, value);
|
||||
min = MIN2(min, value);
|
||||
sum += value;
|
||||
void WorkerDataArray<T>::print_summary_on(outputStream* out, bool print_sum) const {
|
||||
out->print("%-25s", title());
|
||||
uint start = 0;
|
||||
while (start < _length && get(start) == uninitialized()) {
|
||||
start++;
|
||||
}
|
||||
if (start < _length) {
|
||||
T min = get(start);
|
||||
T max = min;
|
||||
T sum = 0;
|
||||
uint contributing_threads = 0;
|
||||
for (uint i = start; i < _length; ++i) {
|
||||
T value = get(i);
|
||||
if (value != uninitialized()) {
|
||||
max = MAX2(max, value);
|
||||
min = MIN2(min, value);
|
||||
sum += value;
|
||||
contributing_threads++;
|
||||
}
|
||||
}
|
||||
T diff = max - min;
|
||||
assert(contributing_threads != 0, "Must be since we found a used value for the start index");
|
||||
double avg = sum / (double) contributing_threads;
|
||||
WDAPrinter::summary(out, min, avg, max, diff, sum, print_sum);
|
||||
out->print_cr(", Workers: %d", contributing_threads);
|
||||
} else {
|
||||
// No data for this phase.
|
||||
out->print_cr(" skipped");
|
||||
}
|
||||
T diff = max - min;
|
||||
double avg = sum / (double) active_threads;
|
||||
WDAPrinter::summary(out, title(), min, avg, max, diff, sum, print_sum);
|
||||
}
|
||||
|
||||
template <class T>
|
||||
void WorkerDataArray<T>::print_details_on(outputStream* out, uint active_threads) const {
|
||||
WDAPrinter::details(this, out, active_threads);
|
||||
void WorkerDataArray<T>::print_details_on(outputStream* out) const {
|
||||
WDAPrinter::details(this, out);
|
||||
}
|
||||
|
||||
#ifndef PRODUCT
|
||||
template <typename T>
|
||||
void WorkerDataArray<T>::reset() {
|
||||
set_all(uninitialized());
|
||||
@ -133,27 +153,4 @@ void WorkerDataArray<T>::reset() {
|
||||
}
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void WorkerDataArray<T>::verify(uint active_threads) const {
|
||||
assert(active_threads <= _length, "Wrong number of active threads");
|
||||
for (uint i = 0; i < active_threads; i++) {
|
||||
assert(_data[i] != uninitialized(),
|
||||
"Invalid data for worker %u in '%s'", i, _title);
|
||||
}
|
||||
if (_thread_work_items != NULL) {
|
||||
_thread_work_items->verify(active_threads);
|
||||
}
|
||||
}
|
||||
|
||||
template <>
|
||||
inline size_t WorkerDataArray<size_t>::uninitialized() const {
|
||||
return (size_t)-1;
|
||||
}
|
||||
|
||||
template <>
|
||||
inline double WorkerDataArray<double>::uninitialized() const {
|
||||
return -1.0;
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // SHARE_VM_GC_G1_WORKERDATAARRAY_INLINE_HPP
|
||||
|
||||
@ -235,7 +235,7 @@ class SvcGCMarker : public StackObj {
|
||||
private:
|
||||
JvmtiGCMarker _jgcm;
|
||||
public:
|
||||
typedef enum { MINOR, FULL, OTHER } reason_type;
|
||||
typedef enum { MINOR, FULL, CONCURRENT, OTHER } reason_type;
|
||||
|
||||
SvcGCMarker(reason_type reason ) {
|
||||
VM_GC_Operation::notify_gc_begin(reason == FULL);
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2002, 2015, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2002, 2016, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
@ -152,7 +152,7 @@ class AbstractWorkGang : public CHeapObj<mtInternal> {
|
||||
_active_workers = MAX2(1U, _active_workers);
|
||||
assert(UseDynamicNumberOfGCThreads || _active_workers == _total_workers,
|
||||
"Unless dynamic should use total workers");
|
||||
log_info(gc, task)("GC Workers: %d", _active_workers);
|
||||
log_info(gc, task)("GC Workers: using %d out of %d", _active_workers, _total_workers);
|
||||
}
|
||||
|
||||
// Return the Ith worker.
|
||||
|
||||
@ -34,6 +34,7 @@
|
||||
#define LOG_TAG_LIST \
|
||||
LOG_TAG(alloc) \
|
||||
LOG_TAG(age) \
|
||||
LOG_TAG(arguments) \
|
||||
LOG_TAG(barrier) \
|
||||
LOG_TAG(biasedlocking) \
|
||||
LOG_TAG(bot) \
|
||||
|
||||
@ -994,10 +994,35 @@ const char* Arguments::handle_aliases_and_deprecation(const char* arg, bool warn
|
||||
return NULL;
|
||||
}
|
||||
|
||||
AliasedLoggingFlag Arguments::catch_logging_aliases(const char* name){
|
||||
void log_deprecated_flag(const char* name, bool on, AliasedLoggingFlag alf) {
|
||||
LogTagType tagSet[] = {alf.tag0, alf.tag1, alf.tag2, alf.tag3, alf.tag4, alf.tag5};
|
||||
// Set tagset string buffer at max size of 256, large enough for any alias tagset
|
||||
const int max_tagset_size = 256;
|
||||
int max_tagset_len = max_tagset_size - 1;
|
||||
char tagset_buffer[max_tagset_size];
|
||||
tagset_buffer[0] = '\0';
|
||||
|
||||
// Write tag-set for aliased logging option, in string list form
|
||||
int max_tags = sizeof(tagSet)/sizeof(tagSet[0]);
|
||||
for (int i = 0; i < max_tags && tagSet[i] != LogTag::__NO_TAG; i++) {
|
||||
if (i > 0) {
|
||||
strncat(tagset_buffer, ",", max_tagset_len - strlen(tagset_buffer));
|
||||
}
|
||||
strncat(tagset_buffer, LogTag::name(tagSet[i]), max_tagset_len - strlen(tagset_buffer));
|
||||
}
|
||||
|
||||
log_warning(arguments)("-XX:%s%s is deprecated. Will use -Xlog:%s=%s instead.",
|
||||
(on) ? "+" : "-",
|
||||
name,
|
||||
tagset_buffer,
|
||||
(on) ? LogLevel::name(alf.level) : "off");
|
||||
}
|
||||
|
||||
AliasedLoggingFlag Arguments::catch_logging_aliases(const char* name, bool on){
|
||||
for (size_t i = 0; aliased_logging_flags[i].alias_name != NULL; i++) {
|
||||
const AliasedLoggingFlag& alf = aliased_logging_flags[i];
|
||||
if (strcmp(alf.alias_name, name) == 0) {
|
||||
log_deprecated_flag(name, on, alf);
|
||||
return alf;
|
||||
}
|
||||
}
|
||||
@ -1016,7 +1041,7 @@ bool Arguments::parse_argument(const char* arg, Flag::Flags origin) {
|
||||
bool warn_if_deprecated = true;
|
||||
|
||||
if (sscanf(arg, "-%" XSTR(BUFLEN) NAME_RANGE "%c", name, &dummy) == 1) {
|
||||
AliasedLoggingFlag alf = catch_logging_aliases(name);
|
||||
AliasedLoggingFlag alf = catch_logging_aliases(name, false);
|
||||
if (alf.alias_name != NULL){
|
||||
LogConfiguration::configure_stdout(LogLevel::Off, alf.exactMatch, alf.tag0, alf.tag1, alf.tag2, alf.tag3, alf.tag4, alf.tag5);
|
||||
return true;
|
||||
@ -1028,7 +1053,7 @@ bool Arguments::parse_argument(const char* arg, Flag::Flags origin) {
|
||||
return set_bool_flag(real_name, false, origin);
|
||||
}
|
||||
if (sscanf(arg, "+%" XSTR(BUFLEN) NAME_RANGE "%c", name, &dummy) == 1) {
|
||||
AliasedLoggingFlag alf = catch_logging_aliases(name);
|
||||
AliasedLoggingFlag alf = catch_logging_aliases(name, true);
|
||||
if (alf.alias_name != NULL){
|
||||
LogConfiguration::configure_stdout(alf.level, alf.exactMatch, alf.tag0, alf.tag1, alf.tag2, alf.tag3, alf.tag4, alf.tag5);
|
||||
return true;
|
||||
@ -1244,8 +1269,9 @@ bool Arguments::process_argument(const char* arg,
|
||||
else {
|
||||
const char* replacement;
|
||||
if ((replacement = removed_develop_logging_flag_name(stripped_argname)) != NULL){
|
||||
jio_fprintf(defaultStream::error_stream(),
|
||||
"%s has been removed. Please use %s instead.\n", stripped_argname, replacement);
|
||||
log_warning(arguments)("%s has been removed. Please use %s instead.",
|
||||
stripped_argname,
|
||||
replacement);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@ -526,7 +526,7 @@ class Arguments : AllStatic {
|
||||
// Return NULL if the arg has expired.
|
||||
static const char* handle_aliases_and_deprecation(const char* arg, bool warn);
|
||||
static bool lookup_logging_aliases(const char* arg, char* buffer);
|
||||
static AliasedLoggingFlag catch_logging_aliases(const char* name);
|
||||
static AliasedLoggingFlag catch_logging_aliases(const char* name, bool on);
|
||||
static short CompileOnlyClassesNum;
|
||||
static short CompileOnlyClassesMax;
|
||||
static char** CompileOnlyClasses;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user