Skip to content

Commit

Permalink
Remove old d3 flamegraph code and d3 dependency.
Browse files Browse the repository at this point in the history
Fixes #777.
  • Loading branch information
aalexand committed Dec 17, 2023
1 parent ec68065 commit f69f379
Show file tree
Hide file tree
Showing 17 changed files with 14 additions and 1,764 deletions.
106 changes: 0 additions & 106 deletions internal/driver/flamegraph.go

This file was deleted.

2 changes: 1 addition & 1 deletion internal/driver/html/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -678,7 +678,7 @@ function viewer(baseUrl, nodes, options) {
}

const ids = ['topbtn', 'graphbtn',
'flamegraph', 'flamegraph2', 'flamegraphold',
'flamegraph',
'peek', 'list',
'disasm', 'focus', 'ignore', 'hide', 'show', 'show-from'];
ids.forEach(makeSearchLinkDynamic);
Expand Down
103 changes: 0 additions & 103 deletions internal/driver/html/flamegraph.html

This file was deleted.

1 change: 0 additions & 1 deletion internal/driver/html/header.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ <h1><a href="./">pprof</a></h1>
<a title="{{.Help.top}}" href="./top" id="topbtn">Top</a>
<a title="{{.Help.graph}}" href="./" id="graphbtn">Graph</a>
<a title="{{.Help.flamegraph}}" href="./flamegraph" id="flamegraph">Flame Graph</a>
<a title="{{.Help.flamegraphold}}" href="./flamegraphold" id="flamegraphold">Flame Graph (old)</a>
<a title="{{.Help.peek}}" href="./peek" id="peek">Peek</a>
<a title="{{.Help.list}}" href="./source" id="list">Source</a>
<a title="{{.Help.disasm}}" href="./disasm" id="disasm">Disassemble</a>
Expand Down
2 changes: 1 addition & 1 deletion internal/driver/stacks.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import (
"github.com/google/pprof/internal/report"
)

// stackView generates the new flamegraph view.
// stackView generates the flamegraph view.
func (ui *webInterface) stackView(w http.ResponseWriter, req *http.Request) {
// Get all data in a report.
rpt, errList := ui.makeReport(w, req, []string{"svg"}, func(cfg *config) {
Expand Down
8 changes: 1 addition & 7 deletions internal/driver/webhtml.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@ import (
"fmt"
"html/template"
"os"

"github.com/google/pprof/third_party/d3flamegraph"
)

//go:embed html
Expand Down Expand Up @@ -52,10 +50,6 @@ func addTemplates(templates *template.Template) {
template.Must(templates.AddParseTree(name, sub.Tree))
}

// Pre-packaged third-party files.
def("d3flamegraphscript", d3flamegraph.JSSource)
def("d3flamegraphcss", d3flamegraph.CSSSource)

// Embedded files.
def("css", loadCSS("html/common.css"))
def("header", loadFile("html/header.html"))
Expand All @@ -64,7 +58,7 @@ func addTemplates(templates *template.Template) {
def("top", loadFile("html/top.html"))
def("sourcelisting", loadFile("html/source.html"))
def("plaintext", loadFile("html/plaintext.html"))
def("flamegraph", loadFile("html/flamegraph.html"))
// TODO: Rename "stacks" to "flamegraph" to seal moving off d3 flamegraph.
def("stacks", loadFile("html/stacks.html"))
def("stacks_css", loadCSS("html/stacks.css"))
def("stacks_js", loadJS("html/stacks.js"))
Expand Down
21 changes: 10 additions & 11 deletions internal/driver/webui.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,6 @@ func serveWebInterface(hostport string, p *profile.Profile, o *plugin.Options, d
ui.help["details"] = "Show information about the profile and this view"
ui.help["graph"] = "Display profile as a directed graph"
ui.help["flamegraph"] = "Display profile as a flame graph"
ui.help["flamegraphold"] = "Display profile as a flame graph (old version; slated for removal)"
ui.help["reset"] = "Show the entire profile"
ui.help["save_config"] = "Save current settings"

Expand All @@ -125,16 +124,16 @@ func serveWebInterface(hostport string, p *profile.Profile, o *plugin.Options, d
Host: host,
Port: port,
Handlers: map[string]http.Handler{
"/": http.HandlerFunc(ui.dot),
"/top": http.HandlerFunc(ui.top),
"/disasm": http.HandlerFunc(ui.disasm),
"/source": http.HandlerFunc(ui.source),
"/peek": http.HandlerFunc(ui.peek),
"/flamegraphold": http.HandlerFunc(ui.flamegraph),
"/flamegraph": http.HandlerFunc(ui.stackView),
"/flamegraph2": http.HandlerFunc(ui.stackView), // Support older URL
"/saveconfig": http.HandlerFunc(ui.saveConfig),
"/deleteconfig": http.HandlerFunc(ui.deleteConfig),
"/": http.HandlerFunc(ui.dot),
"/top": http.HandlerFunc(ui.top),
"/disasm": http.HandlerFunc(ui.disasm),
"/source": http.HandlerFunc(ui.source),
"/peek": http.HandlerFunc(ui.peek),
"/flamegraph": http.HandlerFunc(ui.stackView),
// TODO: Remove supporting this older flamegraph2 URL at some point.
"/flamegraph2": http.HandlerFunc(ui.stackView),
"/saveconfig": http.HandlerFunc(ui.saveConfig),
"/deleteconfig": http.HandlerFunc(ui.deleteConfig),
"/download": http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) {
w.Header().Set("Content-Type", "application/vnd.google.protobuf+gzip")
w.Header().Set("Content-Disposition", "attachment;filename=profile.pb.gz")
Expand Down
12 changes: 1 addition & 11 deletions internal/driver/webui_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,16 +91,6 @@ func TestWebInterface(t *testing.T) {
[]string{"300ms.*F1", "200ms.*300ms.*F2"}, false},
{"/disasm?f=" + url.QueryEscape("F[12]"),
[]string{"f1:asm", "f2:asm"}, false},
{"/flamegraphold", []string{
"File: testbin",
// Check profile frame JSON is included.
`\\u0022n\\u0022:\\u0022root\\u0022`,
`\\u0022n\\u0022:\\u0022F1\\u0022`,
// Check d3-flame-graph JS is included.
`flamegraph:\(\)=>|flamegraph.*function|function.*flamegraph`,
// Check d3-flame-graph CSS is included.
".d3-flame-graph rect {",
}, false},
{"/flamegraph", []string{
"File: testbin",
// Check that interesting frames are included.
Expand Down Expand Up @@ -313,7 +303,7 @@ func TestIsLocalHost(t *testing.T) {
}

func BenchmarkTop(b *testing.B) { benchmarkURL(b, "/top", false) }
func BenchmarkFlame(b *testing.B) { benchmarkURL(b, "/flamegraph2", false) }
func BenchmarkFlame(b *testing.B) { benchmarkURL(b, "/flamegraph", false) }
func BenchmarkDot(b *testing.B) { benchmarkURL(b, "/", true) }

func benchmarkURL(b *testing.B, path string, needDot bool) {
Expand Down
Loading

0 comments on commit f69f379

Please sign in to comment.