--- old/src/hotspot/share/gc/g1/g1GCPhaseTimes.cpp 2018-04-16 13:05:16.465438734 +0200 +++ new/src/hotspot/share/gc/g1/g1GCPhaseTimes.cpp 2018-04-16 13:05:16.200430608 +0200 @@ -483,7 +483,7 @@ } G1EvacPhaseWithTrimTimeTracker::~G1EvacPhaseWithTrimTimeTracker() { - _total_time += (Ticks::now() - _start) + _pss->trim_ticks(); + _total_time += (Ticks::now() - _start) - _pss->trim_ticks(); _trim_time += _pss->trim_ticks(); _pss->reset_trim_ticks(); } @@ -491,13 +491,13 @@ G1GCParPhaseTimesTracker::G1GCParPhaseTimesTracker(G1GCPhaseTimes* phase_times, G1GCPhaseTimes::GCParPhases phase, uint worker_id) : _phase_times(phase_times), _phase(phase), _worker_id(worker_id) { if (_phase_times != NULL) { - _start_time = os::elapsedTime(); + _start_time = Ticks::now(); } } G1GCParPhaseTimesTracker::~G1GCParPhaseTimesTracker() { if (_phase_times != NULL) { - _phase_times->record_time_secs(_phase, _worker_id, os::elapsedTime() - _start_time); + _phase_times->record_time_secs(_phase, _worker_id, TicksToTimeHelper::seconds(Ticks::now() - _start_time)); } } @@ -513,7 +513,8 @@ G1EvacPhaseTimesTracker::~G1EvacPhaseTimesTracker() { if (_phase_times != NULL) { - _start_time += TicksToTimeHelper::seconds(_trim_time); + // Exclude trim time by increasing the start time. + _start_time += _trim_time; _phase_times->record_or_add_objcopy_time_secs(_worker_id, TicksToTimeHelper::seconds(_trim_time)); } } --- old/src/hotspot/share/gc/g1/g1GCPhaseTimes.hpp 2018-04-16 13:05:17.578472865 +0200 +++ new/src/hotspot/share/gc/g1/g1GCPhaseTimes.hpp 2018-04-16 13:05:17.314464769 +0200 @@ -379,7 +379,7 @@ class G1GCParPhaseTimesTracker : public CHeapObj { protected: - double _start_time; + Ticks _start_time; G1GCPhaseTimes::GCParPhases _phase; G1GCPhaseTimes* _phase_times; uint _worker_id; --- old/src/hotspot/share/gc/g1/g1ParScanThreadState.cpp 2018-04-16 13:05:18.799510308 +0200 +++ new/src/hotspot/share/gc/g1/g1ParScanThreadState.cpp 2018-04-16 13:05:18.475500372 +0200 @@ -49,8 +49,8 @@ _scanner(g1h, this), _hash_seed(17), _worker_id(worker_id), - _stack_drain_upper_threshold(GCDrainStackTargetSize * 2 + 1), - _stack_drain_lower_threshold(GCDrainStackTargetSize), + _stack_trim_upper_threshold(GCDrainStackTargetSize * 2 + 1), + _stack_trim_lower_threshold(GCDrainStackTargetSize), _trim_ticks(), _old_gen_is_full(false) { --- old/src/hotspot/share/gc/g1/g1ParScanThreadState.hpp 2018-04-16 13:05:19.977546432 +0200 +++ new/src/hotspot/share/gc/g1/g1ParScanThreadState.hpp 2018-04-16 13:05:19.685537477 +0200 @@ -61,8 +61,8 @@ uint _worker_id; // Upper and lower threshold to start and end work queue draining. - uint const _stack_drain_upper_threshold; - uint const _stack_drain_lower_threshold; + uint const _stack_trim_upper_threshold; + uint const _stack_trim_lower_threshold; Tickspan _trim_ticks; // Map from young-age-index (0 == not young, 1 is youngest) to --- old/src/hotspot/share/gc/g1/g1ParScanThreadState.inline.hpp 2018-04-16 13:05:21.111581207 +0200 +++ new/src/hotspot/share/gc/g1/g1ParScanThreadState.inline.hpp 2018-04-16 13:05:20.827572498 +0200 @@ -153,11 +153,11 @@ } inline bool G1ParScanThreadState::needs_partial_trimming() const { - return !_refs->overflow_empty() || _refs->size() > _stack_drain_upper_threshold; + return !_refs->overflow_empty() || _refs->size() > _stack_trim_upper_threshold; } inline bool G1ParScanThreadState::is_partially_trimmed() const { - return _refs->overflow_empty() && _refs->size() <= _stack_drain_lower_threshold; + return _refs->overflow_empty() && _refs->size() <= _stack_trim_lower_threshold; } inline void G1ParScanThreadState::trim_queue_to_threshold(uint threshold) { @@ -181,7 +181,7 @@ const Ticks start = Ticks::now(); do { - trim_queue_to_threshold(_stack_drain_lower_threshold); + trim_queue_to_threshold(_stack_trim_lower_threshold); } while (!is_partially_trimmed()); _trim_ticks += Ticks::now() - start; } --- old/src/hotspot/share/utilities/ticks.hpp 2018-04-16 13:05:22.230615521 +0200 +++ new/src/hotspot/share/utilities/ticks.hpp 2018-04-16 13:05:21.963607334 +0200 @@ -47,6 +47,11 @@ return *this; } + Tickspan& operator-=(const Tickspan& rhs) { + _span_ticks -= rhs._span_ticks; + return *this; + } + jlong value() const { return _span_ticks; } --- old/src/hotspot/share/utilities/ticks.inline.hpp 2018-04-16 13:05:23.344649683 +0200 +++ new/src/hotspot/share/utilities/ticks.inline.hpp 2018-04-16 13:05:23.079641557 +0200 @@ -33,7 +33,7 @@ } inline Tickspan operator-(Tickspan lhs, Tickspan rhs) { - lhs += rhs; + lhs -= rhs; return lhs; }