-
-
Notifications
You must be signed in to change notification settings - Fork 14.2k
Description
Currently, we always compress crate metadata for dylibs and proc-macros:
rust/compiler/rustc_interface/src/passes.rs
Lines 928 to 940 in ea7e131
| let metadata_kind = tcx | |
| .sess | |
| .crate_types() | |
| .iter() | |
| .map(|ty| match *ty { | |
| CrateType::Executable | CrateType::Staticlib | CrateType::Cdylib => MetadataKind::None, | |
| CrateType::Rlib => MetadataKind::Uncompressed, | |
| CrateType::Dylib | CrateType::ProcMacro => MetadataKind::Compressed, | |
| }) | |
| .max() | |
| .unwrap_or(MetadataKind::None); |
This prevents us from mmap-ing the metadata into memory when we decode it, since we need to read the entire file in order to decompress it.
We should allow configuring this setting via a -Z flag (and maybe through the Cargo.toml at some point), to allow users to trade disk space for speed. In addition to avoiding the overhead of compressing/decompressing, gaining the ability to mmap the crate metadata means that we may avoid loading unused portions from disk entirely. This is less important for proc-macros after #76897, but might still have a noticable performance impact for dylibs.
Suggested by @joshtriplett on Zulip.