umijs / mako

An extremely fast, production-grade web bundler based on Rust.
https://makojs.dev
MIT License
1.68k stars 63 forks source link

Evaluate using Profile-Guided Optimization (PGO) #1380

Open zamazan4ik opened 1 month ago

zamazan4ik commented 1 month ago

Hi!

A few days ago I found the website about Mako - as far as I see, the project tries to deliver peak performance. Recently I checked Profile-Guided Optimization (PGO) improvements on multiple projects including many projects with different parsers. The results are available here. Since PGO helped in many cases, I think it will be a good idea to try optimizing Mako by applying PGO to it.

I can suggest the following things to do:

For the Rust projects, I suggest trying to start with cargo-pgo.

Here you can find different materials about PGO: benchmarks in different software, examples of how PGO is already integrated with different projects, PGO support in multiple Rust compilers, and some PGO-related pieces of advice.

After PGO, I suggest evaluating the LLVM BOLT optimizer - it can give more aggressive optimizations even after PGO. However, starting with regular PGO will be easier to do.

I would be happy to answer all your questions about PGO!

P.S. It's just an improvement idea for the project. Created the Issue since Discussions are disabled for the repository.

stormslowly commented 1 month ago

@zamazan4ik i tried below steps, no profdata was generated

cargo clean
cargo pgo instrument run  path_to_a_benchmark_project  --mode production
find target  -name '*.profdata'  # nothing  found

is there any mistake in the steps? You can reproduce the that by replacing path_to_a_benchmark_project with the path of examples/with-antd in the repo.

zamazan4ik commented 1 month ago

is there any mistake in the steps?

.profdata files are automatically generated by cargo-pgo during the PGO optimization phase. In your case above, only instrumentation is done. I suppose you still got PGO profiles but they have "raw" file format - .profraw. Could you please check the target directory? You should find PGO profiles in the target/pgo-profiles directory.

If profiles still don't exist - I will try to reproduce it locally.