RFR: 8317433: Async UL: Only grab lock once when write():ing
Johan Sjölen
jsjolen at openjdk.org
Thu Oct 5 10:01:41 UTC 2023
On Thu, 5 Oct 2023 05:30:58 GMT, Xin Liu <xliu at openjdk.org> wrote:
>> Hi,
>>
>> The writer thread used to await for `_data_available` to become true through using the async log lock as a condition variable. When data is available it'd let go of the lock and then call `AsyncLogWriter::write()`, which would immediately try to acquire that same lock. We can remove this second instance by moving the work needed to be done under lock to `run`.
>>
>> Thank you for considering this.
>
> src/hotspot/share/logging/logAsyncWriter.cpp line 152:
>
>> 150: void AsyncLogWriter::run() {
>> 151: while (true) {
>> 152: AsyncLogMap<AnyObj::C_HEAP> snapshot;
>
> your optimization is great!
>
> I found that you changed RESOURCE_AREA to C_HEAP here. snapshot is still a local variable. Every iteration will destruct it and free up internal nodes in C_HEAP.
>
> Why can't still use RESOURCE_AREA here?
> 'ResourceMark rm' before AsyncLogMap<AnyObj::RESOURCE_AREA > snapshot will reset the arena. Comparing to malloc/free on C_HEAP, free up a bunch of nodes is zero-cost using arena.
Thanks for noticing this, in an earlier revision this change was necessary. I'm reverting it back to the old resource allocation.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/16030#discussion_r1347148737
More information about the hotspot-runtime-dev
mailing list