Repository navigation
MIR body serialization may be a bottleneck #80536
Copy link
Copy link
Open
Labels
A-MIRArea: Mid-level IR (MIR) - https://blog.rust-lang.org/2016/04/19/MIR.htmlArea: Mid-level IR (MIR) - https://blog.rust-lang.org/2016/04/19/MIR.htmlA-incr-compArea: Incremental compilationArea: Incremental compilationA-metadataArea: Crate metadataArea: Crate metadataA-mir-optArea: MIR optimizationsArea: MIR optimizationsA-mir-opt-inliningArea: MIR inliningArea: MIR inliningC-optimizationCategory: An issue highlighting optimization opportunities or PRs implementing suchCategory: An issue highlighting optimization opportunities or PRs implementing suchI-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.
Description
Activity
- addedA-incr-compArea: Incremental compilationArea: Incremental compilationA-metadataArea: Crate metadataArea: Crate metadataA-mir-optArea: MIR optimizationsArea: MIR optimizationsA-mir-opt-inliningArea: MIR inliningArea: MIR inlining
on Dec 30, 2020 - addedI-compiletimeIssue: Problems and improvements with respect to compile times.Issue: Problems and improvements with respect to compile times.A-MIRArea: Mid-level IR (MIR) - https://blog.rust-lang.org/2016/04/19/MIR.htmlArea: Mid-level IR (MIR) - https://blog.rust-lang.org/2016/04/19/MIR.html
on Jan 1, 2021 Decoding of foreign spans is one of hotspots quite unique to builds with inlining:
rust/compiler/rustc_metadata/src/rmeta/decoder.rs
Lines 485 to 492 in 9320b12
// Decoding 'foreign' spans should be rare enough that it's // not worth it to maintain a per-CrateNum cache for `last_source_file_index`. // We just set it to 0, to ensure that we don't try to access something out // of bounds for our initial 'guess' decoder.last_source_file_index = 0; let foreign_data = decoder.cdata().cstore.get_crate_data(cnum); foreign_data.imported_source_files(sess) - addedT-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.
on Apr 5, 2023 - addedC-optimizationCategory: An issue highlighting optimization opportunities or PRs implementing suchCategory: An issue highlighting optimization opportunities or PRs implementing such
on Feb 14, 2025
Metadata
Metadata
Assignees
Labels
A-MIRArea: Mid-level IR (MIR) - https://blog.rust-lang.org/2016/04/19/MIR.htmlArea: Mid-level IR (MIR) - https://blog.rust-lang.org/2016/04/19/MIR.htmlA-incr-compArea: Incremental compilationArea: Incremental compilationA-metadataArea: Crate metadataArea: Crate metadataA-mir-optArea: MIR optimizationsArea: MIR optimizationsA-mir-opt-inliningArea: MIR inliningArea: MIR inliningC-optimizationCategory: An issue highlighting optimization opportunities or PRs implementing suchCategory: An issue highlighting optimization opportunities or PRs implementing suchI-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.
During MIR inlining, we end up producing larger MIR bodies each, as inlining often causes an increase in MIR for non-trivial functions being inlined. This perf run shows that in the incremental cases, we lose some time to
optimized_miras expected but this is often offset by wins incodegen.However the other place we regress is time spent dealing with the incremental cache. That suggests to me that our MIR is larger due to inlining which causes more time to be spent during serialization/deserialization.
It might be worth exploring if there's any optimizations we can make to the serialized
Bodyrepresentation.Originally posted by @wesleywiser in #68828 (comment)