tectonic-typesetting / tectonic

A modernized, complete, self-contained TeX/LaTeX engine, powered by XeTeX and TeXLive.
https://tectonic-typesetting.github.io/
Other
3.91k stars 162 forks source link

Evaluate Profile-Guided Optimization (PGO) #1072

Open zamazan4ik opened 1 year ago

zamazan4ik commented 1 year 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, PHP, Ruby, and many others.) I think it could also be helpful to check PGO for the Tectonic project.

We need to perform PGO benchmarks on Tectonic. And if it shows improvements - add a note about possible improvements in Tectonic performance with PGO. Providing an easier way (e.g. a build option) to build the project with PGO can also be helpful for the maintainers and end-users. Improving performance can improve user experience with Tectonic.

For the Rust part of the project, you can try to use cargo-pgo, for the C part I think manual setting required compiler flags is needed (which exactly compiler flags - according to your compiler). For Rust you can get some inspiration e.g. from Typst process regarding PGO - https://github.com/typst/typst/issues/1733 .

pkgw commented 1 year ago

Thanks for the suggestion! Getting it to compile might indeed be a challenge, but we already have the proof-of-concept that we can build Tectonic for fuzzing, so it should be possible.

I agree that the first step would be to do some benchmarks and see what kind of improvement we might be talking about here. If it's worth pursuing, while it might be a bit of a slog to integrate PGO into the CI/CD system, that would be the way to make sure the benefits actually get realized.