bytecodealliance / jco

JavaScript toolchain for working with WebAssembly Components
https://bytecodealliance.github.io/jco/
Apache License 2.0
639 stars 63 forks source link

Add support for `winliner`-based PGO #217

Open yoshuawuyts opened 1 year ago

yoshuawuyts commented 1 year ago

The winliner crate adds support to WASM for Profile Guided Optimization. It would be great if jco was able to provide an integration with winliner to compile with PGO enabled, run the profiler, and then rebuild using the captured profile. I believe we're already providing some optimizations for size and speed via binaryen. And I believe this should be mostly in line with that.

The reason why I'm suggesting we include it here, rather than say componentize-js, is because I believe this would work best if the following lines was possible:

$ jco run <my-component> --instrument # outputs profile.json
$ jco opt --profile=profile.json      # optimize using the generated profile.json 

This is not a priority, but I saw winliner come by yesterday, and PGO-based optimization seemed like it would be worth eventually including. Thanks!

guybedford commented 1 year ago

This is a really interesting idea! The benefits of it being JS-ecosystem-focused being that JS developers or build tools don't need to separately install or depend on native tools and that we can more directly link the profiling collection to the profiling optimization.

Could definitely be worth investigating after the preview2 freeze.