RFR: 8229517: Support for optional asynchronous/buffered logging [v17]

Xin Liu xliu at openjdk.java.net
Fri May 21 08:23:38 UTC 2021


On Fri, 21 May 2021 06:16:30 GMT, David Holmes <dholmes at openjdk.org> wrote:

>> Xin Liu has updated the pull request incrementally with one additional commit since the last revision:
>> 
>>   Update according to reviewer's feedback.
>
> src/hotspot/share/logging/logAsyncWriter.hpp line 34:
> 
>> 32: #include "utilities/hashtable.hpp"
>> 33: #include "utilities/linkedlist.hpp"
>> 34: 
> 
> Could you write a summary of operation comment explaining how async mode works e.g.  details on initialization and teardown, how the thread interacts with writers etc. Thanks.

How about this?

`initialize()` is called once when JVM is initialized. It creates and initialize the singleton instance of AsyncLogWriter. Once async logging is established, there's no way to turn it off. 

`instance()` is MT-safe and returns the pointer of the singleton instance if and only if async mode is on and has well initialized.  Clients can use its return value to determine async logging is established or not. 

The basic operation of AsyncLogWriter is `enqueue`. Two overloading versions of it are provided to match `LogOutput::write`. To support async logging,  derived classes of LogOutput can invoke the corresponding AsyncLogWriter::enqueue in write() and return -1.  AsyncLogWriter is responsible of copying both decorations and cstr messages and managing their lifecycle. 

The static member function `flush`is designated to flush out all pending messages when JVM is terminating or aborting. In normal JVM termination, flush() is invoked in `LogConfiguration::finalize()`.  In abortion situation, `flush()` is invoked in `os::shutdown()`.  `flush` is MT-safe and can be invoked arbitrary times.  It is no-op if asynclogging is not established.

-------------

PR: https://git.openjdk.java.net/jdk/pull/3135


More information about the hotspot-dev mailing list