This is an archive of the discontinued LLVM Phabricator instance.

Reduce memory usage when creating .gdb_index. NFC.
ClosedPublic

Authored by ruiu on Jul 9 2018, 11:40 AM.

Details

Summary

.gdb_index sections can be very large. When you are compiling
multi-gibibyte executables, they can be larger than 1 GiB. The previous
implementation of .gdb_index seems to consume too much memory.

This patch is to reduce the memory consumption by eliminating temporary
objects.

Event Timeline

ruiu created this revision.Jul 9 2018, 11:40 AM
ruiu added a comment.Jul 9 2018, 5:37 PM

This change reduces memory consumption of the GdbIndexSection when creating a 1350 GiB .gdb_index from 932 MiB to 261 MiB.

smeenai added a subscriber: smeenai.Jul 9 2018, 6:35 PM
ruiu updated this revision to Diff 154748.Jul 9 2018, 6:42 PM
  • rebased
grimar accepted this revision.Jul 10 2018, 1:44 AM

Looks good. It feels this change can be split into several smaller changes though.
I would do that for committing.

lld/ELF/SyntheticSections.cpp
2325

This can be a separate change.

2453

This can be a separate NFC.

2465

Seems this part can be a separate little change too.

2499

You are assuming at line 2475 that buffer is filled with zeroes. I think you can omit this line then.

This revision is now accepted and ready to land.Jul 10 2018, 1:44 AM
ruiu added inline comments.Jul 10 2018, 5:02 AM
lld/ELF/SyntheticSections.cpp
2499

Ah, good point. I've never thought of it, but that's true.

This revision was automatically updated to reflect the committed changes.