]> Cypherpunks repositories - gostls13.git/commit
cmd/compile,cmd/preprofile: move logic to shared common package
authorMichael Pratt <mpratt@google.com>
Mon, 4 Mar 2024 18:29:39 +0000 (13:29 -0500)
committerGopher Robot <gobot@golang.org>
Wed, 27 Mar 2024 20:20:01 +0000 (20:20 +0000)
commit63deaf00ea6058d1422f0b435e475666cba5743e
tree20ea11d36b1c627fd99993ea6eaff8835e698ffc
parent2860e01853174e278900ef6907b1941b16fb1645
cmd/compile,cmd/preprofile: move logic to shared common package

The processing performed in cmd/preprofile is a simple version of the
same initial processing performed by cmd/compile/internal/pgo. Refactor
this processing into the new IR-independent cmd/internal/pgo package.

Now cmd/preprofile and cmd/compile run the same code for initial
processing of a pprof profile, guaranteeing that they always stay in
sync.

Since it is now trivial, this CL makes one change to the serialization
format: the entries are ordered by weight. This allows us to avoid
sorting ByWeight on deserialization.

Impact on PGO parsing when compiling cmd/compile with PGO:

* Without preprocessing: PGO parsing ~13.7% of CPU time
* With preprocessing (unsorted): ~2.9% of CPU time (sorting ~1.7%)
* With preprocessing (sorted): ~1.3% of CPU time

The remaining 1.3% of CPU time approximately breaks down as:

* ~0.5% parsing the preprocessed profile
* ~0.7% building weighted IR call graph
  * ~0.5% walking function IR to find direct calls
  * ~0.2% performing lookups for indirect calls targets

For #58102.

Change-Id: Iaba425ea30b063ca195fb2f7b29342961c8a64c2
Reviewed-on: https://go-review.googlesource.com/c/go/+/569337
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Michael Pratt <mpratt@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
16 files changed:
src/cmd/compile/internal/devirtualize/pgo_test.go
src/cmd/compile/internal/inline/inl.go
src/cmd/compile/internal/pgo/irgraph.go
src/cmd/compile/internal/test/testdata/pgo/devirtualize/devirt.pprof.node_map
src/cmd/compile/internal/test/testdata/pgo/inline/inline_hot.pprof.node_map
src/cmd/dist/buildtool.go
src/cmd/internal/pgo/deserialize.go [new file with mode: 0644]
src/cmd/internal/pgo/pgo.go [new file with mode: 0644]
src/cmd/internal/pgo/pprof.go [new file with mode: 0644]
src/cmd/internal/pgo/serialize.go [new file with mode: 0644]
src/cmd/internal/pgo/serialize_test.go [new file with mode: 0644]
src/cmd/internal/pgo/testdata/fuzz/FuzzRoundTrip/12fcf136fcb7463c [new file with mode: 0644]
src/cmd/internal/pgo/testdata/fuzz/FuzzRoundTrip/2055d314024c8d6c [new file with mode: 0644]
src/cmd/internal/pgo/testdata/fuzz/FuzzRoundTrip/b615162315f7b72c [new file with mode: 0644]
src/cmd/internal/pgo/testdata/fuzz/FuzzRoundTrip/fdc60117b431bbae [new file with mode: 0644]
src/cmd/preprofile/main.go