RFR: 8292989: Avoid dynamic memory in AsyncLogWriter [v2]
Xin Liu
xliu at openjdk.org
Thu Sep 8 00:36:40 UTC 2022
On Wed, 7 Sep 2022 19:04:48 GMT, Xin Liu <xliu at openjdk.org> wrote:
>> Update: I looked at AsyncLogMessage and you are almost at what I propose anyway since the in-buffer version of AsyncLogMessage already follows my proposed layout. And your `AsyncLogMessage::size()` is similar to what I propose too.
>>
>> But the way you do it, you have two versions, one where the message follows the header, one where it is wherever. This means that `AsyncLogMessage::size()` is wrong for at least half the time.
>
> I prefer trailing 0 because `AsyncLogMessage::message()` can be treated as a valid c-string and pass to LogFileStreamOutput. If so, `len` is optional indeed. The benefit of `len` is that we can iterate buffer faster. We will have O(1) time-complexity instead of O(len) in `Buffer::Iterator::next() `
>
> I see your point. It's more elegant to use `implicit` message. The reason I need to handle `msg= nullptr` is that flushing Token uses it. I can replace it with "" instead.
I update to use in-place new for AsyncLogMessage objects. For safety, I change AsyncLogMessage to a nested class and rename it to 'Message'. It's private so it's not accessible by outside.
Previously, we had at least one extra copy of `LogDecorations`. Now it aligns with c-str message. We materialize them only in constructor. Because we have to support asynchronous execution, this is optimal.
-------------
PR: https://git.openjdk.org/jdk/pull/10092
More information about the hotspot-runtime-dev
mailing list