Repository: google/pprof
Pull request #781 (2023-05-08 16:36:30)

Made non-D3 flamegraph view the default.
In preparation for removing the dependency on D3 make the new flamegraph view the default. The old view is still available under /flamegraphold for now.

codecov-commenter: ## [Codecov](https://app.codecov.io/gh/google/pprof/pull/781?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=google) Report
> Merging [#781](https://app.codecov.io/gh/google/pprof/pull/781?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=google) (b15a3e1) into [main](https://app.codecov.io/gh/google/pprof/commit/ae9796fbfa6f03a28b140fdb1c357caa70ef5839?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=google) (ae9796f) will **decrease** coverage by `0.45%`.
> The diff coverage is `n/a`.

```diff
@@            Coverage Diff             @@
##             main     #781      +/-   ##
==========================================
- Coverage   66.74%   66.30%   -0.45%     
==========================================
  Files          45       45              
  Lines        9851     9852       +1     
==========================================
- Hits         6575     6532      -43     
- Misses       2817     2860      +43     
- Partials      459      460       +1     
```


[see 3 files with indirect coverage changes](https://app.codecov.io/gh/google/pprof/pull/781/indirect-changes?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=google)


aalexand: Will merge once the CI re-run passes.

Patch:
diff --git a/doc/README.md b/doc/README.md
index 547adb0..da481fc 100644
--- a/doc/README.md
+++ b/doc/README.md
@@ -431,15 +431,10 @@ Graph
 :   Displays a scrollable/zoomable graph view; each function (or profile entry)
     is represented by a node and edges connect callers to callees.
 
-Flame Graph
-:   Displays a [flame graph](https://www.brendangregg.com/flamegraphs.html).
-
-[Flame Graph (new)](#flame-graph)
-:   Displays a view similar to a flame graph that can show the selected node's
-    callers and callees simultaneously.
-
-    NOTE: This view is currently experimental and may eventually replace the normal
-    Flame Graph view.
+[Flame Graph](#flame-graph)
+:   Displays a view similar to a
+    [flame graph](https://www.brendangregg.com/flamegraphs.html)
+    that can show the selected node's callers and callees simultaneously.
 
 Peek
 :   Shows callers / callees per function in a simple textual forma.
@@ -473,8 +468,8 @@ prompting the user to confirm).
 
 ## Flame graph
 
-The `Flame graph (new)` view displays profile information as a
-[flame graph](https://www.brendangregg.com/flamegraphs.html).
+The `Flame graph` view displays profile information as a [flame
+graph](https://www.brendangregg.com/flamegraphs.html).
 
 Boxes on this view correspond to stack frames in the profile. Caller boxes are
 directly above callee boxes. The width of each box is proportional to the sum of
diff --git a/internal/driver/html/common.js b/internal/driver/html/common.js
index 5282c1b..1aaa5eb 100644
--- a/internal/driver/html/common.js
+++ b/internal/driver/html/common.js
@@ -682,7 +682,9 @@ function viewer(baseUrl, nodes, options) {
     toptable.addEventListener('touchstart', handleTopClick);
   }
 
-  const ids = ['topbtn', 'graphbtn', 'flamegraph', 'flamegraph2', 'peek', 'list',
+  const ids = ['topbtn', 'graphbtn',
+	       'flamegraph', 'flamegraph2', 'flamegraphold',
+	       'peek', 'list',
 	       'disasm', 'focus', 'ignore', 'hide', 'show', 'show-from'];
   ids.forEach(makeSearchLinkDynamic);
 
diff --git a/internal/driver/html/header.html b/internal/driver/html/header.html
index 39cb55a..96ad418 100644
--- a/internal/driver/html/header.html
+++ b/internal/driver/html/header.html
@@ -12,7 +12,7 @@
       <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.flamegraph2}}" href="./flamegraph2" id="flamegraph2">Flame Graph (new)</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>
diff --git a/internal/driver/webui.go b/internal/driver/webui.go
index 8881e39..41b3002 100644
--- a/internal/driver/webui.go
+++ b/internal/driver/webui.go
@@ -112,7 +112,7 @@ 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["flamegraph2"] = "Display profile as a flame graph (experimental version that can display caller info on selection)"
+	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"
 
@@ -125,15 +125,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),
-			"/flamegraph":   http.HandlerFunc(ui.flamegraph),
-			"/flamegraph2":  http.HandlerFunc(ui.stackView), // Experimental
-			"/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),
+			"/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),
 			"/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")


Test patch:
diff --git a/internal/driver/webui_test.go b/internal/driver/webui_test.go
index fe4f0a9..ea51801 100644
--- a/internal/driver/webui_test.go
+++ b/internal/driver/webui_test.go
@@ -91,7 +91,7 @@ func TestWebInterface(t *testing.T) {
 			[]string{"300ms.*F1", "200ms.*300ms.*F2"}, false},
 		{"/disasm?f=" + url.QueryEscape("F[12]"),
 			[]string{"f1:asm", "f2:asm"}, false},
-		{"/flamegraph", []string{
+		{"/flamegraphold", []string{
 			"File: testbin",
 			// Check profile frame JSON is included.
 			`\\u0022n\\u0022:\\u0022root\\u0022`,
@@ -101,7 +101,7 @@ func TestWebInterface(t *testing.T) {
 			// Check d3-flame-graph CSS is included.
 			".d3-flame-graph rect {",
 		}, false},
-		{"/flamegraph2", []string{
+		{"/flamegraph", []string{
 			"File: testbin",
 			// Check that interesting frames are included.
 			`\bF1\b`,