-
-
Notifications
You must be signed in to change notification settings - Fork 14.7k
trans/LLVM: Don't keep all LLVM modules in memory at the same time #39280
Copy link
Copy link
Closed
Labels
A-codegenArea: Code generationArea: Code generationA-concurrencyArea: ConcurrencyArea: ConcurrencyA-incr-compArea: Incremental compilationArea: Incremental compilationC-cleanupCategory: PRs that clean code up or issues documenting cleanup.Category: PRs that clean code up or issues documenting cleanup.E-mentorCall for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion.Call for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion.I-compilememIssue: Problems and improvements with respect to memory usage during compilation.Issue: Problems and improvements with respect to memory usage during compilation.I-compiletimeIssue: Problems and improvements with respect to compile times.Issue: Problems and improvements with respect to compile times.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Metadata
Metadata
Assignees
Labels
A-codegenArea: Code generationArea: Code generationA-concurrencyArea: ConcurrencyArea: ConcurrencyA-incr-compArea: Incremental compilationArea: Incremental compilationC-cleanupCategory: PRs that clean code up or issues documenting cleanup.Category: PRs that clean code up or issues documenting cleanup.E-mentorCall for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion.Call for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion.I-compilememIssue: Problems and improvements with respect to memory usage during compilation.Issue: Problems and improvements with respect to memory usage during compilation.I-compiletimeIssue: Problems and improvements with respect to compile times.Issue: Problems and improvements with respect to compile times.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Type
Fields
Give feedbackNo fields configured for issues without a type.
UPDATE: There are some mentoring instructions below if you're interested in looking into this issue.
NB: Part of the roadmap issue on incremental compilation.
Currently the compiler translates all codegen units into LLVM modules and then runs LLVM on all of them in parallel. In the context of incremental compilation, where there can be hundreds of codegen units for a single crate, but also for non-incremental builds with a high number of codegen units, this can mean a lot of memory pressure -- e.g. for Servo's
scriptcrate that's more than 10 GB peak memory usage (while otherwise it's around 4.5 GB).There's no real need to keep more LLVM modules in memory than are currently being worked on. Two possible solutions:
NLLVM threads, start persisting LLVM modules to disk at theN+1st and reload them later for optimization and codegen. That's probably relatively easy to implement but involves more disk I/O than necessary.Ncodegen units to LLVM modules, translate them all the way to object files, then go back and translate the next codegen unit. This has the advantage that we would not need to temporarily store anything on disk, but we would need to keep thetcxin memory as long as there are still untranslated codegen units. It would also require a much bigger refactoring than the first approach.Any other ideas?
cc @rust-lang/compiler @rust-lang/tools @nagisa