[PATCH] D74773: [LLD][Debuginfo] create DWARFContext only once for the same object file.

Fangrui Song via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Mar 12 17:23:28 PDT 2020


MaskRay added a comment.

Commit dcf6494abed7550fc84d6b59b33efc634a95c1fe <https://reviews.llvm.org/rGdcf6494abed7550fc84d6b59b33efc634a95c1fe> does not have a subject line.

See my inline comment: I am a bit concerned if we cache DWARFContext for every input file for the proposed --gc-debuginfo feature.

For that affected internal target (which uses --gdb-index):

  % /usr/bin/time -f "%P %M" /tmp/ReleaseA/bin/ld.lld @response.txt --no-gdb-index
  546% 13761460
  
  # Between D74773 and my fix
  % /usr/bin/time -f "%P %M" /tmp/ReleaseA/bin/ld.lld @response.txt
  1010% 22083732
  
  # Before D74773 or after my fix
  % /usr/bin/time -f "%P %M" /tmp/ReleaseA/bin/ld.lld @response.txt
  1098% 18219472
  
  % /usr/bin/time -f "%P %M" gold @response.txt
  99% 16236236



================
Comment at: lld/ELF/SyntheticSections.cpp:2825
   parallelForEachN(0, sections.size(), [&](size_t i) {
-    ObjFile<ELFT> *file = sections[i]->getFile<ELFT>();
-    DWARFContext dwarf(std::make_unique<LLDDwarfObj<ELFT>>(file));
+    DWARFContext *dwarf =
+        sections[i]->getFile<ELFT>()->getDwarf()->getContext();
----------------
We don't want to keep cached DWARFContext here.

--gdb-index can be memory heavy and caching DWARFContext for every input section can greatly increase memory usage.

I have fixed it (restored the previous behavior) with commit 0bb362c1649912d3a328dd01c700626d0a9f5a2c.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D74773/new/

https://reviews.llvm.org/D74773





More information about the llvm-commits mailing list