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

Xin Liu xliu at openjdk.java.net
Wed May 12 21:40:01 UTC 2021


On Fri, 7 May 2021 08:38:32 GMT, Thomas Stuefe <stuefe at openjdk.org> wrote:

> IIUC the mechanism you signal "async"-ness to the logging callsites with is via this pointer being NULL or not, right?

yes. 
> I am not sure this is safe wrt to lost log output on termination. 

It's not safe! now it may lose a coupe of messages in race condition. I have a patch to fix that. 

> Thinking this through, one could even scratch the LogAsyncBuffer dynamic allocation and make it either a static 
global object or even an AllStatic, with all static methods. 

I tried this as well. I found it's hard. Logging sites spread the entire lifecycle of JVM. Unfortunately, async logging can't be in function without some runtime supports, such as Thread::current(), threading.  One lesson I learned from this patch is that DON'T use any runtime in such low-level module.  

Now my target is to define a clear interval. Between 2 synchronization points, async logging takes over synchronous logging. I think it's acceptable because it covers the entire "java" runtime which is concerned by Java applications. 

|JVM begin---LogAsyncFlusher::initialize()---...---LogAsyncFlusher::terminate()--JVM End|


Another bonus for this 2-point-design is that we can assume only AsyncLog Thread is doing logging I/O when async logging is in charge.  it means I can skip the FileLocker imposed by unified logging framework.

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

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


More information about the hotspot-dev mailing list