Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

8348829: Remove ObjectMonitor perf counters #23326

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 0 additions & 10 deletions src/hotspot/share/runtime/lightweightSynchronizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@
#include "runtime/mutexLocker.hpp"
#include "runtime/objectMonitor.inline.hpp"
#include "runtime/os.hpp"
#include "runtime/perfData.inline.hpp"
#include "runtime/safepointMechanism.inline.hpp"
#include "runtime/safepointVerifiers.hpp"
#include "runtime/synchronizer.inline.hpp"
Expand Down Expand Up @@ -384,9 +383,6 @@ ObjectMonitor* LightweightSynchronizer::get_or_insert_monitor(oop object, JavaTh
ObjectMonitor* monitor = get_or_insert_monitor_from_table(object, current, &inserted);

if (inserted) {
// Hopefully the performance counters are allocated on distinct
// cache lines to avoid false sharing on MP systems ...
OM_PERFDATA_OP(Inflations, inc());
log_inflate(current, object, cause);
if (event.should_commit()) {
post_monitor_inflate_event(&event, object, cause);
Expand Down Expand Up @@ -874,9 +870,6 @@ ObjectMonitor* LightweightSynchronizer::inflate_into_object_header(oop object, O
// with the ObjectMonitor, it is safe to allow async deflation:
ObjectSynchronizer::_in_use_list.add(monitor);

// Hopefully the performance counters are allocated on distinct
// cache lines to avoid false sharing on MP systems ...
OM_PERFDATA_OP(Inflations, inc());
log_inflate(current, object, cause);
if (event.should_commit()) {
post_monitor_inflate_event(&event, object, cause);
Expand Down Expand Up @@ -915,9 +908,6 @@ ObjectMonitor* LightweightSynchronizer::inflate_into_object_header(oop object, O
// with the ObjectMonitor, it is safe to allow async deflation:
ObjectSynchronizer::_in_use_list.add(m);

// Hopefully the performance counters are allocated on distinct
// cache lines to avoid false sharing on MP systems ...
OM_PERFDATA_OP(Inflations, inc());
log_inflate(current, object, cause);
if (event.should_commit()) {
post_monitor_inflate_event(&event, object, cause);
Expand Down
56 changes: 0 additions & 56 deletions src/hotspot/share/runtime/objectMonitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@
#include "runtime/objectMonitor.inline.hpp"
#include "runtime/orderAccess.hpp"
#include "runtime/osThread.hpp"
#include "runtime/perfData.hpp"
#include "runtime/safefetch.hpp"
#include "runtime/safepointMechanism.inline.hpp"
#include "runtime/sharedRuntime.hpp"
Expand Down Expand Up @@ -612,8 +611,6 @@ void ObjectMonitor::enter_with_contention_mark(JavaThread *current, ObjectMonito
current->post_vthread_pinned_event(&vthread_pinned_event, "Contended monitor enter", result);
}
}

OM_PERFDATA_OP(ContendedLockAttempts, inc());
}

// Caveat: TryLock() is not necessarily serializing if it returns failure.
Expand Down Expand Up @@ -941,14 +938,6 @@ void ObjectMonitor::EnterI(JavaThread* current) {

// The lock is still contested.

// Keep a tally of the # of futile wakeups.
// Note that the counter is not protected by a lock or updated by atomics.
// That is by design - we trade "lossy" counters which are exposed to
// races during updates for a lower probe effect.
// We are in safepoint safe state, so shutdown can remove the counter
// under our feet. Make sure we make this access safely.
OM_PERFDATA_SAFE_OP(FutileWakeups, inc());

// Assuming this is not a spurious wakeup we'll normally find _succ == current.
// We can defer clearing _succ until after the spin completes
// TrySpin() must tolerate being called with _succ == current.
Expand Down Expand Up @@ -1069,12 +1058,6 @@ void ObjectMonitor::ReenterI(JavaThread* current, ObjectWaiter* currentNode) {
// Invariant: after clearing _succ a contending thread
// *must* retry _owner before parking.
OrderAccess::fence();

// Keep a tally of the # of futile wakeups.
// Note that the counter is not protected by a lock or updated by atomics.
// That is by design - we trade "lossy" counters which are exposed to
// races during updates for a lower probe effect.
OM_PERFDATA_OP(FutileWakeups, inc());
}

// current has acquired the lock -- Unlink current from the cxq or EntryList .
Expand Down Expand Up @@ -1550,9 +1533,6 @@ void ObjectMonitor::ExitEpilog(JavaThread* current, ObjectWaiter* Wakee) {
// Virtual thread case.
Trigger->unpark();
}

// Maintain stats and report events to JVMTI
OM_PERFDATA_OP(Parks, inc());
}

// Exits the monitor returning recursion count. _owner should
Expand Down Expand Up @@ -1998,7 +1978,6 @@ void ObjectMonitor::notify(TRAPS) {
}
DTRACE_MONITOR_PROBE(notify, this, object(), current);
INotify(current);
OM_PERFDATA_OP(Notifications, inc(1));
}


Expand All @@ -2017,13 +1996,9 @@ void ObjectMonitor::notifyAll(TRAPS) {
}

DTRACE_MONITOR_PROBE(notifyAll, this, object(), current);
int tally = 0;
while (_WaitSet != nullptr) {
tally++;
INotify(current);
}

OM_PERFDATA_OP(Notifications, inc(tally));
}

void ObjectMonitor::VThreadWait(JavaThread* current, jlong millis) {
Expand Down Expand Up @@ -2465,14 +2440,6 @@ inline void ObjectMonitor::DequeueSpecificWaiter(ObjectWaiter* node) {
}

// -----------------------------------------------------------------------------
// PerfData support
PerfCounter * ObjectMonitor::_sync_ContendedLockAttempts = nullptr;
PerfCounter * ObjectMonitor::_sync_FutileWakeups = nullptr;
PerfCounter * ObjectMonitor::_sync_Parks = nullptr;
PerfCounter * ObjectMonitor::_sync_Notifications = nullptr;
PerfCounter * ObjectMonitor::_sync_Inflations = nullptr;
PerfCounter * ObjectMonitor::_sync_Deflations = nullptr;
PerfLongVariable * ObjectMonitor::_sync_MonExtant = nullptr;

// One-shot global initialization for the sync subsystem.
// We could also defer initialization and initialize on-demand
Expand All @@ -2489,29 +2456,6 @@ void ObjectMonitor::Initialize() {
Knob_FixedSpin = -1;
}

if (UsePerfData) {
EXCEPTION_MARK;
#define NEWPERFCOUNTER(n) \
{ \
n = PerfDataManager::create_counter(SUN_RT, #n, PerfData::U_Events, \
CHECK); \
}
#define NEWPERFVARIABLE(n) \
{ \
n = PerfDataManager::create_variable(SUN_RT, #n, PerfData::U_Events, \
CHECK); \
}
NEWPERFCOUNTER(_sync_Inflations);
NEWPERFCOUNTER(_sync_Deflations);
NEWPERFCOUNTER(_sync_ContendedLockAttempts);
NEWPERFCOUNTER(_sync_FutileWakeups);
NEWPERFCOUNTER(_sync_Parks);
NEWPERFCOUNTER(_sync_Notifications);
NEWPERFVARIABLE(_sync_MonExtant);
#undef NEWPERFCOUNTER
#undef NEWPERFVARIABLE
}

_oop_storage = OopStorageSet::create_weak("ObjectSynchronizer Weak", mtSynchronizer);

DEBUG_ONLY(InitDone = true;)
Expand Down
39 changes: 0 additions & 39 deletions src/hotspot/share/runtime/objectMonitor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
#include "oops/oopHandle.hpp"
#include "oops/weakHandle.hpp"
#include "runtime/javaThread.hpp"
#include "runtime/perfDataTypes.hpp"
#include "utilities/checkedCast.hpp"

class ObjectMonitor;
Expand Down Expand Up @@ -202,44 +201,6 @@ class ObjectMonitor : public CHeapObj<mtObjectMonitor> {
static OopHandle& vthread_cxq_head() { return _vthread_cxq_head; }
static ParkEvent* vthread_unparker_ParkEvent() { return _vthread_unparker_ParkEvent; }

// Only perform a PerfData operation if the PerfData object has been
// allocated and if the PerfDataManager has not freed the PerfData
// objects which can happen at normal VM shutdown. This operation is
// only safe when thread is not in safepoint-safe code, i.e. PerfDataManager
// could not reach the safepoint and free the counter while we are using it.
// If this is not guaranteed, use OM_PERFDATA_SAFE_OP instead.
#define OM_PERFDATA_OP(f, op_str) \
do { \
if (ObjectMonitor::_sync_ ## f != nullptr) { \
if (PerfDataManager::has_PerfData()) { \
ObjectMonitor::_sync_ ## f->op_str; \
} \
} \
} while (0)

// Only perform a PerfData operation if the PerfData object has been
// allocated and if the PerfDataManager has not freed the PerfData
// objects which can happen at normal VM shutdown. Additionally, we
// enter the critical section to resolve the race against PerfDataManager
// entering the safepoint and deleting the counter during shutdown.
#define OM_PERFDATA_SAFE_OP(f, op_str) \
do { \
if (ObjectMonitor::_sync_ ## f != nullptr) { \
GlobalCounter::CriticalSection cs(Thread::current()); \
if (PerfDataManager::has_PerfData()) { \
ObjectMonitor::_sync_ ## f->op_str; \
} \
} \
} while (0)

static PerfCounter * _sync_ContendedLockAttempts;
static PerfCounter * _sync_FutileWakeups;
static PerfCounter * _sync_Parks;
static PerfCounter * _sync_Notifications;
static PerfCounter * _sync_Inflations;
static PerfCounter * _sync_Deflations;
static PerfLongVariable * _sync_MonExtant;

static int Knob_SpinLimit;

static ByteSize metadata_offset() { return byte_offset_of(ObjectMonitor, _metadata); }
Expand Down
13 changes: 0 additions & 13 deletions src/hotspot/share/runtime/synchronizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@
#include "runtime/objectMonitor.inline.hpp"
#include "runtime/os.inline.hpp"
#include "runtime/osThread.hpp"
#include "runtime/perfData.hpp"
#include "runtime/safepointMechanism.inline.hpp"
#include "runtime/safepointVerifiers.hpp"
#include "runtime/sharedRuntime.hpp"
Expand Down Expand Up @@ -372,12 +371,9 @@ bool ObjectSynchronizer::quick_notify(oopDesc* obj, JavaThread* current, bool al
} else {
DTRACE_MONITOR_PROBE(notify, mon, obj, current);
}
int free_count = 0;
do {
mon->INotify(current);
++free_count;
} while (mon->first_waiter() != nullptr && all);
OM_PERFDATA_OP(Notifications, inc(free_count));
}
return true;
}
Expand Down Expand Up @@ -1583,9 +1579,6 @@ ObjectMonitor* ObjectSynchronizer::inflate_impl(JavaThread* locking_thread, oop
// with the ObjectMonitor, it is safe to allow async deflation:
_in_use_list.add(m);

// Hopefully the performance counters are allocated on distinct cache lines
// to avoid false sharing on MP systems ...
OM_PERFDATA_OP(Inflations, inc());
if (log_is_enabled(Trace, monitorinflation)) {
ResourceMark rm;
lsh.print_cr("inflate(has_locker): object=" INTPTR_FORMAT ", mark="
Expand Down Expand Up @@ -1625,9 +1618,6 @@ ObjectMonitor* ObjectSynchronizer::inflate_impl(JavaThread* locking_thread, oop
// with the ObjectMonitor, it is safe to allow async deflation:
_in_use_list.add(m);

// Hopefully the performance counters are allocated on distinct
// cache lines to avoid false sharing on MP systems ...
OM_PERFDATA_OP(Inflations, inc());
if (log_is_enabled(Trace, monitorinflation)) {
ResourceMark rm;
lsh.print_cr("inflate(unlocked): object=" INTPTR_FORMAT ", mark="
Expand Down Expand Up @@ -1855,9 +1845,6 @@ size_t ObjectSynchronizer::deflate_idle_monitors() {

log.end(deflated_count, unlinked_count);

OM_PERFDATA_OP(MonExtant, set_value(_in_use_list.count()));
OM_PERFDATA_OP(Deflations, inc(deflated_count));

GVars.stw_random = os::random();

if (deflated_count != 0) {
Expand Down