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

build: use profile-guided optimization #110262

Open
nvanbenschoten opened this issue Sep 8, 2023 · 4 comments
Open

build: use profile-guided optimization #110262

nvanbenschoten opened this issue Sep 8, 2023 · 4 comments
Labels
A-build-system C-performance Perf of queries or internals. Solution not expected to change functional behavior. o-perf-efficiency Related to performance efficiency P-2 Issues/test failures with a fix SLA of 3 months T-dev-inf

Comments

@nvanbenschoten
Copy link
Member

nvanbenschoten commented Sep 8, 2023

Go 1.20 (https://tip.golang.org/doc/go1.20) added support for profile-guided optimization (PGO). Go 1.21 (https://tip.golang.org/doc/go1.21) further improves PGO and marks it as ready for general use.

PGO promises to improve the performance of Go programs:

Performance improvements vary depending on application behavior, with most programs from a representative set of Go programs seeing between 2 and 7% improvement from enabling PGO.

PGO currently achieves this by inline hot function calls, but the Go team expects it to become more capable in future releases: golang/go#62463.

Once #109773 lands, we should test out PGO and explore integrating it into our CI pipeline.

Jira issue: CRDB-31351

Epic CRDB-41952

@nvanbenschoten nvanbenschoten added C-performance Perf of queries or internals. Solution not expected to change functional behavior. A-build-system T-dev-inf labels Sep 8, 2023
@nvanbenschoten
Copy link
Member Author

Go 1.22 is expanding PGO's capabilities:

Profile-guided Optimization (PGO) builds can now devirtualize a higher proportion of calls than previously possible. Most programs from a representative set of Go programs now see between 2 and 14% improvement from enabling PGO.

@lyang24
Copy link
Contributor

lyang24 commented Jul 4, 2024

I read more about pgo its very interesting - the hard part is it needs a pprof to guide the optimization, do you have guidances on how get a proper profile?

bazel already support pgo, once i get profile i can drop into the folder that contains the main.go, and add pgoprofile = ":<profile_name>.pprof", to
https://github.com/lyang24/cockroach/blob/d0bb7e47c6649dce2d8efa0c26b999ed5d161fe6/pkg/cmd/cockroach/BUILD.bazel#L25-L30

@rickystewart
Copy link
Collaborator

rickystewart commented Jul 8, 2024

Hi @lyang24, in release-24.1 you can manually collect a profile on the Advanced Debug page or if you wish there is a method to set up automatic profiling. Here is a draft commit showing how to add profiles to the build (the profiles here are one-offs for an internal experiment that we did). You could also directly use the profiles from this commit if you like. If you do please be aware that we do not intend to merge this commit as-is and the provided profiles may not be representative and the PGO build may not be "production-ready"; your mileage may vary and this is not supported by Cockroach Labs.

Note that building with PGO is substantially slower than building without it. It also has implications for caching with respect to the build especially if you are doing development, running tests, etc.

@tbg
Copy link
Member

tbg commented Oct 30, 2024

When this gets tackled we'll also want to include a sysbench profile. (I'm happy to provide one, just DM me).

@tbg tbg added the o-perf-efficiency Related to performance efficiency label Nov 11, 2024
@tbg tbg added the P-2 Issues/test failures with a fix SLA of 3 months label Dec 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-build-system C-performance Perf of queries or internals. Solution not expected to change functional behavior. o-perf-efficiency Related to performance efficiency P-2 Issues/test failures with a fix SLA of 3 months T-dev-inf
Projects
None yet
Development

No branches or pull requests

4 participants