BOLT: Binary Optimization and Layout Tool(github.com)
github.com
BOLT: Binary Optimization and Layout Tool
https://github.com/facebookincubator/BOLT
24 comments
GNU Rope never shipped but it looks like the source code is here[0].
[0] www.hungry.com/~shaver/gropt.tar.bz2
[0] www.hungry.com/~shaver/gropt.tar.bz2
Some usage description of mine: http://perl11.org/blog/bolt.html
Propeller looks much better now.
Propeller looks much better now.
I guess maybe the original version of something like this was cord and cord2, done at MIPS in the mid-80s.
http://www.bitsavers.org/pdf/mips/RISCos/3204DOC_RISC_os_Use...
I wonder if those have been open sourced.
http://www.bitsavers.org/pdf/mips/RISCos/3204DOC_RISC_os_Use...
I wonder if those have been open sourced.
The README doesn't link to the final version of their article: https://research.fb.com/publications/bolt-a-practical-binary...
I believe the version published at CGO 19 is the final version. It is longer.
https://www.ic.unicamp.br/~ra045840/bolt-cgo19.pdf
https://www.ic.unicamp.br/~ra045840/bolt-cgo19.pdf
Some discussion from two years ago: https://news.ycombinator.com/item?id=17350122
similar thing from google: http://lists.llvm.org/pipermail/llvm-dev/2019-September/1353...
> Inspired by the performance gains and to address the scalability issue of BOLT, we went about designing a scalable infrastructure that can perform BOLT-like post-link optimizations.
> Our experiments on large real-world applications and SPEC with code layout show that Propeller can optimize as effectively as BOLT, with just 20% of its memory footprint and time overhead.
> Inspired by the performance gains and to address the scalability issue of BOLT, we went about designing a scalable infrastructure that can perform BOLT-like post-link optimizations.
> Our experiments on large real-world applications and SPEC with code layout show that Propeller can optimize as effectively as BOLT, with just 20% of its memory footprint and time overhead.
One thing I really wanted to be able to do with Propeller was a post-link optimization of a Go program. Go's compiler is both fast and terrible. If you glance at the text, opportunities for simple optimizations abound. Unfortunately the layout of the program, references between the debug information and the function entry points, and Propeller having been designed for C++ programs kept me from getting very far. I did get a little ways, but not far enough that I could keep a long-running Go program from crashing.
Did you mean bolt instead of propeller? Bolt optimizes binaries, propeller is an llvm fork with extra information and a special linker.
Neither is made to do the optimizations you are talking about, that is what regular llvm does.
Neither is made to do the optimizations you are talking about, that is what regular llvm does.
Currently discussed at https://news.ycombinator.com/item?id=22655316.
Okay, I don't get it.
Why not hook this into LLVM's compiler infrastructure, instead of recovering the CFG from a binary - and not any binary, but one that has to built with special flags anyway? This seems backwards.
Why not hook this into LLVM's compiler infrastructure, instead of recovering the CFG from a binary - and not any binary, but one that has to built with special flags anyway? This seems backwards.
Because if you statically link libraries like the language runtime it allows you to reorder the blocks in those as well to improve locality and instruction cache utilization.
For example if your code calls a particular runtime function shortly after starting, that function (or the basic blocks from that function that are executed frequently) can be placed close to the call site.
For example if your code calls a particular runtime function shortly after starting, that function (or the basic blocks from that function that are executed frequently) can be placed close to the call site.
If you're statically linking, then LTO would give you cross TU visibility to do the same optimization at link time, not post link when you've lost a lot of fidelity.
Not if it’s a library that you’re not compiling, like language runtimes or system libraries.
LTO requires that you’re compiling all the code to get the benefits.
I’m also not sure if either gcc or clang’s LTO does layout at the basic block level or at the function level. There is a lot of benefit from doing it at the basic block level. You can literally lay out all the code that runs at application start time so that it is mostly adjacent and fall-through from block to block during execution.
This isn’t something you necessarily do instead of LTO, but rather something you can do in addition to it.
LTO requires that you’re compiling all the code to get the benefits.
I’m also not sure if either gcc or clang’s LTO does layout at the basic block level or at the function level. There is a lot of benefit from doing it at the basic block level. You can literally lay out all the code that runs at application start time so that it is mostly adjacent and fall-through from block to block during execution.
This isn’t something you necessarily do instead of LTO, but rather something you can do in addition to it.
[deleted]
This is the argument the authors of propeller make.
What if your binary, or one of its libraries, is not built with LLVM?
you're absolutely right. it seems like a huge number of comilers have had 'global optimization' on their todo list, but never got around to it.
i think this paper (cant find a non-paywalled copy) https://dl.acm.org/doi/10.1145/12276.13338 got around 10% just by attempting to align the allocation of the callers and the callee.
maybe memories are large enough now, and the whole proprietary binary-only library business model is gone, that we should really be abandoning the idea of seperate compilation units as the default.
i think this paper (cant find a non-paywalled copy) https://dl.acm.org/doi/10.1145/12276.13338 got around 10% just by attempting to align the allocation of the callers and the callee.
maybe memories are large enough now, and the whole proprietary binary-only library business model is gone, that we should really be abandoning the idea of seperate compilation units as the default.
Why would you use this over the profile guided optimizations that gcc and clang already offer, that use the same data?
What kind of perf benefits can you expect?
What kind of application have you tested this with?
What kind of perf benefits can you expect?
What kind of application have you tested this with?
From the paper:
"For datacenter applications, BOLT achieves up to 7.0% performance speedups on top of profile-guided function reordering and LTO."
This is used for large binaries, like hhvm. There's a lot more details here: https://research.fb.com/publications/bolt-a-practical-binary...
"For datacenter applications, BOLT achieves up to 7.0% performance speedups on top of profile-guided function reordering and LTO."
This is used for large binaries, like hhvm. There's a lot more details here: https://research.fb.com/publications/bolt-a-practical-binary...
What would it take to use this on a complete linux distro like ubuntu? Seems like it would be a respectable improvement.
I think it's a demonstrated fact that nobody cares about the out-of-the-box distro performance, because recompiling Ubuntu for your actual CPU (or anything newer than Opteron) gives large speedups on every program. Doing whole-distro PGO and LTO would be challenging because there's no one true workload upon which all users agree. An optimization for me might be bad for you. Also PGO and LTO will tend to think initialization and startup code is "cold" whereas in a thing like a shell pipeline that exec's many programs may be bottlenecked by those functions. If I profile a long-running daemon and rebuild libc with those profiles, it could make startup times slower for an exec-heavy workload.
Gentoo v2
[1] http://lwn.net/1998/1029/als/rope.html
(An aisde: I was at that talk in 1998 at Atlanta Linux Showcase and remember it fairly well. I'm the guy who asked Nat if he'd considered using a genetic algorithm for the optimization processing.)