symbolizer: Load DWARF sections via mmap to reduce initialization allocations - #6410
Open
HSP18SCM23P wants to merge 4 commits into
Open
HSP18SCM23P wants to merge 4 commits into
HSP18SCM23P wants to merge 4 commits into
Conversation
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Loading DWARF debug info via debug/elf's File.DWARF() copies every section into Go heap buffers. On large binaries this dominates symbolizer initialization time and GC pressure.
This change adds elfutils.LoadDWARFData, which memory-maps the file read-only once and serves uncompressed DWARF sections as views into the mapping, building dwarf.Data with the same two-pass logic as the stdlib loader. DwarfLiner keeps the mapping alive until Close() and releases it on initialization failure.
The previous copying behavior is retained for: compressed sections (.zdebug_*, SHF_COMPRESSED), inputs whose DWARF sections need relocations applied (non-ET_EXEC with REL/RELA targeting DWARF sections), and non-unix platforms (build-tagged stub; zero new dependencies, stdlib syscall.Mmap only).
Benchmarks (loader only, -benchmem), synthetic 4000-function -g binary (~274KB DWARF): before ~283KB/op, 32 allocs/op, ~0.65-2.6ms; after 4.5KB/op, 28 allocs/op, ~38-106us.
Note: mapped pages still count toward RSS; the win is Go-heap/GC. Theoretical SIGBUS risk if a debug file were truncated while mapped (the heap-copy path didn't have this); debug artifacts are stable on disk in practice.
Fixes #6404