Figure out how to make symbolisation code smaller
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 119k
- Forks
- 16.1k
- PR merge metrics
- PR metrics pending
Description
Rust binaries are notoriously large. For instance, a simple, release-mode "Hello, world!" binary has a size of over 400 kB on my machine (ARM macOS). Much of this size (probably more than half) comes from the symbolisation that std performs when printing backtraces, as that pulls in a DWARF parser, an ELF/Mach-O parser, four instantiations of sort and some other things in order to support printing line numbers and file names. Annoyingly, this code is almost completely redundant when a binary is compiled with the release profile, as that profile disables the generation of the very DWARF debug info that all that code aims to use. Thus, when compiling with -C debuginfo=none, all this code could be replaced by a simple dladdr call without any loss of functionality.
Unfortunately, std being pre-compiled makes fixing this is rather difficult since we can't just add a feature flag to std and turn that on and off depending on compiler flags. My idea here would be to copy the strategy used to implement -C panic and make -C debuginfo select between two separate crates: one that calls back into std to employ the backtrace-rs logic and one that uses dladdr or a similar platform function. I'm not sure that's feasible, however.
This issue exists to coordinate work on reducing the size of backtrace-rs (there are some obvious some fixes like using dynamic dispatch to reduce the number of sort instantiations) and to discuss strategies for reducing the binary size further.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reviewing the backtrace-rs symbolisation logic and how the -C debuginfo and -C panic options select implementation strategies. Compare the proposed dynamic-dispatch reductions with the separate-crate approach. Done means there is an agreed, demonstrated strategy for reducing release-binary size without losing backtrace functionality.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- compilers, performance
- Issue type
- Refactor
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100