-
Notifications
You must be signed in to change notification settings - Fork 13.7k
Open
Labels
A-codegenArea: Code generationArea: Code generationC-bugCategory: This is a bug.Category: This is a bug.I-slowIssue: Problems and improvements with respect to performance of generated code.Issue: 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.Relevant to the compiler team, which will review and decide on the PR/issue.
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
mtak-, joshsleeper, briansmith, swarnimarun and WGH-
Metadata
Metadata
Assignees
Labels
A-codegenArea: Code generationArea: Code generationC-bugCategory: This is a bug.Category: This is a bug.I-slowIssue: Problems and improvements with respect to performance of generated code.Issue: 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.Relevant to the compiler team, which will review and decide on the PR/issue.