Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Profile-Guided Optimization (PGO) support to the compiler #12200

Open
zamazan4ik opened this issue Apr 22, 2023 · 5 comments
Open

Add Profile-Guided Optimization (PGO) support to the compiler #12200

zamazan4ik opened this issue Apr 22, 2023 · 5 comments

Comments

@zamazan4ik
Copy link

Hi.

I have read multiple articles about attempts to add PGO (or FDO) support to Ocaml. But as far as I see, right now there is no support for PGO in AoT mode in Ocaml compiler. Do you have plans to support so? If I am wrong and PGO is already supported - could you please point me out to the documentation?

Thanks!

@xavierleroy
Copy link
Contributor

I guess those articles were from Jane Street's blog? My understanding is that Jane Street has experimental support for some profile-guided link-time optimizations in their internal fork of OCaml, but this support has not been upstreamed yet.

As far as I know, the only part that is already in the OCaml core distribution is the -function-sections option to the ocamlopt compiler, which puts each function in a separate section, so that a linker script can group "hot" functions together.

@zamazan4ik
Copy link
Author

I guess those articles were from Jane Street's blog?

Yeah, you are right: the link

@xavierleroy
Copy link
Contributor

Right. Maybe @gretay-js can tell you more. At the moment, as far as I know, some of the basic mechanisms mentioned in her talk were integrated in the core OCaml distribution, but not the tools that actually perform link-time optimizations, and I don't know whether these tools are publicly available.

@gretay-js
Copy link
Contributor

A very much out-of-date version of profile-guided layout optimization tool is available here, if you want to have a look at how it was implemented. Function reordering is implemented simply with a linker script. Basic block reordering is implemented by converting Linear IR to a CFG and then back to Linear using a different layout.

The version we use internally at Jane Street is slightly different, because we use an experimental compiler with several changes on top of OCaml 4.14 that haven't been upstreamed yet. If you want to try ocamlfdo with this experimental compiler, please let me know. Note that this version of ocamlfdo is only tested/supported on Linux/x86_64 targets.

Copy link

This issue has been open one year with no activity. Consequently, it is being marked with the "stale" label. What this means is that the issue will be automatically closed in 30 days unless more comments are added or the "stale" label is removed. Comments that provide new information on the issue are especially welcome: is it still reproducible? did it appear in other contexts? how critical is it? etc.

@github-actions github-actions bot added the Stale label May 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants