Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce address based index to ELF symbol table cache #939

Merged
merged 2 commits into from
Dec 23, 2024

Conversation

danielocfb
Copy link
Collaborator

So far our symbol table cache had the symbols mapped into memory and then sorted references to them by the respective symbol's address, in a heap allocated array. This is conceptually fine, but it is an approach that is incompatible with future changes.
This change reworks the SymbolTableCache type as follows: 1) we to store the memory mapped symbols as-is; that is, we keep an
(unsorted) slice of the symbols around
2) we then build an additional index that is sorted by address on top of
that

In so doing we eliminate the need for keeping unnecessary references to the memory mapped data around. Further more, we could optimize the (heap allocated) index further, by using a smaller index size when the number of symbols is below certain maxima. Third, because symbol filtering now happens inside SymbolTableCache, we remove the duplication for filtering and sorting symbols for 32 and 64 bit, respectively. Lastly, because we no longer heap allocate an array of references, we can ditch the ElfN_BoxedSyms type, which was arguably a weird special case to have, entirely.

So far our symbol table cache had the symbols mapped into memory and
then sorted references to them by the respective symbol's address, in a
heap allocated array. This is conceptually fine, but it is an approach
that is incompatible with future changes.
This change reworks the SymbolTableCache type as follows:
1) we to store the memory mapped symbols as-is; that is, we keep an
   (unsorted) slice of the symbols around
2) we then build an additional index that is sorted by address on top of
   that

In so doing we eliminate the need for keeping unnecessary references to
the memory mapped data around. Further more, we could optimize the (heap
allocated) index further, by using a smaller index size when the number
of symbols is below certain maxima. Third, because symbol filtering now
happens inside SymbolTableCache, we remove the duplication for filtering
and sorting symbols for 32 and 64 bit, respectively. Lastly, because we
no longer heap allocate an array of references, we can ditch the
ElfN_BoxedSyms type, which was arguably a weird special case to have,
entirely.

Signed-off-by: Daniel Müller <[email protected]>
With the introduction of an address based cache for ELF symbols, we no
longer require the ElfNBoxedSlice type. Remove it.

Signed-off-by: Daniel Müller <[email protected]>
Copy link

codecov bot commented Dec 23, 2024

Codecov Report

Attention: Patch coverage is 97.72727% with 2 lines in your changes missing coverage. Please review.

Project coverage is 94.56%. Comparing base (9a39222) to head (9116402).
Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
src/elf/parser.rs 98.71% 1 Missing ⚠️
src/elf/types.rs 90.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #939      +/-   ##
==========================================
+ Coverage   94.44%   94.56%   +0.12%     
==========================================
  Files          57       57              
  Lines       10531    10527       -4     
==========================================
+ Hits         9946     9955       +9     
+ Misses        585      572      -13     

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

@danielocfb danielocfb merged commit a2e6c8a into libbpf:main Dec 23, 2024
41 checks passed
@danielocfb danielocfb deleted the topic/create_by_name_idx branch December 23, 2024 17:39
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.

2 participants