This is an archive of the discontinued LLVM Phabricator instance.

Reduce the memory footprint of dsymutil. (NFC)
ClosedPublic

Authored by aprantl on Aug 21 2018, 5:38 PM.

Details

Summary

This (partially) fixes a regression introduced by
https://reviews.llvm.org/D43945 / r327399, which parallelized
DwarfLinker. This patch avoids parsing and allocating the memory for
all input DIEs up front and instead only allocates them in the
concurrent loop in the AnalyzeLambda. At the end of the loop the
memory from the LinkContext is cleared again.

This reduces the peak memory needed to link the debug info of a
non-modular build of the Swift compiler by >3GB.

rdar://problem/43444464

Diff Detail

Event Timeline

aprantl created this revision.Aug 21 2018, 5:38 PM
friss added inline comments.Aug 21 2018, 5:48 PM
tools/dsymutil/DwarfLinker.cpp
2468–2472

You're changing the semantics here. registerModuleReference would not have been called in Update mode and now it will.

Also, why not simply if (CUDie)?

2502

Don't you want Quiet = true ?

2505

I would adda comment explaining that registerModuleReference() won't do any work here because the modules have been registered previously. It's just here to filter out module CUs.

friss added inline comments.Aug 21 2018, 5:58 PM
tools/dsymutil/DwarfLinker.cpp
2471

Here UnitID is always the same in this loop. Pretty sure that's bad.

aprantl updated this revision to Diff 161879.Aug 21 2018, 7:28 PM

Address (most) review feedback. Thanks!

aprantl marked 3 inline comments as done.Aug 21 2018, 7:29 PM
aprantl added inline comments.
tools/dsymutil/DwarfLinker.cpp
2468–2472

That doesn't really matter because they would have been resolved in the first pass, but I'm changing it anyway.

2471

UnitDie is an inout parameter, it is being incremented by loadClangModule() if it creates a new module.

friss accepted this revision.Aug 21 2018, 8:20 PM

Thanks, this LGTM

tools/dsymutil/DwarfLinker.cpp
2471

I see, thanks.

This revision is now accepted and ready to land.Aug 21 2018, 8:20 PM
This revision was automatically updated to reflect the committed changes.