mirror of
https://github.com/openjdk/jdk.git
synced 2026-02-14 04:15:04 +00:00
8221153: ZGC: Heap iteration and verification pollutes GC statistics
Reviewed-by: stefank, eosterlund
This commit is contained in:
parent
7a623e6e46
commit
793c71bf92
@ -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);
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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
|
||||
//
|
||||
|
||||
@ -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);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user