It just crossed my mind that it would be very nice if Julia provided some kind of profile-guided optimization (PGO) API.
Something like:
-
The user gathers a performance profile for some of their Julia code
-
The user is now able to request a recompilation of their Julia code, feeding the profile to the Julia compiler to enable better optimizations, like, for example, control height reduction or hot-cold splitting.
Step 2 could look like this:
pgo_anonymous_function = recompile_with_pgo(my_function, (ArgType1, ArgType2, ...), my_profile)
# Now `pgo_anonymous_function` may be used as a more performant version of `my_function`!
The nice thing (I think) is that LLVM already supports PGO, so I guess this would mostly be a matter of expanding the profiling functionality and plugging into LLVM, and then just letting LLVM take care of the optimization?
Has this been considered already? Is it really such a low-hanging fruit like it seems? Perhaps this could even be implemented as a package outside the standard library?