This is an archive of the discontinued LLVM Phabricator instance.

Use a single context for lto
ClosedPublic

Authored by rafael on Apr 28 2016, 7:12 AM.

Details

Summary

Using multiple context used to be a really big memory saving because we could free memory from each file while the linker proceeded with the the symbol resolution. We are getting lazier about reading data from the bitcode, so I was curious if this was still a good tradeoff.

One thing that is a bit annoying is that we still have to copy the symbol names. The problem is that the names are stored in the Module and get freed when we move the module bits during linking.

Long term I think the solution is to add a symbol table to the bitcode. That way IRObject file will not need to use a Module or a Context and we can drop it while still keeping a StringRef to the names.

This patch might still be an interesting medium term improvement.

When linking llvm-as without debug info this patch is a small speedup:

master: 29.861877513 seconds
patch: 29.814533787 seconds

With debug info the numbers are

master: 34.765181469 seconds
patch: 34.563351584 seconds

The peak memory usage when linking llvm-as with debug info was

master: 599.10MB
patch: 600.13MB

Diff Detail

Event Timeline

rafael updated this revision to Diff 55400.Apr 28 2016, 7:12 AM
rafael retitled this revision from to Use a single context for lto.
rafael updated this object.
rafael added reviewers: ruiu, pcc, mehdi_amini.
rafael added a subscriber: llvm-commits.
mehdi_amini edited edge metadata.Apr 28 2016, 8:23 AM

Using multiple context used to be a really big memory saving because we could free memory from each file while the linker proceeded with the the symbol resolution.

Using multiple LLVMContext is an enabled to parse the bitcode in parallel, don't you care about that?

pcc accepted this revision.Apr 28 2016, 10:33 AM
pcc edited edge metadata.

LGTM with nit.

ELF/InputFiles.h
25

Duplicate #include.

This revision is now accepted and ready to land.Apr 28 2016, 10:33 AM
ruiu accepted this revision.Apr 28 2016, 10:50 AM
ruiu edited edge metadata.

LGTM with this change.

ELF/Driver.cpp
265–269

I'd move this to initLLVM and swap the order of initLLVM and readConfigs.

Eugene.Zelenko added a subscriber: Eugene.Zelenko.

Committed in r267921.