Facebook/Meta's "Bolt" optimizer for WebAssembly target

104 views
Skip to first unread message

Soeren Balko

unread,
Jan 12, 2022, 1:32:02 AM1/12/22
to emscripten-discuss
The good people at Facebook just landed their "Bolt" optimizer in LLVM:  llvm-project/bolt at main · llvm/llvm-project (github.com)

Bolt is currently limited to x86-64 and AArch64. Given the lofty performance uplift that Bolt claims to deliver, I wonder if WebAssembly would benefit from it. Any thoughts?

Thomas Lively

unread,
Jan 12, 2022, 3:27:38 AM1/12/22
to emscripte...@googlegroups.com
IIRC, Bolt reorganizes binaries to separate out cold blocks into separate code sections. A similar optimization would probably be useful in WebAssembly, but it would have to outline the cold blocks into separate functions. Alternatively, we could add some sort of hinting about cold blocks in a custom section and let the WebAssembly engine perform this optimization on the compiled code.

On Wed, Jan 12, 2022 at 01:32 Soeren Balko <soe...@clipchamp.com> wrote:
The good people at Facebook just landed their "Bolt" optimizer in LLVM:  llvm-project/bolt at main · llvm/llvm-project (github.com)

Bolt is currently limited to x86-64 and AArch64. Given the lofty performance uplift that Bolt claims to deliver, I wonder if WebAssembly would benefit from it. Any thoughts?

--
You received this message because you are subscribed to the Google Groups "emscripten-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to emscripten-disc...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/emscripten-discuss/1cd76c9b-7ea9-4fd4-9678-72b080204f5an%40googlegroups.com.

Soeren Balko

unread,
Jan 12, 2022, 10:14:37 PM1/12/22
to emscripten-discuss
Interesting, as I understand branch hinting is already WebAssembly proposal that is being worked on. Perhaps it could be use to segregate away the "cold" blocks (branches). Moving cold blocks into functions (as the only existing modularization concept in wasm) seems quite complex and possibly introduce a performance penalty when calling cold code. Also, I wonder if the (tiered) WebAssembly runtimes would even be smart enough to treat hot functions differently from cold ones. But I am really out of my depth here, not sure if any of this makes sense. 

In a more general sense: Emscripten once had PGO, which now seems to be deprecated (is it?). Are there any plans to bring it back? We've got some very specific workloads, for which we have performance profiles that we'd love to feed back into the build process.

Soeren



Thomas Lively

unread,
Jan 12, 2022, 11:15:45 PM1/12/22
to emscripte...@googlegroups.com
Yes, good point. The branch hinting proposal has a very similar goal. And yes, outlining cold blocks into separate functions has downsides, but as V8 (and maybe other engines?) move to lazy tier-up, the outlining can improve startup performance get reach peak performance sooner by reducing the amount of code that needs to be tiered up.

I know PGO is on our list of things we'd like to get to eventually, but I don't think we have any specific plans to work on it soon.

Reply all
Reply to author
Forward
0 new messages