RFR: 8334866: Improve Speed of ElfDecoder source search [v7]
Christian Hagedorn
chagedorn at openjdk.org
Thu Oct 30 11:46:16 UTC 2025
On Wed, 29 Oct 2025 15:16:39 GMT, Kerem Kat <krk 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.
>
> Kerem Kat has updated the pull request with a new target base due to a merge or a rebase. The incremental webrev excludes the unrelated changes brought in by the merge/rebase. The pull request contains 19 additional commits since the last revision:
>
> - fix space
> - Address comments and better guess the initial cache size
> - Merge branch 'master' into elfdecoder-JDK-8334866
> - Fix comments, delete copy ctor
> - Merge branch 'master' into elfdecoder-JDK-8334866
> - fix DWARF_LOG_INFO
> - Comment on ArangesCache
> - Fix secondary sort order and comment
> - Remove move ctor of ArangesCache
> - Clarify when we can fallback to linear scan, which doesn't seem to allocate on the heap
> - ... and 9 more: https://git.openjdk.org/jdk/compare/e523131d...9814a3ff
Thanks a lot for the update and showing some more benchmark results, looks good!
src/hotspot/share/utilities/elfFile.hpp line 540:
> 538: FAILED,
> 539:
> 540: // Cache is usable, no need to fallback to linear scan.
Suggestion:
// Cache is usable, no need to fall back to linear scan.
-------------
Marked as reviewed by chagedorn (Reviewer).
PR Review: https://git.openjdk.org/jdk/pull/27337#pullrequestreview-3399078277
PR Review Comment: https://git.openjdk.org/jdk/pull/27337#discussion_r2477696960
More information about the hotspot-dev
mailing list