Skip to content

Commit

Permalink
8244326: Shenandoah: global statistics should not accept bogus samples
Browse files Browse the repository at this point in the history
Reviewed-by: rkennke
  • Loading branch information
shipilev committed May 5, 2020
1 parent 81597d9 commit 00e15ff
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 11 deletions.
43 changes: 32 additions & 11 deletions src/hotspot/share/gc/shenandoah/shenandoahPhaseTimings.cpp
Expand Up @@ -57,7 +57,7 @@ ShenandoahPhaseTimings::ShenandoahPhaseTimings(uint max_workers) :
_worker_data[i] = NULL;
SHENANDOAH_PAR_PHASE_DO(,, SHENANDOAH_WORKER_DATA_NULL)
#undef SHENANDOAH_WORKER_DATA_NULL
_cycle_data[i] = 0;
_cycle_data[i] = uninitialized();
}

// Then punch in the worker-related data.
Expand Down Expand Up @@ -134,7 +134,7 @@ bool ShenandoahPhaseTimings::is_root_work_phase(Phase phase) {
void ShenandoahPhaseTimings::set_cycle_data(Phase phase, double time) {
#ifdef ASSERT
double d = _cycle_data[phase];
assert(d == 0, "Should not be set yet: %s, current value: %lf", phase_name(phase), d);
assert(d == uninitialized(), "Should not be set yet: %s, current value: %lf", phase_name(phase), d);
#endif
_cycle_data[phase] = time;
}
Expand Down Expand Up @@ -175,23 +175,44 @@ void ShenandoahPhaseTimings::flush_par_workers_to_cycle() {
for (uint pi = 0; pi < _num_phases; pi++) {
Phase phase = Phase(pi);
if (is_worker_phase(phase)) {
double s = 0;
double s = uninitialized();
for (uint i = 1; i < _num_par_phases; i++) {
double t = worker_data(phase, ParPhase(i))->sum();
// add to each line in phase
set_cycle_data(Phase(phase + i + 1), t);
s += t;
ShenandoahWorkerData* wd = worker_data(phase, ParPhase(i));
double ws = uninitialized();
for (uint c = 0; c < _max_workers; c++) {
double v = wd->get(c);
if (v != ShenandoahWorkerData::uninitialized()) {
if (ws == uninitialized()) {
ws = v;
} else {
ws += v;
}
}
}
if (ws != uninitialized()) {
// add to each line in phase
set_cycle_data(Phase(phase + i + 1), ws);
if (s == uninitialized()) {
s = ws;
} else {
s += ws;
}
}
}
if (s != uninitialized()) {
// add to total for phase
set_cycle_data(Phase(phase + 1), s);
}
// add to total for phase
set_cycle_data(Phase(phase + 1), s);
}
}
}

void ShenandoahPhaseTimings::flush_cycle_to_global() {
for (uint i = 0; i < _num_phases; i++) {
_global_data[i].add(_cycle_data[i]);
_cycle_data[i] = 0;
if (_cycle_data[i] != uninitialized()) {
_global_data[i].add(_cycle_data[i]);
_cycle_data[i] = uninitialized();
}
if (_worker_data[i] != NULL) {
_worker_data[i]->reset();
}
Expand Down
1 change: 1 addition & 0 deletions src/hotspot/share/gc/shenandoah/shenandoahPhaseTimings.hpp
Expand Up @@ -195,6 +195,7 @@ class ShenandoahPhaseTimings : public CHeapObj<mtGC> {
Phase worker_par_phase(Phase phase, ParPhase par_phase);

void set_cycle_data(Phase phase, double time);
static double uninitialized() { return -1; }

public:
ShenandoahPhaseTimings(uint _max_workers);
Expand Down

0 comments on commit 00e15ff

Please sign in to comment.