Skip to content

Commit 74dc8e8

Browse files

File tree

6 files changed

+66
-20
lines changed

6 files changed

+66
-20
lines changed
 

‎src/hotspot/share/code/codeCache.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -1566,7 +1566,7 @@ void CodeCache::print_memory_overhead() {
15661566
static void print_helper1(outputStream* st, const char* prefix, int total, int not_entrant, int used) {
15671567
if (total > 0) {
15681568
double ratio = (100.0 * used) / total;
1569-
st->print("%s %3d nmethods: %3d not_entrant, %d used (%2.1f%%);", prefix, total, not_entrant, used, ratio);
1569+
st->print("%s %3d nmethods: %3d not_entrant, %d used (%2.1f%%)", prefix, total, not_entrant, used, ratio);
15701570
}
15711571
}
15721572

@@ -1624,7 +1624,7 @@ void CodeCache::print_nmethod_statistics_on(outputStream* st) {
16241624
if (total_normal + total_osr > 0) {
16251625
st->print(" Tier%d:", i);
16261626
print_helper1(st, "", total_normal, stats[0][i][1][0], stats_used[0][i][0][0] + stats_used[0][i][1][0]);
1627-
print_helper1(st, " osr:", total_osr, stats[0][i][1][1], stats_used[0][i][0][1] + stats_used[0][i][1][1]);
1627+
print_helper1(st, "; osr:", total_osr, stats[0][i][1][1], stats_used[0][i][0][1] + stats_used[0][i][1][1]);
16281628
st->cr();
16291629
}
16301630
}
@@ -1636,7 +1636,7 @@ void CodeCache::print_nmethod_statistics_on(outputStream* st) {
16361636
if (total_normal + total_osr > 0) {
16371637
st->print(" SC T%d:", i);
16381638
print_helper1(st, "", total_normal, stats[1][i][1][0], stats_used[1][i][0][0] + stats_used[1][i][1][0]);
1639-
print_helper1(st, " osr:", total_osr, stats[1][i][1][1], stats_used[1][i][0][1] + stats_used[1][i][1][1]);
1639+
print_helper1(st, "; osr:", total_osr, stats[1][i][1][1], stats_used[1][i][0][1] + stats_used[1][i][1][1]);
16401640
st->cr();
16411641
}
16421642
}

‎src/hotspot/share/compiler/compileBroker.cpp

+2
Original file line numberDiff line numberDiff line change
@@ -2063,6 +2063,8 @@ void CompileBroker::free_buffer_blob_if_allocated(CompilerThread* thread) {
20632063
void CompileBroker::shutdown_compiler_runtime(AbstractCompiler* comp, CompilerThread* thread) {
20642064
free_buffer_blob_if_allocated(thread);
20652065

2066+
log_info(compilation)("shutdown_compiler_runtime: " INTPTR_FORMAT, p2i(thread));
2067+
20662068
if (comp->should_perform_shutdown()) {
20672069
// There are two reasons for shutting down the compiler
20682070
// 1) compiler runtime initialization failed

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

+1
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,7 @@ Mutex::Mutex(Rank rank, const char * name, bool allow_vm_block) : _owner(nullptr
275275
assert(os::mutex_init_done(), "Too early!");
276276
assert(name != nullptr, "Mutex requires a name");
277277
_name = os::strdup(name, mtInternal);
278+
_id = MutexLocker::name2id(name);
278279
#ifdef ASSERT
279280
_allow_vm_block = allow_vm_block;
280281
_rank = rank;

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

+3-1
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,9 @@ class Mutex : public CHeapObj<mtSynchronizer> {
195195
const char *name() const { return _name; }
196196

197197
int id() const { return _id; }
198-
void set_id(int id) { _id = id; }
198+
// void set_id(int id) { _id = id; }
199+
200+
static const char* id2name(int id);
199201

200202
void print_on_error(outputStream* st) const;
201203
#ifndef PRODUCT

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

+50-15
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ static void add_mutex(Mutex* var) {
196196
assert(_num_mutex < MAX_NUM_MUTEX, "increase MAX_NUM_MUTEX");
197197
int id = _num_mutex++;
198198
_mutex_array[id] = var;
199-
var->set_id(id);
199+
// var->set_id(id);
200200
}
201201

202202
#define MUTEX_STORAGE_NAME(name) name##_storage
@@ -393,6 +393,11 @@ void mutex_init() {
393393
#undef MUTEX_STORAGE
394394
#undef MUTEX_STORAGE_NAME
395395

396+
static const int MAX_NAMES = 200;
397+
static const char* _names[MAX_NAMES] = { nullptr };
398+
static bool _is_unique[MAX_NAMES] = { false };
399+
static int _num_names = 0;
400+
396401
PerfCounter** MutexLockerImpl::_perf_lock_count = nullptr;
397402
PerfCounter** MutexLockerImpl::_perf_lock_wait_time = nullptr;
398403
PerfCounter** MutexLockerImpl::_perf_lock_hold_time = nullptr;
@@ -401,28 +406,54 @@ void MutexLockerImpl::init_counters() {
401406
if (ProfileVMLocks && UsePerfData) {
402407
ResourceMark rm;
403408
EXCEPTION_MARK;
404-
_perf_lock_count = NEW_C_HEAP_ARRAY(PerfCounter*, _num_mutex + 1, mtInternal);
405-
_perf_lock_wait_time = NEW_C_HEAP_ARRAY(PerfCounter*, _num_mutex + 1, mtInternal);
406-
_perf_lock_hold_time = NEW_C_HEAP_ARRAY(PerfCounter*, _num_mutex + 1, mtInternal);
409+
_perf_lock_count = NEW_C_HEAP_ARRAY(PerfCounter*, MAX_NAMES + 1, mtInternal);
410+
_perf_lock_wait_time = NEW_C_HEAP_ARRAY(PerfCounter*, MAX_NAMES + 1, mtInternal);
411+
_perf_lock_hold_time = NEW_C_HEAP_ARRAY(PerfCounter*, MAX_NAMES + 1, mtInternal);
407412

408413
NEWPERFEVENTCOUNTER(_perf_lock_count[0], SUN_RT, PerfDataManager::counter_name("Other", "Count"));
409414
NEWPERFEVENTCOUNTER(_perf_lock_wait_time[0], SUN_RT, PerfDataManager::counter_name("Other", "BeforeTime"));
410415
NEWPERFEVENTCOUNTER(_perf_lock_hold_time[0], SUN_RT, PerfDataManager::counter_name("Other", "AfterTime"));
411-
for (int i = 0; i < _num_mutex; i++) {
412-
NEWPERFEVENTCOUNTER(_perf_lock_count[i+1], SUN_RT, PerfDataManager::counter_name(_mutex_array[i]->name(), "Count"));
413-
NEWPERFEVENTCOUNTER(_perf_lock_wait_time[i + 1], SUN_RT, PerfDataManager::counter_name(_mutex_array[i]->name(), "BeforeTime"));
414-
NEWPERFEVENTCOUNTER(_perf_lock_hold_time[i + 1], SUN_RT, PerfDataManager::counter_name(_mutex_array[i]->name(), "AfterTime"));
416+
for (int i = 0; i < MAX_NAMES; i++) {
417+
ResourceMark rm;
418+
const char* counter_name = _names[i];
419+
if (counter_name == nullptr) {
420+
stringStream ss;
421+
ss.print("UnnamedMutex#%d", i);
422+
counter_name = ss.as_string();
423+
}
424+
NEWPERFEVENTCOUNTER(_perf_lock_count[i + 1], SUN_RT, PerfDataManager::counter_name(counter_name, "Count"));
425+
NEWPERFEVENTCOUNTER(_perf_lock_wait_time[i + 1], SUN_RT, PerfDataManager::counter_name(counter_name, "BeforeTime"));
426+
NEWPERFEVENTCOUNTER(_perf_lock_hold_time[i + 1], SUN_RT, PerfDataManager::counter_name(counter_name, "AfterTime"));
415427
}
416428
if (HAS_PENDING_EXCEPTION) {
417429
vm_exit_during_initialization("MutexLockerImpl::init_counters() failed unexpectedly");
418430
}
419431
}
420432
}
421433

422-
void MutexLockerImpl::print_counter_on(outputStream* st, const char* name, int idx) {
434+
int MutexLockerImpl::name2id(const char* name) {
435+
if (ProfileVMLocks && UsePerfData) {
436+
for (int i = 0; i < _num_names; i++) {
437+
if (strcmp(_names[i], name) == 0) {
438+
_is_unique[i] = false;
439+
return i;
440+
}
441+
}
442+
if (_num_names < MAX_NAMES) {
443+
int new_id = _num_names++;
444+
_names[new_id] = os::strdup(name, mtInternal);
445+
_is_unique[new_id] = true;
446+
return new_id;
447+
}
448+
log_debug(init)("Unnamed: %s", name); // no slots left
449+
}
450+
return -1;
451+
}
452+
453+
void MutexLockerImpl::print_counter_on(outputStream* st, const char* name, bool is_unique, int idx) {
423454
jlong count = _perf_lock_count[idx]->get_value();
424455
if (count > 0) {
425-
st->print_cr(" %3d: %32s = %5ldms (%5ldms) / %9ld events", idx, name,
456+
st->print_cr(" %3d: %s%40s = %5ldms (%5ldms) / %9ld events", idx, (is_unique ? " " : "M"), name,
426457
Management::ticks_to_ms(_perf_lock_hold_time[idx]->get_value()),
427458
Management::ticks_to_ms(_perf_lock_wait_time[idx]->get_value()),
428459
count);
@@ -431,7 +462,10 @@ void MutexLockerImpl::print_counter_on(outputStream* st, const char* name, int i
431462

432463
static jlong accumulate_lock_counters(PerfCounter** lock_counters) {
433464
jlong acc = 0;
434-
for (int i = 0; i < _num_mutex + 1; i++) { // 0 slot is reserved for unnamed locks
465+
for (int i = 0; i < _num_names + 1; i++) { // 0 slot is reserved for unnamed locks
466+
if (lock_counters[i] == nullptr) {
467+
break;
468+
}
435469
acc += lock_counters[i]->get_value();
436470
}
437471
return acc;
@@ -443,14 +477,15 @@ void MutexLockerImpl::print_counters_on(outputStream* st) {
443477
jlong total_wait_time = accumulate_lock_counters(_perf_lock_wait_time);
444478
jlong total_hold_time = accumulate_lock_counters(_perf_lock_hold_time);
445479

446-
st->print_cr("MutexLocker: Total: hold = %ldms (wait = %ldms) / %ld events for thread \"main\"",
480+
st->print_cr("MutexLocker: Total: %d named locks (%d unique names); hold = %ldms (wait = %ldms) / %ld events for thread \"main\"",
481+
_num_mutex, _num_names,
447482
Management::ticks_to_ms(total_hold_time),
448483
Management::ticks_to_ms(total_wait_time),
449484
total_count);
450-
for (int i = 0; i < _num_mutex; i++) {
451-
print_counter_on(st, _mutex_array[i]->name(), i+1);
485+
for (int i = 0; i < _num_names; i++) {
486+
print_counter_on(st, _names[i], _is_unique[i], i+1);
452487
}
453-
print_counter_on(st, "Unnamed / Other", 0);
488+
print_counter_on(st, "Unnamed / Other", false /*is_unique*/, 0);
454489
} else {
455490
st->print_cr("MutexLocker: no info (%s is disabled)", (UsePerfData ? "ProfileVMLocks" : "UsePerfData"));
456491
}

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

+7-1
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,10 @@ class MutexLockerImpl: public StackObj {
248248
assert_lock_strong(_mutex);
249249
_mutex->unlock();
250250

251+
if (_mutex->id() == -1) {
252+
log_trace(init)("Unnamed unclassified lock: %s", _mutex->name());
253+
}
254+
251255
if (_prof) {
252256
assert(UsePerfData, "required");
253257
_after.stop();
@@ -259,9 +263,11 @@ class MutexLockerImpl: public StackObj {
259263
}
260264

261265
private:
262-
static void print_counter_on(outputStream* st, const char* name, int idx);
266+
static void print_counter_on(outputStream* st, const char* name, bool is_unique, int idx);
263267

264268
public:
269+
static int name2id(const char* name);
270+
265271
static void post_initialize();
266272
static void init_counters();
267273
static void print_counters_on(outputStream* st);

0 commit comments

Comments
 (0)
Please sign in to comment.