[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAH0uvojXcxp-GCF6JAcAvATvKjySQ_Wo5ciUfQoPotqA7+7YOA@mail.gmail.com>
Date: Tue, 5 Aug 2025 16:05:26 -0700
From: Howard Chu <howardchu95@...il.com>
To: Ian Rogers <irogers@...gle.com>
Cc: Peter Zijlstra <peterz@...radead.org>, Ingo Molnar <mingo@...hat.com>,
Arnaldo Carvalho de Melo <acme@...nel.org>, Namhyung Kim <namhyung@...nel.org>,
Mark Rutland <mark.rutland@....com>,
Alexander Shishkin <alexander.shishkin@...ux.intel.com>, Jiri Olsa <jolsa@...nel.org>,
Adrian Hunter <adrian.hunter@...el.com>, Kan Liang <kan.liang@...ux.intel.com>,
James Clark <james.clark@...aro.org>, Xu Yang <xu.yang_2@....com>,
"Masami Hiramatsu (Google)" <mhiramat@...nel.org>, Collin Funk <collin.funk1@...il.com>,
Weilin Wang <weilin.wang@...el.com>, Andi Kleen <ak@...ux.intel.com>,
"Dr. David Alan Gilbert" <linux@...blig.org>, Thomas Richter <tmricht@...ux.ibm.com>,
Tiezhu Yang <yangtiezhu@...ngson.cn>, Gautam Menghani <gautam@...ux.ibm.com>,
Thomas Falcon <thomas.falcon@...el.com>, Chun-Tse Shao <ctshao@...gle.com>,
linux-kernel@...r.kernel.org, linux-perf-users@...r.kernel.org,
Arnaldo Carvalho de Melo <acme@...hat.com>
Subject: Re: [PATCH v9 11/16] perf ilist: Add new python ilist command
Hello Ian,
On Fri, Jul 25, 2025 at 11:52 AM Ian Rogers <irogers@...gle.com> wrote:
>
> The perf ilist command is a textual app [1] similar to perf list. In
> the top-left pane a tree of PMUs is displayed. Selecting a PMU expands
> the events within it. Selecting an event displays the `perf list`
> style event information in the top-right pane.
>
> When an event is selected it is opened and the counters on each CPU
> the event is for are periodically read. The bottom of the screen
> contains a scrollable set of sparklines showing the events in total
> and on each CPU. Scrolling below the sparklines shows the same data as
> raw counts. The sparklines are small graphs where the height of the
> bar is in relation to maximum of the other counts in the graph.
>
> By default the counts are read with an interval of 0.1 seconds (10
> times per second). A -I/--interval command line option allows the
> interval to be changed. The oldest read counts are dropped when the
> counts fill the line causing the sparkline to move from right to left.
>
> A search box can be pulled up with the 's' key. 'n' and 'p' iterate
> through the search results. As some PMUs have hundreds of events a 'c'
> key will collapse the events in the current PMU to make navigating the
> PMUs easier.
Maybe display sparklines on-demand and when not displayed fill the
whole window to the left with event names, this should make
parent-child relation more obvious, and displays as many lines of
event as the classic 'perf list'.
>
> [1] https://textual.textualize.io/
>
> Signed-off-by: Ian Rogers <irogers@...gle.com>
> Tested-by: Arnaldo Carvalho de Melo <acme@...hat.com>
> ---
> tools/perf/python/ilist.py | 385 +++++++++++++++++++++++++++++++++++++
> 1 file changed, 385 insertions(+)
> create mode 100755 tools/perf/python/ilist.py
>
> diff --git a/tools/perf/python/ilist.py b/tools/perf/python/ilist.py
> new file mode 100755
> index 000000000000..22c70a8b31f3
> --- /dev/null
> +++ b/tools/perf/python/ilist.py
> @@ -0,0 +1,385 @@
> +#!/usr/bin/env python3
> +# SPDX-License-Identifier: (LGPL-2.1 OR BSD-2-Clause)
> +"""Interactive perf list."""
> +
> +import argparse
> +from typing import Any, Dict, Optional, Tuple
> +import perf
> +from textual import on
> +from textual.app import App, ComposeResult
> +from textual.binding import Binding
> +from textual.containers import Horizontal, HorizontalGroup, Vertical, VerticalScroll
> +from textual.command import SearchIcon
> +from textual.screen import ModalScreen
> +from textual.widgets import Button, Footer, Header, Input, Label, Sparkline, Static, Tree
> +from textual.widgets.tree import TreeNode
> +
> +
> +class ErrorScreen(ModalScreen[bool]):
> + """Pop up dialog for errors."""
> +
> + CSS = """
> + ErrorScreen {
> + align: center middle;
> + }
> + """
> +
> + def __init__(self, error: str):
> + self.error = error
> + super().__init__()
> +
> + def compose(self) -> ComposeResult:
> + yield Button(f"Error: {self.error}", variant="primary", id="error")
> +
> + def on_button_pressed(self, event: Button.Pressed) -> None:
> + self.dismiss(True)
> +
> +
> +class SearchScreen(ModalScreen[str]):
> + """Pop up dialog for search."""
> +
> + CSS = """
> + SearchScreen Horizontal {
> + align: center middle;
> + margin-top: 1;
> + }
> + SearchScreen Input {
> + width: 1fr;
> + }
> + """
> +
> + def compose(self) -> ComposeResult:
> + yield Horizontal(SearchIcon(), Input(placeholder="Event name"))
> +
> + def on_input_submitted(self, event: Input.Submitted) -> None:
> + """Handle the user pressing Enter in the input field."""
> + self.dismiss(event.value)
> +
> +
> +class Counter(HorizontalGroup):
> + """Two labels for a CPU and its counter value."""
> +
> + CSS = """
> + Label {
> + gutter: 1;
> + }
> + """
> +
> + def __init__(self, cpu: int) -> None:
> + self.cpu = cpu
> + super().__init__()
> +
> + def compose(self) -> ComposeResult:
> + label = f"cpu{self.cpu}" if self.cpu >= 0 else "total"
> + yield Label(label + " ")
> + yield Label("0", id=f"counter_{label}")
> +
> +
> +class CounterSparkline(HorizontalGroup):
> + """A Sparkline for a performance counter."""
> +
> + def __init__(self, cpu: int) -> None:
> + self.cpu = cpu
> + super().__init__()
> +
> + def compose(self) -> ComposeResult:
> + label = f"cpu{self.cpu}" if self.cpu >= 0 else "total"
> + yield Label(label)
> + yield Sparkline([], summary_function=max, id=f"sparkline_{label}")
> +
> +
> +class IListApp(App):
> + TITLE = "Interactive Perf List"
> +
> + BINDINGS = [
> + Binding(key="s", action="search", description="Search",
> + tooltip="Search events and PMUs"),
> + Binding(key="n", action="next", description="Next",
> + tooltip="Next search result or item"),
> + Binding(key="p", action="prev", description="Previous",
> + tooltip="Previous search result or item"),
> + Binding(key="c", action="collapse", description="Collapse",
> + tooltip="Collapse the current PMU"),
> + Binding(key="^q", action="quit", description="Quit",
> + tooltip="Quit the app"),
Some people use the terminal in vscode, where ^q is occupied, I'd
imagine for emacs users ^q is entering raw characters, so it doesn't
work in eterm either, why not just q?
Thanks,
Howard
Powered by blists - more mailing lists