Large amounts of repeated data in debug info #129722
Labels
A-debuginfo
Area: Debugging information in compiled programs (DWARF, PDB, etc.)
A-LLVM
Area: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues.
C-bug
Category: This is a bug.
C-tracking-issue
Category: A tracking issue for an RFC or an unstable feature.
I-heavy
Issue: Problems and improvements with respect to binary size of generated code.
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
In #128861 (comment) I teased @nnethercote with the promise of more debug info inefficiency. One example is that the .debug_ranges section that specifies the ranges over which DWARF constructs such as functions, variables, etc are valid contains large amounts of repeated data. Rust's love of inlining and zero cost abstractions tends to produce repeated ranges.
When built with debuginfo-level = 2, tip Rust's librustc_driver.so has approximately 2.1 million entries in .debug_ranges. There are only approximately 1.1 million unique entries though. Doing the dumbest possible thing in LLVM (checking in DwarfFile::add_range to see if the new range is exactly equal to the last range, and not adding a new entry if it is) eliminates virtually all duplicated ranges (less than 1k remain) and results in a 43% reduction in the size of the .debug_ranges section, or a roughly 1.75% reduction in the size of the .so
@rustbot label A-debuginfo A-llvm I-heavy
The text was updated successfully, but these errors were encountered: