Skip to content

Allow using uncompressed metadata for proc-macros and dylibs #77602

Open
@Aaron1011

Description

@Aaron1011

Currently, we always compress crate metadata for dylibs and proc-macros:

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-metadataArea: Crate metadataC-enhancementCategory: An issue proposing an enhancement or a PR with one.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions