RFR: 8229517: Support for optional asynchronous/buffered logging [v12]
Xin Liu
xliu at openjdk.java.net
Mon May 10 23:13:04 UTC 2021
On Fri, 7 May 2021 08:24:03 GMT, Thomas Stuefe <stuefe at openjdk.org> wrote:
>> Xin Liu has updated the pull request incrementally with one additional commit since the last revision:
>>
>> Change option AsyncLogBufferEntries to AsyncLogBufferSize.
>>
>> AsyncLogBufferSize is the memory budget in bytes for Asynchronous Logging.
>> User can specify it in shorthand form. eg. -XX:AsyncLogBufferSize=10M.
>
> src/hotspot/share/logging/logAsyncFlusher.cpp line 206:
>
>> 204:
>> 205: LogAsyncFlusher* LogAsyncFlusher::instance() {
>> 206: if (Thread::current_or_null() != nullptr) {
>
> I don't understand why this depends on the existence of a current thread? Ideally we should be able to log just fine in corner cases, e.g. when thread is detached or if we have an error (during signal handling e..g.)
`LogAsyncFlusher::enqueue` needs Thread::current() to use _lock.
void Mutex::lock_without_safepoint_check() {
lock_without_safepoint_check(Thread::current());
}
This check is for a very rare corner case. This can be trigger using the following cmdline.
`
java -Xlog:'thread+smr=debug:file=/tmp/t.log' -Xlog:async -version
`
the root cause is the following code in thread
void ThreadsSMRSupport::smr_delete(JavaThread *thread) {
elapsedTimer timer;
if (EnableThreadSMRStatistics) {
timer.start();
}
wait_until_not_protected(thread);
delete thread; // Thread::current() will trigger assert(current != __null) failed: Thread::current() called on detached thread after ~Thread()
if (EnableThreadSMRStatistics) {
timer.stop();
uint millis = (uint)timer.milliseconds();
ThreadsSMRSupport::inc_deleted_thread_cnt();
ThreadsSMRSupport::add_deleted_thread_times(millis);
ThreadsSMRSupport::update_deleted_thread_time_max(millis);
}
// logsite will crash in async mode because we can't use Thread::current() here.
log_debug(thread, smr)("tid=" UINTX_FORMAT ": ThreadsSMRSupport::smr_delete: thread=" INTPTR_FORMAT " is deleted.", os::current_thread_id(), p2i(thread));
}
-------------
PR: https://git.openjdk.java.net/jdk/pull/3135
More information about the hotspot-dev
mailing list