Skip to content

Commit 07da3a1

Browse files
committedSep 14, 2020
8253030: ZGC: Change ZMarkCompleteTimeout unit to microseconds
Reviewed-by: kbarrett, stefank, eosterlund
1 parent f978f6f commit 07da3a1

File tree

4 files changed

+18
-12
lines changed

4 files changed

+18
-12
lines changed
 

‎src/hotspot/share/gc/z/zGlobals.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,6 @@ const size_t ZMarkProactiveFlushMax = 10;
149149
const size_t ZMarkTerminateFlushMax = 3;
150150

151151
// Try complete mark timeout
152-
const uint64_t ZMarkCompleteTimeout = 1; // ms
152+
const uint64_t ZMarkCompleteTimeout = 1000; // us
153153

154154
#endif // SHARE_GC_Z_ZGLOBALS_HPP

‎src/hotspot/share/gc/z/zMark.cpp

+11-11
Original file line numberDiff line numberDiff line change
@@ -563,9 +563,9 @@ class ZMarkTimeout : public StackObj {
563563
bool _expired;
564564

565565
public:
566-
ZMarkTimeout(uint64_t timeout_in_millis) :
566+
ZMarkTimeout(uint64_t timeout_in_micros) :
567567
_start(Ticks::now()),
568-
_timeout(_start.value() + TimeHelper::millis_to_counter(timeout_in_millis)),
568+
_timeout(_start.value() + TimeHelper::micros_to_counter(timeout_in_micros)),
569569
_check_interval(200),
570570
_check_at(_check_interval),
571571
_check_count(0),
@@ -591,9 +591,9 @@ class ZMarkTimeout : public StackObj {
591591
}
592592
};
593593

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

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

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

619-
if (timeout_in_millis == 0) {
619+
if (timeout_in_micros == 0) {
620620
work_without_timeout(&cache, stripe, stacks);
621621
} else {
622-
work_with_timeout(&cache, stripe, stacks, timeout_in_millis);
622+
work_with_timeout(&cache, stripe, stacks, timeout_in_micros);
623623
}
624624

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

673673
public:
674-
ZMarkTask(ZMark* mark, uint64_t timeout_in_millis = 0) :
674+
ZMarkTask(ZMark* mark, uint64_t timeout_in_micros = 0) :
675675
ZTask("ZMarkTask"),
676676
_mark(mark),
677-
_timeout_in_millis(timeout_in_millis) {
677+
_timeout_in_micros(timeout_in_micros) {
678678
_mark->prepare_work();
679679
}
680680

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

685685
virtual void work() {
686-
_mark->work(_timeout_in_millis);
686+
_mark->work(_timeout_in_micros);
687687
}
688688
};
689689

‎src/hotspot/share/runtime/timer.cpp

+5
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,11 @@ jlong TimeHelper::millis_to_counter(jlong millis) {
4242
return millis * freq;
4343
}
4444

45+
jlong TimeHelper::micros_to_counter(jlong micros) {
46+
jlong freq = os::elapsed_frequency() / MICROUNITS;
47+
return micros * freq;
48+
}
49+
4550
elapsedTimer::elapsedTimer(jlong time, jlong timeUnitsPerSecond) {
4651
_active = false;
4752
jlong osTimeUnitsPerSecond = os::elapsed_frequency();

‎src/hotspot/share/runtime/timer.hpp

+1
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ class TimeHelper {
7777
static double counter_to_seconds(jlong counter);
7878
static double counter_to_millis(jlong counter);
7979
static jlong millis_to_counter(jlong millis);
80+
static jlong micros_to_counter(jlong micros);
8081
};
8182

8283
#endif // SHARE_RUNTIME_TIMER_HPP

0 commit comments

Comments
 (0)
Please sign in to comment.