Skip to content

Improve DWARF symbolization performance#1541

Open
d-e-s-o wants to merge 2 commits intolibbpf:mainfrom
d-e-s-o:topic/dwarf-perf
Open

Improve DWARF symbolization performance#1541
d-e-s-o wants to merge 2 commits intolibbpf:mainfrom
d-e-s-o:topic/dwarf-perf

Conversation

@d-e-s-o
Copy link
Copy Markdown
Collaborator

@d-e-s-o d-e-s-o commented Apr 15, 2026

Please see individual commits for descriptions.

d-e-s-o added 2 commits April 15, 2026 12:39
Change Unit to store its gimli::Unit and language in OnceCell wrappers,
introducing ensure_dw_unit() as the single access point. All units
continue to be eagerly constructed via Unit::new() for now, but the
OnceCell plumbing prepares for deferring construction when
.debug_aranges data is available.

Signed-off-by: Daniel Müller <deso@posteo.net>
Move the .debug_aranges lookup before gimli::Unit construction in
Units::parse(). When aranges provide address ranges for a CU, use
Unit::new_deferred() to skip the expensive abbreviation and line
program header parsing entirely. The full gimli::Unit is constructed
lazily on first access via ensure_dw_unit().

This changes the range source priority: .debug_aranges is now checked
before DW_AT_ranges. This is necessary because we cannot read
DW_AT_ranges without constructing the gimli::Unit (which is the
expensive operation we are deferring). In practice both sources are
assumed to agree since they are generated by the same toolchain.

Our main vmlinux based symbolization benchmarks see a vast improvement
from the lazy unit construction, because less work needs to happen
overall (the vast majority of CUs are not queried):

> main/symbolize_dwarf_no_lines
>                         time:   [11.456 ms 11.798 ms 12.163 ms]
>                         change: [−92.099% −91.860% −91.645%] (p = 0.00 < 0.02)
>                         Performance has improved.
> main/symbolize_dwarf
>                         time:   [11.102 ms 11.165 ms 11.253 ms]
>                         change: [−92.389% −92.322% −92.250%] (p = 0.00 < 0.02)
>                         Performance has improved.

Signed-off-by: Daniel Müller <deso@posteo.net>
@codecov
Copy link
Copy Markdown

codecov bot commented Apr 15, 2026

Codecov Report

❌ Patch coverage is 87.25490% with 13 lines in your changes missing coverage. Please review.
✅ Project coverage is 95.27%. Comparing base (ebba953) to head (b9620bf).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
src/dwarf/units.rs 79.59% 10 Missing ⚠️
src/dwarf/unit.rs 94.33% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1541      +/-   ##
==========================================
- Coverage   95.50%   95.27%   -0.23%     
==========================================
  Files          56       56              
  Lines        9534     9579      +45     
==========================================
+ Hits         9105     9126      +21     
- Misses        429      453      +24     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant