]> Cypherpunks repositories - gostls13.git/commit
cmd/go: use cache for PGO preprocessing
authorMichael Pratt <mpratt@google.com>
Thu, 29 Feb 2024 21:23:03 +0000 (16:23 -0500)
committerGopher Robot <gobot@golang.org>
Thu, 18 Apr 2024 15:39:17 +0000 (15:39 +0000)
commit84fbdf01ffde21fcf0a5359d98a65dc6ee16f5a5
tree8110a89b0e85ed739e2aaa3841ac4d2cc1255b76
parent081dc9fd8c9cf824f5caac3a03a1c8dfd86894c0
cmd/go: use cache for PGO preprocessing

This is the final CL in the series adding PGO preprocessing support to
cmd/go. Now that the tool is hooked up, we integrate with the build
cache to cache the result.

This is fairly straightforward. One difference is that the compile and
link do caching through updateBuildID. However, preprocessed PGO files
don't have a build ID, so it doesn't make much sense to hack our way
through that function when it is simple to just add to the cache
ourselves.

As as aside, we could add a build ID to the preproccessed file format,
though it is not clear if it is worthwhile. The one place a build ID
could be used is in buildActionID, which currently compute the file hash
of the preprocessed profile. With a build ID it could simply read the
build ID. This would save one complete read of the file per build
(cmd/go caches the hash), but each compile process also reads the entire
file, so this is a small change overall.

Fixes #58102.

Cq-Include-Trybots: luci.golang.try:gotip-linux-amd64-longtest
Change-Id: I86e2999a08ccd264230fbb1c983192259b7288e9
Reviewed-on: https://go-review.googlesource.com/c/go/+/569425
Auto-Submit: Michael Pratt <mpratt@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
doc/next/5-toolchain.md
src/cmd/go/internal/work/action.go
src/cmd/go/internal/work/buildid.go
src/cmd/go/testdata/script/build_cache_pgo.txt [new file with mode: 0644]
src/cmd/go/testdata/script/build_pgo.txt
src/cmd/go/testdata/script/build_pgo_auto.txt
src/cmd/preprofile/main.go