PGO profile invalidation in -Cprofile-use
#100397
Labels
A-incr-comp
Area: Incremental compilation
C-bug
Category: This is a bug.
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
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
sccache
here), unless it would have to be done by everyrustc
invocation instead of just once per Cargo run? 🤔 I don't think that-Cprofile-use
is that common that this would cause perf. problems, but it could resolve a potential footgun.CC @michaelwoerister
The text was updated successfully, but these errors were encountered: