8221153: ZGC: Heap iteration and verification pollutes GC statistics

Reviewed-by: stefank, eosterlund
This commit is contained in:
Per Lidén 2019-03-28 19:43:59 +01:00
parent 7a623e6e46
commit 793c71bf92
4 changed files with 37 additions and 3 deletions

View File

@ -540,16 +540,19 @@ void ZHeap::print_extended_on(outputStream* st) const {
class ZVerifyRootsTask : public ZTask {
private:
ZStatTimerDisable _disable;
ZRootsIterator _strong_roots;
ZWeakRootsIterator _weak_roots;
public:
ZVerifyRootsTask() :
ZTask("ZVerifyRootsTask"),
_disable(),
_strong_roots(),
_weak_roots() {}
virtual void work() {
ZStatTimerDisable disable;
ZVerifyOopClosure cl;
_strong_roots.oops_do(&cl);
_weak_roots.oops_do(&cl);

View File

@ -28,6 +28,7 @@
#include "gc/z/zHeapIterator.hpp"
#include "gc/z/zOop.inline.hpp"
#include "gc/z/zRootsIterator.hpp"
#include "gc/z/zStat.hpp"
#include "memory/iterator.inline.hpp"
#include "utilities/bitMap.inline.hpp"
#include "utilities/stack.inline.hpp"
@ -170,6 +171,7 @@ void ZHeapIterator::objects_do(ObjectClosure* cl) {
// If we didn't do this the application would have expected to see
// ObjectFree events for phantom reachable objects in the tag map.
ZStatTimerDisable disable;
ZHeapIteratorRootOopClosure root_cl(this);
// Push strong roots onto stack

View File

@ -748,6 +748,11 @@ void ZStatCriticalPhase::register_end(const Ticks& start, const Ticks& end) cons
}
}
//
// Stat timer
//
__thread uint32_t ZStatTimerDisable::_active = 0;
//
// Stat sample/inc
//

View File

@ -269,21 +269,45 @@ public:
//
// Stat timer
//
class ZStatTimerDisable : public StackObj {
private:
static __thread uint32_t _active;
public:
ZStatTimerDisable() {
_active++;
}
~ZStatTimerDisable() {
_active--;
}
static bool is_active() {
return _active > 0;
}
};
class ZStatTimer : public StackObj {
private:
const bool _enabled;
const ZStatPhase& _phase;
const Ticks _start;
public:
ZStatTimer(const ZStatPhase& phase) :
_enabled(!ZStatTimerDisable::is_active()),
_phase(phase),
_start(Ticks::now()) {
_phase.register_start(_start);
if (_enabled) {
_phase.register_start(_start);
}
}
~ZStatTimer() {
const Ticks end = Ticks::now();
_phase.register_end(_start, end);
if (_enabled) {
const Ticks end = Ticks::now();
_phase.register_end(_start, end);
}
}
};