Integrated: 8292989: Avoid dynamic memory in AsyncLogWriter

Xin Liu xliu at openjdk.org
Thu Sep 15 18:36:52 UTC 2022


On Wed, 31 Aug 2022 01:10:09 GMT, Xin Liu <xliu at 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.

This pull request has now been integrated.

Changeset: bf79f99c
Author:    Xin Liu <xliu at openjdk.org>
URL:       https://git.openjdk.org/jdk/commit/bf79f99c0c61fc36b80cd8550e5c70e158338ef4
Stats:     504 lines in 5 files changed: 267 ins; 199 del; 38 mod

8292989: Avoid dynamic memory in AsyncLogWriter

Reviewed-by: jsjolen, stuefe

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

PR: https://git.openjdk.org/jdk/pull/10092


More information about the hotspot-runtime-dev mailing list