RFR: 8301403: Eliminate memory allocations in JVMFlag::printFlags during signal handling [v11]
Thomas Stuefe
stuefe at openjdk.org
Fri Jul 26 15:19:33 UTC 2024
On Fri, 26 Jul 2024 14:50:47 GMT, Gerard Ziemski <gziemski at openjdk.org> wrote:
>> Allocating memory while handling an error should be avoided, however `JVMFlag::printFlags()` is used by crash log and it allocates memory to print flags sorted (using qsort).
>>
>> We avoid memory allocation by using BitMapView (using stack storage for array of indices) for markers in a simple O(n^2) algorithm that lets us print in alphabetical order. Performance was measured and it's not an issue.
>>
>> Running MACH5 tests...
>
> Gerard Ziemski has updated the pull request incrementally with one additional commit since the last revision:
>
> need 32 bit version of LogBytesPerWord too
I am fine with the constexpr.
But note, if you want to keep the patch minimal, you could just do the calculation by hand:
constexpr size_t num_words_needed = (length / (sizeof(BitMap::bm_word_t) * 8)) + 1);
BitMap::bm_word_t iteratorArray[num_words_needed];
Up to you. This is fine by me.
-------------
Marked as reviewed by stuefe (Reviewer).
PR Review: https://git.openjdk.org/jdk/pull/20202#pullrequestreview-2202119769
More information about the hotspot-runtime-dev
mailing list