RFR: 8292989: Avoid dynamic memory in AsyncLogWriter [v8]
Xin Liu
xliu at openjdk.org
Mon Sep 12 13:41:54 UTC 2022
On Mon, 12 Sep 2022 05:55:01 GMT, Thomas Stuefe <stuefe at openjdk.org> wrote:
>> Xin Liu has updated the pull request incrementally with one additional commit since the last revision:
>>
>> get rid of TOKEN_SIZE. use Message::calc_size(0) instead.
>>
>> it's still a compiler-time constant like TOKEN_SIZE. put the
>> headroom logic in Buffer::push_back().
>
> src/hotspot/share/logging/logAsyncWriter.cpp line 52:
>
>> 50: // Reserve space for a flush token, so 'push_flush_token' always succeeds.
>> 51: AsyncLogWriter::Buffer::Buffer(size_t capacity) : _pos(0), _capacity(capacity) {
>> 52: _buf = NEW_C_HEAP_ARRAY(char, capacity, mtLogging);
>
> I would give it a low minimal size. It needs to be at least token size, but small enough to serve as a good test for simulating buffer overflows. Maybe 2-3 x header size + ~64 bytes or so. E.g. 96 bytes?
HotSpot has a constraint in VMOption. The minimal number is 50K here.
https://github.com/openjdk/jdk/blob/master/src/hotspot/share/runtime/globals.hpp#L1905
I added a unit test in test_asynclog.cpp. Like you said, I feel it's more flexible to write tests if we don't limit size here.
If buffer capacity is smaller than a token, it will hit assertion in `Buffer::push_flush_token`.
-------------
PR: https://git.openjdk.org/jdk/pull/10092
More information about the hotspot-runtime-dev
mailing list