Skip to content

#[cold] attribute does is not propagated across crates #64075

Open
@matklad

Description

Hi!

When hacking on once_cell, I've noticed that it is significantly faster than lazy_static. Digging into this, it seems like the difference is in the usage of the #[cold] attribute.

Specifically, I've applied a patch which marks initialization function as #[cold] in lazy_static, and it indeed improved perf quite a bunch:

matklad/lazy-static.rs@7863cc0

And this is really weird, because Once, which powers lazy_static, already has the #[cold] attribute. Seems like it doesn't take an effect for whatever reason?

@rustbot modify labels to: +I-slow

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    A-codegenArea: Code generationC-bugCategory: This is a bug.I-slowIssue: Problems and improvements with respect to performance of generated code.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