summaryrefslogtreecommitdiff
path: root/internal/flamegraph
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2026-03-06 14:33:52 +0200
committerPaul Buetow <paul@buetow.org>2026-03-06 14:33:52 +0200
commit3e08a3d199fdf603b7c0a4002ca9822b6ecf2575 (patch)
tree7e096a07cc515ffc18f0eca308819e8162df1d60 /internal/flamegraph
parentaa4f638206b9b79de267f9a1daab7ec6698b241d (diff)
flamegraph: make esc undo one zoom level and aggregate syscalls by default
Diffstat (limited to 'internal/flamegraph')
-rw-r--r--internal/flamegraph/livehtml.go7
-rw-r--r--internal/flamegraph/livehtml_browser_test.go2
-rw-r--r--internal/flamegraph/livehtml_interaction_test.go2
-rw-r--r--internal/flamegraph/livetrie_test.go33
4 files changed, 39 insertions, 5 deletions
diff --git a/internal/flamegraph/livehtml.go b/internal/flamegraph/livehtml.go
index 90a6d3d..71b955e 100644
--- a/internal/flamegraph/livehtml.go
+++ b/internal/flamegraph/livehtml.go
@@ -116,7 +116,7 @@ const liveHTML = `<!doctype html>
<button id="btn-undo-zoom" type="button">Undo Zoom</button>
<button id="btn-reset-zoom" type="button">Reset Zoom</button>
<button id="btn-reset-baseline" type="button">Reset Baseline</button>
- <button id="btn-toggle-order" class="order-toggle" type="button">Order: comm > path > tracepoint</button>
+ <button id="btn-toggle-order" class="order-toggle" type="button">Order: comm > tracepoint > path</button>
<span id="status">LIVE</span>
</div>
@@ -146,10 +146,11 @@ const liveHTML = `<!doctype html>
resetBaselineBtn: document.getElementById('btn-reset-baseline'),
toggleOrderBtn: document.getElementById('btn-toggle-order'),
orderPresets: [
- 'comm,path,tracepoint',
+ 'comm,tracepoint,path',
'path,tracepoint,comm',
'tracepoint,comm,path',
- 'pid,path,tracepoint'
+ 'pid,tracepoint,path',
+ 'comm,path,tracepoint'
],
orderIndex: 0,
cfg: {
diff --git a/internal/flamegraph/livehtml_browser_test.go b/internal/flamegraph/livehtml_browser_test.go
index c7a16c7..10252a9 100644
--- a/internal/flamegraph/livehtml_browser_test.go
+++ b/internal/flamegraph/livehtml_browser_test.go
@@ -166,7 +166,7 @@ global.prompt = function(){ return ""; };
global.fetch = function() {
return Promise.resolve({
ok: true,
- json: function() { return Promise.resolve({ fields: ["comm", "path", "tracepoint"], snapshot: { n: "", v: 0, t: 0 } }); },
+ json: function() { return Promise.resolve({ fields: ["comm", "tracepoint", "path"], snapshot: { n: "", v: 0, t: 0 } }); },
text: function() { return Promise.resolve("{\"n\":\"\",\"v\":0,\"t\":0}"); }
});
};
diff --git a/internal/flamegraph/livehtml_interaction_test.go b/internal/flamegraph/livehtml_interaction_test.go
index 0de1466..4c947f5 100644
--- a/internal/flamegraph/livehtml_interaction_test.go
+++ b/internal/flamegraph/livehtml_interaction_test.go
@@ -574,7 +574,7 @@ global.prompt = function(){ return ""; };
global.fetch = function() {
return Promise.resolve({
ok: true,
- json: function() { return Promise.resolve({ fields: ["comm", "path", "tracepoint"], snapshot: { n: "", v: 0, t: 0 } }); },
+ json: function() { return Promise.resolve({ fields: ["comm", "tracepoint", "path"], snapshot: { n: "", v: 0, t: 0 } }); },
text: function() { return Promise.resolve("{\"n\":\"\",\"v\":0,\"t\":0}"); }
});
};
diff --git a/internal/flamegraph/livetrie_test.go b/internal/flamegraph/livetrie_test.go
index c5ed32c..71f645c 100644
--- a/internal/flamegraph/livetrie_test.go
+++ b/internal/flamegraph/livetrie_test.go
@@ -48,6 +48,39 @@ func TestLiveTrieIngestIsAdditive(t *testing.T) {
}
}
+func TestLiveTrieCommTracepointPathAggregatesSameSyscallAcrossPaths(t *testing.T) {
+ lt := NewLiveTrie([]string{"comm", "tracepoint", "path"}, "count")
+ lt.AddRecord(IterRecord{
+ Path: "/srv/a",
+ TraceID: types.SYS_ENTER_READ,
+ Comm: "svc",
+ Pid: 1001,
+ Tid: 1001,
+ Cnt: Counter{Count: 1},
+ })
+ lt.AddRecord(IterRecord{
+ Path: "/srv/b",
+ TraceID: types.SYS_ENTER_READ,
+ Comm: "svc",
+ Pid: 1002,
+ Tid: 1002,
+ Cnt: Counter{Count: 1},
+ })
+
+ snap := decodeLiveSnapshot(t, lt)
+ commNode := findSnapshotPath(t, &snap, "svc")
+ if len(commNode.Children) != 1 {
+ t.Fatalf("expected one syscall child under comm node, got %d", len(commNode.Children))
+ }
+ syscallNode := commNode.Children[0]
+ if got, want := syscallNode.Name, "enter_read"; got != want {
+ t.Fatalf("syscall child name = %q, want %q", got, want)
+ }
+ if got, want := syscallNode.Total, uint64(2); got != want {
+ t.Fatalf("syscall aggregate total = %d, want %d", got, want)
+ }
+}
+
func TestLiveTrieVersionIncrementsPerIngest(t *testing.T) {
lt := NewLiveTrie([]string{"comm"}, "count")
if got := lt.Version(); got != 0 {