From 281a433b9ff39c0b290adfc901bdf47cc486491f Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Fri, 27 Feb 2026 21:50:08 +0200 Subject: flags: change default flamegraph order to comm-first --- README.md | 4 +++- internal/flags/flags.go | 2 +- internal/flags/flags_test.go | 14 ++++++++++++++ internal/flamegraph/nativesvg.go | 2 +- 4 files changed, 19 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 19282f7..08775aa 100644 --- a/README.md +++ b/README.md @@ -60,9 +60,11 @@ sudo cp -v ./libelf/libelf.a /usr/lib64/ ## Native Flamegraph Generation Flamegraphs are generated natively by `ior` from `.ior.zst` data files; no external flamegraph tool is required. +When `-fields` is omitted, the default stack order is `comm,path,tracepoint` (bottom to top). +To change grouping order, pass `-fields` explicitly in the desired order. ```sh -./ior -ior=trace.ior.zst -fields=pid,path,tracepoint -count=count +./ior -ior=trace.ior.zst -fields=comm,path,tracepoint -count=count ``` This generates an SVG and starts an embedded web server. The terminal prints a URL like: diff --git a/internal/flags/flags.go b/internal/flags/flags.go index dccbe0d..8785ea9 100644 --- a/internal/flags/flags.go +++ b/internal/flags/flags.go @@ -144,7 +144,7 @@ func parse() { // If future kernels regress, add targeted exclusions here. if *fields == "" { - singleton.CollapsedFields = []string{"pid", "path", "tracepoint"} + singleton.CollapsedFields = []string{"comm", "path", "tracepoint"} } else { singleton.CollapsedFields = strings.Split(*fields, ",") } diff --git a/internal/flags/flags_test.go b/internal/flags/flags_test.go index b4d47d2..872a597 100644 --- a/internal/flags/flags_test.go +++ b/internal/flags/flags_test.go @@ -74,3 +74,17 @@ func TestParseLiveDefaults(t *testing.T) { t.Fatalf("default live interval = %v, want %v", cfg.LiveInterval, time.Second) } } + +func TestParseDefaultCollapsedFieldsOrder(t *testing.T) { + cfg := parseForTest(t) + + want := []string{"comm", "path", "tracepoint"} + if len(cfg.CollapsedFields) != len(want) { + t.Fatalf("default collapsed fields len = %d, want %d", len(cfg.CollapsedFields), len(want)) + } + for i := range want { + if cfg.CollapsedFields[i] != want[i] { + t.Fatalf("default collapsed fields[%d] = %q, want %q", i, cfg.CollapsedFields[i], want[i]) + } + } +} diff --git a/internal/flamegraph/nativesvg.go b/internal/flamegraph/nativesvg.go index 89a3e6b..8a2bcd5 100644 --- a/internal/flamegraph/nativesvg.go +++ b/internal/flamegraph/nativesvg.go @@ -12,7 +12,7 @@ import ( // // Flamegraphs are generated natively by ior from .ior.zst data files; no external // flamegraph tool is required. The CLI typically drives this via the -ior flag, -// which reads trace data, aggregates it into a trie of stack frames (e.g. pid,path,tracepoint) +// which reads trace data, aggregates it into a trie of stack frames (e.g. comm,path,tracepoint) // and renders a self-contained SVG that can be viewed in a browser. type NativeSVG struct { fields []string -- cgit v1.2.3