Skip to content

Conversation

@hodgesds
Copy link
Contributor

@hodgesds hodgesds commented Nov 7, 2025

Overview

Add performance counter statistics (perf stat) integration for scxtop, including TUI visualization, MCP server API, and critical bug fixes of per-process monitoring.

TUI

  • Real-time performance counter visualization with tabular and graphical views
  • Derived metrics: IPC, cache/branch miss rates, stall percentages
  • Multiple aggregation levels: system-wide, per-CPU, per-LLC, per-NUMA node
  • Historical graphs using sparklines for trend analysis
  • Integration with existing TUI navigation and key bindings

MCP Server API

  • start_perf_stat: Start performance counter collection (system-wide or per-process)
  • stop_perf_stat: Stop collection and finalize statistics
  • get_perf_stat_results: Retrieve statistics with derived metrics
  • Support for aggregation by system, CPU, LLC, NUMA node, and process
  • Historical data collection for trend analysis
  • Thread-safe SharedPerfStatCollector for concurrent access

Per-Process Monitoring Issues

  • CPU filtering bug: Process events only monitored CPU 0 → Now monitors all CPUs with cpu=-1
  • Inherit flag inverted: Child threads not tracked → Now correctly enabled for per-process monitoring

API Improvements

  • Refactored PerfEvent to use i32 for CPU parameter (matches kernel API)
  • Removed usize::MAX hack, replaced with explicit -1 for all-CPU monitoring
  • Added comprehensive documentation with parameter descriptions
  • More tests

Add a TUI view that allows for viewing aggregates of perf stat data such
as IPC, branch misses, stalls. Render both in aggregated and graphical
view.

Signed-off-by: Daniel Hodges <[email protected]>
Add methods for collecting and analyzing perf stat data via the MCP
server.

Signed-off-by: Daniel Hodges <[email protected]>
Fix the api for PerfEvent to take a i32 to follow the kernel API to
easily allow for passing in -1 (all CPUs). Update the MCP server to fix
perf event filtering for processes. Add tests for related changes.

Signed-off-by: Daniel Hodges <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant