-
-
Notifications
You must be signed in to change notification settings - Fork 14.7k
PGO profile invalidation in -Cprofile-use #100397
Copy link
Copy link
Open
Labels
A-incr-compArea: Incremental compilationArea: Incremental compilationC-bugCategory: This is a bug.Category: This is a bug.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.
Metadata
Metadata
Assignees
Labels
A-incr-compArea: Incremental compilationArea: Incremental compilationC-bugCategory: This is a bug.Category: This is a bug.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.
Type
Fields
Give feedbackNo fields configured for issues without a type.
Hi! While working on https://github.com/Kobzol/cargo-pgo, I noticed a peculiar thing about the invalidation of the PGO profile path.
When PGO is used for compiling, we specify the path to the PGO profile using
-Cprofile-use=<path>. When<path>changes, it invalidates the compilation session, so the code is recompiled again (as it should be, if the profile changes).However, if the path stays the same, but the contents of the profile file change, the code will not be recompiled. That can be a footgun, since users might try to gather profiles incrementally and then try to compile/benchmark using the new profiles, but if the profile path stays the same (if it's just overwritten each time), they might not notice that the code is not recompiled and they thus might get stale results.
Would it be feasible to check the hash/modification time of the profile file instead of just the file path, w.r.t. invalidating recompilation? Is there any prior art to this in some other Rust flags?
I think that hashing the file wouldn't be such a bottleneck (I think that it was done for
sccachehere), unless it would have to be done by everyrustcinvocation instead of just once per Cargo run? 🤔 I don't think that-Cprofile-useis that common that this would cause perf. problems, but it could resolve a potential footgun.CC @michaelwoerister