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

Xin Liu xliu at openjdk.java.net
Thu May 20 08:33:36 UTC 2021


On Thu, 20 May 2021 07:42:43 GMT, Volker Simonis <simonis at openjdk.org> wrote:

>> I would like to consolidate "exclusively". Once async logging takes over, we guarantee that no synchronous logsite is writing files in concurrency.  If we guarantee that, we can avoid FileLocker() because only AsyncLog Thread writes files. 
>> 
>> Fence isn't enough here. fence can only guarantee that logsites 'after' the fence use async logging.  It's possible that there are on-going synchronous logging. 
>> 
>> This is a RCU trick of Unified logging.  RCU is kind of synchronization biased to multiple readers. `LogOutputList::Iterator` actually embeds an atomic counter.
>> ts->wait_until_no_readers() waits until all readers finish. It means that all synchronous write have done. 
>> 
>> here is how synchronous log writes. Iterator increases to zero when the loop is done. 
>>  
>> 
>> void LogTagSet::log(LogLevelType level, const char* msg) {
>>   LogDecorations decorations(level, *this, _decorators);
>>   for (LogOutputList::Iterator it = _output_list.iterator(level); it != _output_list.end(); it++) {
>>     (*it)->write(decorations, msg);
>>   }
>> }```
>
> Thanks for the explanation. I assume you meant that the `Iterator` **de**creases the readers to zero when the loop is done. But I think I got it now.

Yes, the scope of 'it' is defined inside the 'for' construct.  Once control flow exists the loop, 
the dtor of Iterator will automatically be invoked. When all pending synchronous logsites have completed,  all RCU counters of OutputList objects restore to zero.  It means there's no on-going 'reader'. 
 


    ~Iterator() {
      _list->decrease_readers();
    }

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

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


More information about the hotspot-dev mailing list