1
0
mirror of https://github.com/golang/go synced 2024-11-22 16:25:07 -07:00

cmd/pprof: update vendored github.com/google/pprof

Pull in the latest published version of github.com/google/pprof
as part of the continuous process of keeping Go's dependencies
up to date.

For #36905.

[git-generate]
cd src/cmd
go get github.com/google/pprof@v0.0.0-20240722153945-304e4f0156b8
go mod tidy
go mod vendor

Change-Id: If009cff7f2d99ec58315102963cbe07b6739c09a
Reviewed-on: https://go-review.googlesource.com/c/go/+/600596
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Auto-Submit: Dmitri Shuralyov <dmitshur@google.com>
This commit is contained in:
Dmitri Shuralyov 2024-07-23 17:38:32 -04:00 committed by Gopher Robot
parent 0d5fc4e1f0
commit d55253f5dd
9 changed files with 48 additions and 26 deletions

View File

@ -3,7 +3,7 @@ module cmd
go 1.24
require (
github.com/google/pprof v0.0.0-20240528025155-186aa0362fba
github.com/google/pprof v0.0.0-20240722153945-304e4f0156b8
golang.org/x/arch v0.8.1-0.20240716161256-b863392466ea
golang.org/x/build v0.0.0-20240722200705-b9910f320300
golang.org/x/mod v0.19.1-0.20240718175220-b56a28f8bd83

View File

@ -1,7 +1,7 @@
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
github.com/google/pprof v0.0.0-20240528025155-186aa0362fba h1:ql1qNgCyOB7iAEk8JTNM+zJrgIbnyCKX/wdlyPufP5g=
github.com/google/pprof v0.0.0-20240528025155-186aa0362fba/go.mod h1:K1liHPHnj73Fdn/EKuT8nrFqBihUSKXoLYU0BuatOYo=
github.com/google/pprof v0.0.0-20240722153945-304e4f0156b8 h1:ssNFCCVmib/GQSzx3uCWyfMgOamLGWuGqlMS77Y1m3Y=
github.com/google/pprof v0.0.0-20240722153945-304e4f0156b8/go.mod h1:K1liHPHnj73Fdn/EKuT8nrFqBihUSKXoLYU0BuatOYo=
github.com/ianlancetaylor/demangle v0.0.0-20240312041847-bd984b5ce465 h1:KwWnWVWCNtNq/ewIX7HIKnELmEx2nDP42yskD/pi7QE=
github.com/ianlancetaylor/demangle v0.0.0-20240312041847-bd984b5ce465/go.mod h1:gx7rwoVhcfuVKG5uya9Hs3Sxj7EIvldVofAWIUtGouw=
github.com/yuin/goldmark v1.6.0 h1:boZcn2GTjpsynOsC0iJHnBWa4Bi0qzfJjthwauItG68=

View File

@ -52,7 +52,6 @@ a {
}
#detailsbox {
display: none;
z-index: 1;
position: fixed;
top: 40px;
right: 20px;
@ -107,7 +106,6 @@ a {
}
.submenu {
display: none;
z-index: 1;
margin-top: -4px;
min-width: 10em;
position: absolute;
@ -169,8 +167,6 @@ a {
top: 60px;
left: 50%;
transform: translateX(-50%);
z-index: 3;
font-size: 125%;
background-color: #ffffff;
box-shadow: 0 1px 5px rgba(0,0,0,.3);
@ -271,3 +267,9 @@ table tr td {
background-color: #ebf5fb;
font-weight: bold;
}
/* stacking order */
.boxtext { z-index: 2; } /* flame graph box text */
#current-details { z-index: 2; } /* flame graph current box info */
#detailsbox { z-index: 3; } /* profile details */
.submenu { z-index: 4; }
.dialog { z-index: 5; }

View File

@ -19,7 +19,6 @@ body {
position: absolute;
top: 5px;
right: 5px;
z-index: 2;
font-size: 12pt;
}
/* Background of a single flame-graph frame */
@ -57,8 +56,6 @@ body {
font-size: 12pt;
font-weight: bold;
}
/* Ensure that pprof menu is above boxes */
.submenu { z-index: 3; }
/* Right-click menu */
#action-menu {
max-width: 15em;

View File

@ -436,13 +436,29 @@ function stackViewer(stacks, nodes) {
r.appendChild(t);
}
r.addEventListener('click', () => { switchPivots(pprofQuoteMeta(src.UniqueName)); });
onClick(r, () => { switchPivots(pprofQuoteMeta(src.UniqueName)); });
r.addEventListener('mouseenter', () => { handleEnter(box, r); });
r.addEventListener('mouseleave', () => { handleLeave(box); });
r.addEventListener('contextmenu', (e) => { showActionMenu(e, box); });
return r;
}
// Handle clicks, but only if the mouse did not move during the click.
function onClick(target, handler) {
// Disable click if mouse moves more than threshold pixels since mousedown.
const threshold = 3;
let [x, y] = [-1, -1];
target.addEventListener('mousedown', (e) => {
[x, y] = [e.clientX, e.clientY];
});
target.addEventListener('click', (e) => {
if (Math.abs(e.clientX - x) <= threshold &&
Math.abs(e.clientY - y) <= threshold) {
handler();
}
});
}
function drawSep(y, posTotal, negTotal) {
const m = document.createElement('div');
m.innerText = summary(posTotal, negTotal);

View File

@ -20,7 +20,6 @@ import (
"net/http"
"github.com/google/pprof/internal/measurement"
"github.com/google/pprof/internal/report"
)
// stackView generates the flamegraph view.
@ -51,8 +50,7 @@ func (ui *webInterface) stackView(w http.ResponseWriter, req *http.Request) {
}
nodes[0] = "" // root is not a real node
_, legend := report.TextItems(rpt)
ui.render(w, req, "stacks", rpt, errList, legend, webArgs{
ui.render(w, req, "stacks", rpt, errList, stacks.Legend(), webArgs{
Stacks: template.JS(b),
Nodes: nodes,
UnitDefs: measurement.UnitTypes,

View File

@ -781,7 +781,7 @@ type TextItem struct {
func TextItems(rpt *Report) ([]TextItem, []string) {
g, origCount, droppedNodes, _ := rpt.newTrimmedGraph()
rpt.selectOutputUnit(g)
labels := reportLabels(rpt, g, origCount, droppedNodes, 0, false)
labels := reportLabels(rpt, graphTotal(g), len(g.Nodes), origCount, droppedNodes, 0, false)
var items []TextItem
var flatSum int64
@ -1064,7 +1064,7 @@ func printTree(w io.Writer, rpt *Report) error {
g, origCount, droppedNodes, _ := rpt.newTrimmedGraph()
rpt.selectOutputUnit(g)
fmt.Fprintln(w, strings.Join(reportLabels(rpt, g, origCount, droppedNodes, 0, false), "\n"))
fmt.Fprintln(w, strings.Join(reportLabels(rpt, graphTotal(g), len(g.Nodes), origCount, droppedNodes, 0, false), "\n"))
fmt.Fprintln(w, separator)
fmt.Fprintln(w, legend)
@ -1128,7 +1128,7 @@ func printTree(w io.Writer, rpt *Report) error {
func GetDOT(rpt *Report) (*graph.Graph, *graph.DotConfig) {
g, origCount, droppedNodes, droppedEdges := rpt.newTrimmedGraph()
rpt.selectOutputUnit(g)
labels := reportLabels(rpt, g, origCount, droppedNodes, droppedEdges, true)
labels := reportLabels(rpt, graphTotal(g), len(g.Nodes), origCount, droppedNodes, droppedEdges, true)
c := &graph.DotConfig{
Title: rpt.options.Title,
@ -1184,12 +1184,19 @@ func ProfileLabels(rpt *Report) []string {
return label
}
func graphTotal(g *graph.Graph) int64 {
var total int64
for _, n := range g.Nodes {
total += n.FlatValue()
}
return total
}
// reportLabels returns printable labels for a report. Includes
// profileLabels.
func reportLabels(rpt *Report, g *graph.Graph, origCount, droppedNodes, droppedEdges int, fullHeaders bool) []string {
func reportLabels(rpt *Report, shownTotal int64, nodeCount, origCount, droppedNodes, droppedEdges int, fullHeaders bool) []string {
nodeFraction := rpt.options.NodeFraction
edgeFraction := rpt.options.EdgeFraction
nodeCount := len(g.Nodes)
var label []string
if len(rpt.options.ProfileLabels) > 0 {
@ -1198,17 +1205,12 @@ func reportLabels(rpt *Report, g *graph.Graph, origCount, droppedNodes, droppedE
label = ProfileLabels(rpt)
}
var flatSum int64
for _, n := range g.Nodes {
flatSum = flatSum + n.FlatValue()
}
if len(rpt.options.ActiveFilters) > 0 {
activeFilters := legendActiveFilters(rpt.options.ActiveFilters)
label = append(label, activeFilters...)
}
label = append(label, fmt.Sprintf("Showing nodes accounting for %s, %s of %s total", rpt.formatValue(flatSum), strings.TrimSpace(measurement.Percentage(flatSum, rpt.total)), rpt.formatValue(rpt.total)))
label = append(label, fmt.Sprintf("Showing nodes accounting for %s, %s of %s total", rpt.formatValue(shownTotal), strings.TrimSpace(measurement.Percentage(shownTotal, rpt.total)), rpt.formatValue(rpt.total)))
if rpt.total != 0 {
if droppedNodes > 0 {

View File

@ -34,6 +34,7 @@ type StackSet struct {
Unit string // One of "B", "s", "GCU", or "" (if unknown)
Stacks []Stack // List of stored stacks
Sources []StackSource // Mapping from source index to info
report *Report
}
// Stack holds a single stack instance.
@ -94,6 +95,7 @@ func (rpt *Report) Stacks() StackSet {
Unit: unit,
Stacks: []Stack{}, // Ensure non-nil
Sources: []StackSource{}, // Ensure non-nil
report: rpt,
}
s.makeInitialStacks(rpt)
s.fillPlaces()
@ -187,3 +189,8 @@ func (s *StackSet) assignColors() {
s.Sources[i].Color = int(index % numColors)
}
}
// Legend returns the list of lines to display as the legend.
func (s *StackSet) Legend() []string {
return reportLabels(s.report, s.report.total, len(s.Sources), len(s.Sources), 0, 0, false)
}

View File

@ -1,4 +1,4 @@
# github.com/google/pprof v0.0.0-20240528025155-186aa0362fba
# github.com/google/pprof v0.0.0-20240722153945-304e4f0156b8
## explicit; go 1.19
github.com/google/pprof/driver
github.com/google/pprof/internal/binutils