[all-commits] [llvm/llvm-project] d0d0a6: [DWARFVerifier] rewrite DieRangeInfo::insert to re...
Peter Rong via All-commits
all-commits at lists.llvm.org
Fri Mar 13 11:06:46 PDT 2026
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: d0d0a665c238f143b085c2355c7c6608359b1bf6
https://github.com/llvm/llvm-project/commit/d0d0a665c238f143b085c2355c7c6608359b1bf6
Author: Peter Rong <peterrong96 at gmail.com>
Date: 2026-03-13 (Fri, 13 Mar 2026)
Changed paths:
M llvm/benchmarks/CMakeLists.txt
A llvm/benchmarks/DWARFVerifierBM.cpp
M llvm/lib/DebugInfo/DWARF/DWARFVerifier.cpp
M llvm/unittests/DebugInfo/DWARF/CMakeLists.txt
A llvm/unittests/DebugInfo/DWARF/DWARFVerifierTest.cpp
Log Message:
-----------
[DWARFVerifier] rewrite DieRangeInfo::insert to remove O(N^2) loop (#185915)
We have a dSYM that is ~5.6 GB and has 69,840 compile units that took 3+
hours to verify (`dsymutil --verify-dwarf=auto`). This severely slowed
our build time. So I investigated by `perf record` for a few minutes and
found that `DWARFVerifier::DieRangeInfo::insert(const DieRangeInfo &RI)`
was consuming 83% of CPU time — 48% in `_Rb_tree_increment` (iterator
traversal) and 36% in the `insert` function itself.
It turns out the function was linearly scanning all children in a
std::set to check for range overlaps, when it could leverage the sorted
property of the set and check only the immediate neighbors after a O(log
N) insertion. The worst compile unit had ~189K DIEs, making this O(N²)
scan take over 4 minutes for a single unit.
The fix: insert into the sorted set first (O(log N)), then check only
the predecessor and successor for intersection. Since children are
verified non-overlapping as they are inserted incrementally, if the
immediate neighbors don't intersect, no other child can either.
Results:
- Full verification: 181 minutes → 3.5 minutes (~52x speedup)
- Worst single compile unit: 245 seconds → 1.7 seconds (146x)
- Unit test with N=100,000 inserts (old → new):
- Forward order: 262s → 33ms
- Reverse order: 288s → 18ms
- Random order: 369s → 59ms
---------
Co-authored-by: J. Ryan Stinnett <ryan at convolv.es>
To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications
More information about the All-commits
mailing list