[prev in list] [next in list] [prev in thread] [next in thread]
List: openjdk-hotspot-runtime-dev
Subject: Re: RFR: 8292989: Avoid dynamic memory in AsyncLogWriter
From: Xin Liu <xliu () openjdk ! org>
Date: 2022-08-31 18:14:24
Message-ID: CnMaGTjZtDPZPrKWgpFdpwCJWrX2cI-ZN3nQvG6DP3c=.94ddcc6c-d35a-4860-9b54-1a40ca1a7220 () github ! com
[Download RAW message or body]
On Wed, 31 Aug 2022 14:04:46 GMT, Johan Sjölén <duke@openjdk.org> wrote:
> > Current implementation of AsyncLogWriter uses dynamic memory. There are 2 \
> > sources.
> > 1. Overhead of pointer-based linked-list.
> > 2. strdup of message contents
> >
> > This implementation has impact on glibc/malloc. If allocation of logsites \
> > interleave with other allocation, it's hard to clean up all glibc arenas. This \
> > worsens fragmentation issue.
> > In this PR, we replace linked-list with `2 pre-allocated raw buffers`. \
> > AsyncLogWriter appends payload AsyncLogMessage to the serving buffer and avoids \
> > all dynamic allocation. Please note this effort won't eliminate mutex lock. We \
> > use ping-pong buffers to guarantee AsyncLogWriter is still non-blocking. A buffer \
> > serves as a FIFO queue like before.
> > In addition, AsyncLogWriter doesn't enqueue meta messages anymore when it needs \
> > to report the number of discarded messages. This is archived using a temporary \
> > hashtable called `snapshot`. It copies the working hashtable with the protection \
> > of lock and reset it. After writing all regular messages, AsyncLogWriter writes \
> > meta messages from snapshot.
>
> src/hotspot/share/logging/logAsyncWriter.cpp line 143:
>
> > 141: log_warning(logging)("AsyncLogging failed to create buffers. Falling \
> > back to synchronous logging.");
> > 142:
> > 143: if (buf0 != nullptr) {
>
> `os::free(nullptr)` is safe, no need for a branch here.
okay! I will update it.
-------------
PR: https://git.openjdk.org/jdk/pull/10092
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic