janet-lang / janet

A dynamic language and bytecode vm
https://janet-lang.org
MIT License
3.37k stars 217 forks source link

Evaluate Profile-Guided Optimization (PGO) #1221

Open zamazan4ik opened 11 months ago

zamazan4ik commented 11 months ago

Hi!

Recently I checked Profile-Guided Optimization (PGO) improvements on multiple projects. The results are here.

Since PGO showed measurable improvements in compiler/interpreter-like workloads (CPython, Clang, Clangd, clang-format, GCC, Rustc, CrosVM, etc.) I think it could be useful to check PGO for the Janet project too.

We need to perform PGO benchmarks on Janet. And if it shows improvements - add a note about possible improvements in Janet VM performance with PGO. Providing an easier way (e.g. a build option) to build scripts with PGO can be useful for the end-users too.

bakpakin commented 11 months ago

Thanks for the interest here. Janet has a sort of builtin natural target for PGO in the bootstrapping process, which is just executing src/boot/boot.janet. For interpreters I imagine that anything that targets the instruction dispatch loop would be good, but other modules that I think would see big impacts are workloads that target src/core/peg.c (basically another interpreter inside the main interpreter).

Hacking the Makefile for PGO shouldn't be too difficult, but I haven't done it recently.

iacore commented 9 months ago

here's a better tutorial: Page 7 of https://llvm.org/devmtg/2020-09/slides/PGO_Instrumentation.pdf

Also https://source.android.com/docs/core/perf/pgo