berry-lang / berry

A ultra-lightweight embedded scripting language optimized for microcontrollers.
https://berry-lang.github.io
MIT License
782 stars 95 forks source link

Evaluate Profile-Guided Optimization (PGO) and LLVM BOLT #367

Open zamazan4ik opened 9 months ago

zamazan4ik commented 9 months ago

Hi!

Recently I did many Profile-Guided Optimization (PGO) benchmarks on multiple projects (including interpreters and compilers like CPython, Rustc, Clang, GCC, and many others) - the results are available here. So that's why I think it's worth trying to apply PGO to Berry tooling.

I can suggest the following things to do:

Here are some examples of how PGO is already integrated into other projects' build scripts:

After PGO, I can suggest evaluating LLVM BOLT as an additional optimization step after PGO.

skiars commented 8 months ago

This should be able to be added once CMake build scripts #370 are supported? I'm not going to do this in Makefile because CMake is better.

zamazan4ik commented 8 months ago

This should be able to be added once CMake build scripts https://github.com/berry-lang/berry/issues/370 are supported? I'm not going to do this in Makefile because CMake is better.

If you are talking about integrating PGO build mode directly to the build scripts - yeah, it could be integrated directly into the CMake scripts. As an example, you can look at the following projects:

However, you can add PGO support even without CMake (e.g. via a dedicated Makefile command) - it's all up to you.

skiars commented 8 months ago

I want to do it in CMake because it's cross-platform and can generate Makefiles.