server-edition
server-edition copied to clipboard
Build using PGO + LTO
In late 2017 I was investigating building Ruby using Profile Guided Optimization and Link Time Optimization. Python has support for building with PGO + LTO https://bugs.python.org/issue25702 but it's quite brittle. If Fullstaq Ruby standardised on building with a single version of GCC or Clag then it wouldn't be too hard to build using PGO + LTO (just slower) and would produce Ruby binaries which run 3-5% faster.
That is a good idea! With single version of GCC, do you mean a single version across all distributions, or a single version within the context of a single distribution? And where would the profile come from?
I think 2.4+ will all build with a recent version of GCC and there's no reason to build with older compilers anymore. The build process becomes: build instrumented code, run instumented code to generate the profile, build using profile. https://github.com/jamatthews/ruby/commit/4aefb10adc4e069c36cc0b2c359aa3a73e791970
The main problem with PGO+LTO is the crazy build times but when distributing binaries it's much less of a problem.
It's a while ago now but I saw some minor improvements of 3-5% just using the tests as a profiling task. I believe CPython uses the tests as the profiling task too. The more general the profiling task, the better. The main benefit comes from the cross-file inling from LTO, inling rb_str_free()
etc.
(sorry for necroposting) Any news? I am interested to see LTO + PGO in the upstream Ruby project. Starting with LTO is a good point (since it's easier to achieve than PGO).