Skip to content
Permalink
Browse files
8253030: ZGC: Change ZMarkCompleteTimeout unit to microseconds
Reviewed-by: kbarrett, stefank, eosterlund
  • Loading branch information
pliden committed Sep 14, 2020
1 parent f978f6f commit 07da3a18083cd84bfdb1c0d68476d72482755125
Showing with 18 additions and 12 deletions.
  1. +1 −1 src/hotspot/share/gc/z/zGlobals.hpp
  2. +11 −11 src/hotspot/share/gc/z/zMark.cpp
  3. +5 −0 src/hotspot/share/runtime/timer.cpp
  4. +1 −0 src/hotspot/share/runtime/timer.hpp
@@ -149,6 +149,6 @@ const size_t ZMarkProactiveFlushMax = 10;
const size_t ZMarkTerminateFlushMax = 3;

// Try complete mark timeout
const uint64_t ZMarkCompleteTimeout = 1; // ms
const uint64_t ZMarkCompleteTimeout = 1000; // us

#endif // SHARE_GC_Z_ZGLOBALS_HPP
@@ -563,9 +563,9 @@ class ZMarkTimeout : public StackObj {
bool _expired;

public:
ZMarkTimeout(uint64_t timeout_in_millis) :
ZMarkTimeout(uint64_t timeout_in_micros) :
_start(Ticks::now()),
_timeout(_start.value() + TimeHelper::millis_to_counter(timeout_in_millis)),
_timeout(_start.value() + TimeHelper::micros_to_counter(timeout_in_micros)),
_check_interval(200),
_check_at(_check_interval),
_check_count(0),
@@ -591,9 +591,9 @@ class ZMarkTimeout : public StackObj {
}
};

void ZMark::work_with_timeout(ZMarkCache* cache, ZMarkStripe* stripe, ZMarkThreadLocalStacks* stacks, uint64_t timeout_in_millis) {
void ZMark::work_with_timeout(ZMarkCache* cache, ZMarkStripe* stripe, ZMarkThreadLocalStacks* stacks, uint64_t timeout_in_micros) {
ZStatTimer timer(ZSubPhaseMarkTryComplete);
ZMarkTimeout timeout(timeout_in_millis);
ZMarkTimeout timeout(timeout_in_micros);

for (;;) {
if (!drain_and_flush(stripe, stacks, cache, &timeout)) {
@@ -611,15 +611,15 @@ void ZMark::work_with_timeout(ZMarkCache* cache, ZMarkStripe* stripe, ZMarkThrea
}
}

void ZMark::work(uint64_t timeout_in_millis) {
void ZMark::work(uint64_t timeout_in_micros) {
ZMarkCache cache(_stripes.nstripes());
ZMarkStripe* const stripe = _stripes.stripe_for_worker(_nworkers, ZThread::worker_id());
ZMarkThreadLocalStacks* const stacks = ZThreadLocalData::stacks(Thread::current());

if (timeout_in_millis == 0) {
if (timeout_in_micros == 0) {
work_without_timeout(&cache, stripe, stacks);
} else {
work_with_timeout(&cache, stripe, stacks, timeout_in_millis);
work_with_timeout(&cache, stripe, stacks, timeout_in_micros);
}

// Make sure stacks have been flushed
@@ -668,13 +668,13 @@ class ZMarkConcurrentRootsTask : public ZTask {
class ZMarkTask : public ZTask {
private:
ZMark* const _mark;
const uint64_t _timeout_in_millis;
const uint64_t _timeout_in_micros;

public:
ZMarkTask(ZMark* mark, uint64_t timeout_in_millis = 0) :
ZMarkTask(ZMark* mark, uint64_t timeout_in_micros = 0) :
ZTask("ZMarkTask"),
_mark(mark),
_timeout_in_millis(timeout_in_millis) {
_timeout_in_micros(timeout_in_micros) {
_mark->prepare_work();
}

@@ -683,7 +683,7 @@ class ZMarkTask : public ZTask {
}

virtual void work() {
_mark->work(_timeout_in_millis);
_mark->work(_timeout_in_micros);
}
};

@@ -42,6 +42,11 @@ jlong TimeHelper::millis_to_counter(jlong millis) {
return millis * freq;
}

jlong TimeHelper::micros_to_counter(jlong micros) {
jlong freq = os::elapsed_frequency() / MICROUNITS;
return micros * freq;
}

elapsedTimer::elapsedTimer(jlong time, jlong timeUnitsPerSecond) {
_active = false;
jlong osTimeUnitsPerSecond = os::elapsed_frequency();
@@ -77,6 +77,7 @@ class TimeHelper {
static double counter_to_seconds(jlong counter);
static double counter_to_millis(jlong counter);
static jlong millis_to_counter(jlong millis);
static jlong micros_to_counter(jlong micros);
};

#endif // SHARE_RUNTIME_TIMER_HPP

1 comment on commit 07da3a1

@bridgekeeper

This comment has been minimized.

Copy link

@bridgekeeper bridgekeeper bot commented on 07da3a1 Sep 14, 2020

Please sign in to comment.