Replies: 1 comment 4 replies
-
That someone was probably https://github.com/zamazan4ik 😆 Well, in theory, it is possible. You can PGO instrument a library and then run a binary using that library on some workload (well, you would probably just PGO instrument the whole thing, as Rust libs and binaries are usually compiled together, see below). Then when you get the set of profiles, it should be possible to compile just the library using the profiles. However, there are two issues with this approach. The first one is relatively straightforward and might not be such a big issue; libraries are by their definitions general, and they might be used in many different situations and use-cases. It might be thus a bit challenging to find good workloads that will consistently provide a speedup for a majority of users of said library (remember, when held wrong, PGO can also hamper performance, although it's quite rare in my experience). The second issue is more problematic. Rust libraries are usually compiled together with the resulting binary, in the form of What we could do instead is to design some general way of sharing profiles; if e.g. Cargo could download a PGO profile from crates.io, it could leverage it during the compilation of downstream binaries. But this is easier said than done; primarily because PGO profiles are usually anything but portable. Different OSes, different LLVM versions, pretty much different anything on your system might cause them to stop working. So distributing them to the world might require the design of some more general stable format, which is probably a lot of work. |
Beta Was this translation helpful? Give feedback.
-
Became aware of this tool due to someone evangalizing the use of PGO to various crates. One conversation that caught my eye was with a library author: The evangalist demonstrated 40% improvements in some cases, and the library author was interested, but the only known ways of applying the optimization were shipping prebuilt binaries, or modifying the source code to try and reproduce what PGO did. (conversation I'm referencing: tokio-rs/prost#1041 )
So, going back to the title of this discussion: is there a (possibility of a) mechanism that allows libraries to float profiles up to the binaries that use them?
Beta Was this translation helpful? Give feedback.
All reactions