Closed SUPERCILEX closed 1 year ago
That's an interesting idea. I don't think that it's possible with Cargo today, but even if it was, there are at least two large problems that I see with it:
Hmmm, that sounds practically intractable.Maybe a better idea is to make the flow for installing cargo binaries more amenable to pgo?
Currently you'd have to git clone, checkout the latest tag (assuming there even is one), do pgo, and finally cargo pgo install --path (is that a thing?). And you're also left out from any updates, having to manually repeat this whole process each time. It makes more sense to keep around the profiles across updates since probably not all code has changed, and therefore the quality of the profiles will decay rather become useless immediately (I think).
The ideal flow is probably something like: you cargo install as usual, but you can optionally run a separate command at any time to gather profiles for the binary and re-install. These profiles stick around and get reused across updates. Running the optional pgo-this-binary command would wipe the profiles if they came from an old version but append if it's the same crate version letting you build better profiles over time.
That would definitely require an RFC though, so maybe too much of a pain.
This would basically mean that cargo-pgo
would need to be integrated as part of cargo
, and on top of that a lot of other functionality would have to be added to cargo install
. Based on the current maintainer shortage and feature freeze/slowdown of cargo
, I don't think that this is going to happen anytime soon.
And I'm not really sure that it's worth all this effort. If you want the fastest possible binary for a specific use-case, you'll want to do more things than just PGO/BOLT (LTO=thin, CGU=1, -C target-cpu=native
etc.). cargo install
is a tool to provide a reasonably optimized binary with wide platform/CPU support, using PGO and other, more targeted optimizations, is usually done in some custom way and is hard to generalize.
Yeah, it's be quite an effort for sure. Agreed that it's probably not worth it for now.
Is it possible to ship the PGO/BOLT profile files with a crate such that a cargo install will use them? That would be quite powerful for rust ecosystem tools where people tend to prefer installing from source.