4 ms·
can't help but wonder, if one could push PGO into the actual runtime of the program itself? e.g. have a "GC" pass that would go through and re-arrange the basic
by webdevver 3y ago
can't help but wonder, if one could push PGO into the actual runtime of the program itself? e.g. have a "GC" pass that would go through and re-arrange the basic blocks in the .text section, flush cache, then go back to running the code for a bit, repeat, etc.
sort of what javascript engines do already (as I understand it anyway), but apply it to actual binary code.
- viraptor 3y agoPropeller does this kind of: https://github.com/google/llvm-propeller/blob/main/Docs/OptimizeClangO3WithPropeller.md https://github.com/google/llvm-propeller/blob/main/Docs/Opti... It doesn't work online on the running code, but does on already compiled binaries. You can't move things after loading, without the application helping you, because the function pointers may be saved already. But you could optimise between runs. Alternatively, jits can already do pgo.
- neonsunset 3y agoThat’s what JVM HotSpot and .NET do. The former had this since a long time ago and the latter had this since 6 but only enabled by default in the recent 8 release. There’s a video that describes how it works, although it focuses more on devirtualization and inlining rather than basic block reordering (which .NET also does, it’s a “proper” PGO implementation): https://youtu.be/WrpYcGic9b8?si=sLKAi-bpzDevgswx https://youtu.be/WrpYcGic9b8?si=sLKAi-bpzDevgswx