aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Pratt <mpratt@google.com>2023-05-11 14:27:25 -0400
committerGopher Robot <gobot@golang.org>2023-05-11 20:54:03 +0000
commitd740b365b7c1ecefb91b2e2fed5719c8ec49d155 (patch)
tree81fc74a9d778dba7942f531f69a50d8db9719344
parentc2becd70c5dad379def219e60452072ab6e72617 (diff)
downloadgo-d740b365b7c1ecefb91b2e2fed5719c8ec49d155.tar.xz
cmd/compile/internal/pgo: move pprof graph to internal package
graph.go is a simplified fork of github.com/google/pprof/internal/graph, which is used as an intermediate data structure to construct the final graph exported by package pgo (IRGraph). Exporting both is a bit confusing as the former is unused outside of the package. Since the naming is also similar, move graph.go to its own package entirely. Change-Id: I2bccb3ddb6c3f63afb869ea9cf34d2a261cad058 Reviewed-on: https://go-review.googlesource.com/c/go/+/494437 Reviewed-by: Cherry Mui <cherryyz@google.com> Run-TryBot: Michael Pratt <mpratt@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Auto-Submit: Michael Pratt <mpratt@google.com>
-rw-r--r--src/cmd/compile/internal/pgo/internal/graph/graph.go (renamed from src/cmd/compile/internal/pgo/graph.go)12
-rw-r--r--src/cmd/compile/internal/pgo/irgraph.go5
2 files changed, 9 insertions, 8 deletions
diff --git a/src/cmd/compile/internal/pgo/graph.go b/src/cmd/compile/internal/pgo/internal/graph/graph.go
index a2cf18f936..72d3f2194d 100644
--- a/src/cmd/compile/internal/pgo/graph.go
+++ b/src/cmd/compile/internal/pgo/internal/graph/graph.go
@@ -12,10 +12,10 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-// Package graph collects a set of samples into a directed graph.
-
-// Original file location: https://github.com/google/pprof/tree/main/internal/graph/graph.go
-package pgo
+// Package graph represents a pprof profile as a directed graph.
+//
+// This package is a simplified fork of github.com/google/pprof/internal/graph.
+package graph
import (
"fmt"
@@ -245,8 +245,8 @@ func (e *Edge) WeightValue() int64 {
return e.Weight / e.WeightDiv
}
-// newGraph computes a graph from a profile.
-func newGraph(prof *profile.Profile, o *Options) *Graph {
+// NewGraph computes a graph from a profile.
+func NewGraph(prof *profile.Profile, o *Options) *Graph {
nodes, locationMap := CreateNodes(prof, o)
seenNode := make(map[*Node]bool)
seenEdge := make(map[nodePair]bool)
diff --git a/src/cmd/compile/internal/pgo/irgraph.go b/src/cmd/compile/internal/pgo/irgraph.go
index 42ba27afb7..4a9de2ef00 100644
--- a/src/cmd/compile/internal/pgo/irgraph.go
+++ b/src/cmd/compile/internal/pgo/irgraph.go
@@ -43,6 +43,7 @@ package pgo
import (
"cmd/compile/internal/base"
"cmd/compile/internal/ir"
+ "cmd/compile/internal/pgo/internal/graph"
"cmd/compile/internal/typecheck"
"cmd/compile/internal/types"
"fmt"
@@ -155,7 +156,7 @@ func New(profileFile string) (*Profile, error) {
return nil, fmt.Errorf(`profile does not contain a sample index with value/type "samples/count" or cpu/nanoseconds"`)
}
- g := newGraph(profile, &Options{
+ g := graph.NewGraph(profile, &graph.Options{
CallTree: false,
SampleValue: func(v []int64) int64 { return v[valueIndex] },
})
@@ -189,7 +190,7 @@ func New(profileFile string) (*Profile, error) {
// create edges for WeightedCG.
//
// Caller should ignore the profile if p.TotalNodeWeight == 0 || p.TotalEdgeWeight == 0.
-func (p *Profile) processprofileGraph(g *Graph) error {
+func (p *Profile) processprofileGraph(g *graph.Graph) error {
nFlat := make(map[string]int64)
nCum := make(map[string]int64)
seenStartLine := false