RFR: 8334866: Improve Speed of ElfDecoder source search
Kerem Kat
krk at openjdk.org
Wed Sep 17 11:11:17 UTC 2025
On Wed, 17 Sep 2025 10:37:14 GMT, Francesco Andreuzzi <fandreuzzi at openjdk.org> wrote:
>> Right now, looking up source file and line number info is slow because we do a full linear scan of the `.debug_aranges` section for every single call. This can be a major bottleneck on large binaries, especially during frequent native stack walking, e.g. while writing an hs_err.
>>
>> This change fixes that by caching the address ranges on the first lookup, and keeping it in memory for the lifetime of the `DwarfFile` object.
>>
>> All subsequent lookups on that object now use a binary search instead of the slow linear scan. If caching fails for any reason, it just falls back to the old method.
>
> src/hotspot/share/utilities/elfFile.hpp line 530:
>
>> 528: size_t _capacity;
>> 529: bool _initialized;
>> 530: bool _failed;
>
> What's the advantage of having `_failed`? It seems that whenever you check `_failed` you also check `_initialized`.
If initialization is failed for some reason, we do not try it again for the same `DwarfFile`, with the check in `ensure_aranges_cache`.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/27337#discussion_r2355151876
More information about the hotspot-dev
mailing list