Skip to content

Pre-allocate res_units vector#1586

Merged
d-e-s-o merged 1 commit into
libbpf:mainfrom
d-e-s-o:topic/res-units-pre-alloc
Jun 10, 2026
Merged

Pre-allocate res_units vector#1586
d-e-s-o merged 1 commit into
libbpf:mainfrom
d-e-s-o:topic/res-units-pre-alloc

Conversation

@d-e-s-o

@d-e-s-o d-e-s-o commented Jun 10, 2026

Copy link
Copy Markdown
Collaborator

Commit d0b99be ("Pre-allocate unit_ranges Vec with aranges-based capacity") improved DWARF parsing performance by sizing the unit_ranges vector based on the number of .debug_aranges entries. Resizing the res_units Vec is even worse in terms of performance, because the contained Unit objects are rather large (making copying more expensive).
Use the same size hint to pre-allocate said vector and minimize copy operations in the process.

> main/symbolize_dwarf_no_lines
>      time:   [7.1269 ms 7.1522 ms 7.1901 ms]
>      change: [−30.399% −29.940% −29.484%] (p = 0.00 < 0.02)
>      Performance has improved.
> main/symbolize_dwarf
>      time:   [6.9546 ms 6.9988 ms 7.0619 ms]
>      change: [−34.973% −34.455% −33.805%] (p = 0.00 < 0.02)
>      Performance has improved.

Commit d0b99be ("Pre-allocate unit_ranges Vec with aranges-based
capacity") improved DWARF parsing performance by sizing the unit_ranges
vector based on the number of .debug_aranges entries.
Resizing the res_units Vec is even worse in terms of performance,
because the contained Unit objects are rather large (making copying more
expensive).
Use the same size hint to pre-allocate said vector and minimize copy
operations in the process.

> main/symbolize_dwarf_no_lines
>      time:   [7.1269 ms 7.1522 ms 7.1901 ms]
>      change: [−30.399% −29.940% −29.484%] (p = 0.00 < 0.02)
>      Performance has improved.
> main/symbolize_dwarf
>      time:   [6.9546 ms 6.9988 ms 7.0619 ms]
>      change: [−34.973% −34.455% −33.805%] (p = 0.00 < 0.02)
>      Performance has improved.

Reported-by: Jannik Glückert <jannik.glueckert@gmail.com>
Signed-off-by: Daniel Müller <deso@posteo.net>
@codecov

codecov Bot commented Jun 10, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 96.32%. Comparing base (2ced358) to head (81b9f2d).
⚠️ Report is 2 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1586      +/-   ##
==========================================
+ Coverage   96.21%   96.32%   +0.10%     
==========================================
  Files          56       56              
  Lines       11132    11132              
==========================================
+ Hits        10711    10723      +12     
+ Misses        421      409      -12     

☔ View full report in Codecov by Harness.
📢 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.

@d-e-s-o d-e-s-o merged commit b33faaf into libbpf:main Jun 10, 2026
46 checks passed
@d-e-s-o d-e-s-o deleted the topic/res-units-pre-alloc branch June 10, 2026 17:06
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