Add an API for releasing cached DIEs to improve iteration performance - #669
Conversation
|
@sevaa wdyt about this alternative? @grahamroff-dev the new method seems OK to me, but I'm less sure about modifying |
|
I am not a fan of building up the cache then discarding it, rather than not building in the first place. The proposed change to The forced "clear the cache" method might be useful, we should keep it - for those consumers who won't mind managing the cache manually to avoid those OOMs. |
|
Disabling the cache completely seems more intrusive, and is targeting (I think) an even narrower use-case - processing a single very large CU where limiting memory completely trumps performance. The per-CU DIE cache provides a good performance boost while processing that CU:
but it provides little benefit after moving to another CU unless the caller revisits that CU or follows a cross-CU reference. So the cache cleaning between CUs works a good memory optimization without affecting iteration performance. I can remove the change to the |
Yes, this would be preferable |
5d356a1 to
d5f8bb4
Compare
Add CompileUnit.clear_DIE_cache() to allow consumers iterating over each compile unit to release the DIE graph after processing it, significantly reducing peak memory usage. Preserve the existing caching behavior by default and add tests for release and reparsing after release. Signed-off-by: Graham Roff <grahamr@qti.qualcomm.com>
d5f8bb4 to
1a7c77c
Compare
|
Done, PR updated to just add the new cache clearing API. |
|
No objections. |
Add CompileUnit.clear_DIE_cache() and an optional release_dies argument to DWARFInfo.iter_CUs(). This allows consumers iterating over each compile unit to release the DIE graph after processing it, significantly reducing peak memory usage. In a test parsing a 30MB elf file this reduces the maximum RAM usage from 1.8 GB to about 190 MB, with a resulting non-trivial boost in performance.
Preserve the existing caching behavior by default and add tests for explicit release, automatic release, and reparsing after release.
Relates (as an alternate solution) to #626