8302508: Add timestamp to the output TraceCompilerThreads

Reviewed-by: thartmann
(cherry picked from commit f813dc7183)
This commit is contained in:
Vladimir Kozlov
2023-03-08 18:23:39 +00:00
committed by Vitaly Provodin
parent 0ed94b65b4
commit 3835a665dd

View File

@@ -906,6 +906,21 @@ JavaThread* CompileBroker::make_thread(ThreadType type, jobject thread_handle, C
return new_thread;
}
static bool trace_compiler_threads() {
LogTarget(Debug, jit, thread) lt;
return TraceCompilerThreads || lt.is_enabled();
}
static void print_compiler_threads(stringStream& msg) {
if (TraceCompilerThreads) {
tty->print_cr("%7d %s", (int)tty->time_stamp().milliseconds(), msg.as_string());
}
LogTarget(Debug, jit, thread) lt;
if (lt.is_enabled()) {
LogStream ls(lt);
ls.print_cr("%s", msg.as_string());
}
}
void CompileBroker::init_compiler_threads() {
// Ensure any exceptions lead to vm_exit_during_initialization.
@@ -945,11 +960,13 @@ void CompileBroker::init_compiler_threads() {
JavaThread *ct = make_thread(compiler_t, thread_handle, _c2_compile_queue, _compilers[1], THREAD);
assert(ct != nullptr, "should have been handled for initial thread");
_compilers[1]->set_num_compiler_threads(i + 1);
if (TraceCompilerThreads) {
if (trace_compiler_threads()) {
ResourceMark rm;
ThreadsListHandle tlh; // name() depends on the TLH.
assert(tlh.includes(ct), "ct=" INTPTR_FORMAT " exited unexpectedly.", p2i(ct));
tty->print_cr("Added initial compiler thread %s", ct->name());
stringStream msg;
msg.print("Added initial compiler thread %s", ct->name());
print_compiler_threads(msg);
}
}
}
@@ -966,11 +983,13 @@ void CompileBroker::init_compiler_threads() {
JavaThread *ct = make_thread(compiler_t, thread_handle, _c1_compile_queue, _compilers[0], THREAD);
assert(ct != nullptr, "should have been handled for initial thread");
_compilers[0]->set_num_compiler_threads(i + 1);
if (TraceCompilerThreads) {
if (trace_compiler_threads()) {
ResourceMark rm;
ThreadsListHandle tlh; // name() depends on the TLH.
assert(tlh.includes(ct), "ct=" INTPTR_FORMAT " exited unexpectedly.", p2i(ct));
tty->print_cr("Added initial compiler thread %s", ct->name());
stringStream msg;
msg.print("Added initial compiler thread %s", ct->name());
print_compiler_threads(msg);
}
}
}
@@ -1028,10 +1047,12 @@ void CompileBroker::possibly_add_compiler_threads(JavaThread* THREAD) {
thread_oop = create_thread_oop(name_buffer, THREAD);
}
if (HAS_PENDING_EXCEPTION) {
if (TraceCompilerThreads) {
if (trace_compiler_threads()) {
ResourceMark rm;
tty->print_cr("JVMCI compiler thread creation failed:");
PENDING_EXCEPTION->print();
stringStream msg;
msg.print_cr("JVMCI compiler thread creation failed:");
PENDING_EXCEPTION->print_on(&msg);
print_compiler_threads(msg);
}
CLEAR_PENDING_EXCEPTION;
break;
@@ -1046,12 +1067,14 @@ void CompileBroker::possibly_add_compiler_threads(JavaThread* THREAD) {
JavaThread *ct = make_thread(compiler_t, compiler2_object(i), _c2_compile_queue, _compilers[1], THREAD);
if (ct == nullptr) break;
_compilers[1]->set_num_compiler_threads(i + 1);
if (TraceCompilerThreads) {
if (trace_compiler_threads()) {
ResourceMark rm;
ThreadsListHandle tlh; // name() depends on the TLH.
assert(tlh.includes(ct), "ct=" INTPTR_FORMAT " exited unexpectedly.", p2i(ct));
tty->print_cr("Added compiler thread %s (available memory: %dMB, available non-profiled code cache: %dMB)",
ct->name(), (int)(available_memory/M), (int)(available_cc_np/M));
stringStream msg;
msg.print("Added compiler thread %s (available memory: %dMB, available non-profiled code cache: %dMB)",
ct->name(), (int)(available_memory/M), (int)(available_cc_np/M));
print_compiler_threads(msg);
}
}
}
@@ -1067,12 +1090,14 @@ void CompileBroker::possibly_add_compiler_threads(JavaThread* THREAD) {
JavaThread *ct = make_thread(compiler_t, compiler1_object(i), _c1_compile_queue, _compilers[0], THREAD);
if (ct == nullptr) break;
_compilers[0]->set_num_compiler_threads(i + 1);
if (TraceCompilerThreads) {
if (trace_compiler_threads()) {
ResourceMark rm;
ThreadsListHandle tlh; // name() depends on the TLH.
assert(tlh.includes(ct), "ct=" INTPTR_FORMAT " exited unexpectedly.", p2i(ct));
tty->print_cr("Added compiler thread %s (available memory: %dMB, available profiled code cache: %dMB)",
ct->name(), (int)(available_memory/M), (int)(available_cc_p/M));
stringStream msg;
msg.print("Added compiler thread %s (available memory: %dMB, available profiled code cache: %dMB)",
ct->name(), (int)(available_memory/M), (int)(available_cc_p/M));
print_compiler_threads(msg);
}
}
}
@@ -1887,9 +1912,12 @@ void CompileBroker::compiler_thread_loop() {
// Access compiler_count under lock to enforce consistency.
MutexLocker only_one(CompileThread_lock);
if (can_remove(thread, true)) {
if (TraceCompilerThreads) {
tty->print_cr("Removing compiler thread %s after " JLONG_FORMAT " ms idle time",
thread->name(), thread->idle_time_millis());
if (trace_compiler_threads()) {
ResourceMark rm;
stringStream msg;
msg.print("Removing compiler thread %s after " JLONG_FORMAT " ms idle time",
thread->name(), thread->idle_time_millis());
print_compiler_threads(msg);
}
// Notify compiler that the compiler thread is about to stop