# xinydev/telemetry-solution architecture

> Architecture diagram of the GitHub repository xinydev/telemetry-solution, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-07-18). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/xinydev/telemetry-solution
- Repository: https://github.com/xinydev/telemetry-solution

## Overview

#### Purpose and Primary Entry Points
Arm Telemetry Solution is a performance-analysis repository for Arm CPU PMUs and CMN interconnect telemetry. Its central workflow is specification-driven collection, metric calculation, and Topdown bottleneck analysis. The primary executable is the Python Topdown CLI at `tools/topdown_tool/topdown_tool/__main__.py`, with orchestration in `tools/topdown_tool/topdown_tool/probe/probe.py`.

#### Telemetry Specifications as the Data Contract
Versioned JSON schemas and product specifications define raw events, derived metrics, groups, and methodology trees. CPU and CMN are distinct specification domains with a shared JSON-driven model:
- `data/pmu/cpu/schemas/v1.2.schema.json`
- `data/pmu/cpu/specifications/neoverse/neoverse_v3_r0p0_pmu.json`
- `data/pmu/cmn/specifications/cmn_700_r0p0_pmu.json`

The Topdown tool loads these specifications through `tools/topdown_tool/topdown_tool/common/spec_loader.py`; schemas/specifications are the boundary between Arm IP telemetry definitions and collection implementations.

#### Topdown Probe Layer
The probe layer selects and drives CPU or CMN analysis. CPU detection, model construction, telemetry-database handling, metric computation, and output rendering are separated under:
- `tools/topdown_tool/topdown_tool/cpu_probe/cpu_detector.py`
- `tools/topdown_tool/topdown_tool/cpu_probe/cpu_factory.py`
- `tools/topdown_tool/topdown_tool/cpu_probe/cpu_probe.py`

CPU flows are: detect target CPU → select matching specification → resolve event dependencies and methodology/group selection → collect counters → compute per-core/aggregate metrics → render CLI or CSV output. The metric decision tree implements Stage 1 Topdown and deeper metric-group analysis.

#### CMN Discovery, Modeling, and Scheduling
CMN analysis adds a hardware-topology boundary: static CMN revision specifications must be combined with discovered mesh instances, nodes, ports, and device types. The CMN subsystem models that topology and translates component events, filters, and watchpoints into collectable plans:
- `tools/topdown_tool/topdown_tool/cmn_probe/cmn_factory.py`
- `tools/topdown_tool/topdown_tool/cmn_probe/cmn_model.py`
- `tools/topdown_tool/topdown_tool/cmn_probe/scheduler.py`

`multi_cmn_scheduler.py` coordinates scheduling across CMN instances. CMN collection is constrained by hardware counter/watchpoint availability, unlike purely declarative metric definitions.

#### Collection and Target Runtime Boundary
The tool executes workloads while PMU collection backends acquire measurements. Workload modes isolate command, PID-tracked, and system-wide execution:
- `tools/topdown_tool/topdown_tool/workload/command_workload.py`
- `tools/topdown_tool/topdown_tool/workload/pid_workload.py`
- `tools/topdown_tool/topdown_tool/workload/systemwide_workload.py`

Linux collection integrates with `perf` via `tools/topdown_tool/topdown_tool/perf/linux_perf.py`; Windows support is represented by `tools/topdown_tool/topdown_tool/perf/windows_perf.py` and `wperf_artifact_handler.py`. Local and remote Linux command execution are abstracted in `tools/topdown_tool/topdown_tool/common/command_runner/remote_linux.py`, making host/target transport an explicit infrastructure boundary.

#### Supporting Toolchain and Validation Workloads
The repository also produces and consumes telemetry-adjacent artifacts. `tools/perf_json_generator/generate.py` generates Linux perf JSON metadata from mappings/categories, while `tools/spe_parser/spe_parser/parser.py` decodes SPE/perf input into CSV or Parquet-oriented analysis data.

Native benchmark suites validate the telemetry methodology by creating targeted CPU, cache, memory, lock, and interconnect pressure:
- `benchmarks/ustress/Makefile`
- `benchmarks/sysstress/CMakeLists.txt`
- `benchmarks/matmul/Makefile`

These C/C++/assembly workloads are independent of the Python analysis runtime but are intended inputs to Topdown/perf collection and metric validation.

Main entry points: [`tools/topdown_tool/topdown_tool/perf/linux_perf.py`](https://github.com/xinydev/telemetry-solution/blob/main/tools/topdown_tool/topdown_tool/perf/linux_perf.py) (Linux perf backend), [`tools/topdown_tool/topdown_tool/cpu_probe/cpu_probe.py`](https://github.com/xinydev/telemetry-solution/blob/main/tools/topdown_tool/topdown_tool/cpu_probe/cpu_probe.py) (CPU Topdown probe), [`tools/topdown_tool/topdown_tool/common/spec_loader.py`](https://github.com/xinydev/telemetry-solution/blob/main/tools/topdown_tool/topdown_tool/common/spec_loader.py) (Specification loader), [`tools/topdown_tool/topdown_tool/probe/probe.py`](https://github.com/xinydev/telemetry-solution/blob/main/tools/topdown_tool/topdown_tool/probe/probe.py) (Probe orchestrator)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_specs["Telemetry specifications"]
  node_cpu_schema["CPU JSON schema v1.2<br/>[v1.2.schema.json]"]
  node_cpu_spec["Neoverse V3 PMU spec<br/>CPU specification"]
  node_cmn_spec["CMN-700 PMU spec<br/>CMN specification"]
end

subgraph group_topdown["Topdown analysis"]
  node_cli["Topdown CLI<br/>Python entry point<br/>[__main__.py]"]
  node_probe_orchestrator["Probe orchestrator<br/>analysis router<br/>[probe.py]"]
  node_spec_loader["Specification loader<br/>JSON loader<br/>[spec_loader.py]"]
  node_cpu_detector["CPU detector<br/>target discovery<br/>[cpu_detector.py]"]
  node_cpu_factory["CPU model factory<br/>model builder<br/>[cpu_factory.py]"]
  node_cpu_probe["CPU Topdown probe<br/>metric engine<br/>[cpu_probe.py]"]
  node_results["CLI / CSV results<br/>analysis output"]
end

subgraph group_cmn["CMN analysis"]
  node_cmn_factory["CMN model factory<br/>model builder<br/>[cmn_factory.py]"]
  node_cmn_model["CMN topology model<br/>hardware model<br/>[cmn_model.py]"]
  node_cmn_scheduler["CMN scheduler<br/>collection planner<br/>[scheduler.py]"]
  node_multi_cmn_scheduler["Multi-CMN coordinator<br/>instance scheduler"]
end

subgraph group_runtime["Collection runtime"]
  node_command_workload["Command workload<br/>workload mode"]
  node_pid_workload["PID workload<br/>workload mode<br/>[pid_workload.py]"]
  node_systemwide_workload["System-wide workload<br/>workload mode"]
  node_linux_perf["Linux perf backend<br/>PMU collector<br/>[linux_perf.py]"]
  node_windows_perf["Windows perf backend<br/>PMU collector<br/>[windows_perf.py]"]
  node_remote_linux["Remote Linux runner<br/>target transport<br/>[remote_linux.py]"]
end

subgraph group_tooling["Supporting toolchain"]
  node_perf_json_generator["Perf JSON generator<br/>metadata generator<br/>[generate.py]"]
  node_spe_parser["SPE parser<br/>trace decoder<br/>[parser.py]"]
  node_benchmarks{{"Native stress benchmarks<br/>validation workloads"}}
end

node_cpu_schema -.->|"validates"| node_cpu_spec
node_cli -->|"invokes"| node_probe_orchestrator
node_probe_orchestrator -->|"loads definitions"| node_spec_loader
node_cpu_spec -->|"CPU definitions"| node_spec_loader
node_cmn_spec -->|"CMN definitions"| node_spec_loader
node_probe_orchestrator -->|"CPU flow"| node_cpu_detector
node_cpu_detector -->|"target identity"| node_cpu_factory
node_spec_loader -->|"matched spec"| node_cpu_factory
node_cpu_factory -->|"CPU model"| node_cpu_probe
node_cpu_probe -->|"metrics and Topdown output"| node_results
node_probe_orchestrator -->|"CMN flow"| node_cmn_factory
node_spec_loader -->|"CMN definitions"| node_cmn_factory
node_cmn_factory -->|"static model"| node_cmn_model
node_cmn_model -->|"topology and events"| node_cmn_scheduler
node_cmn_scheduler -->|"per-instance plans"| node_multi_cmn_scheduler
node_multi_cmn_scheduler -->|"collection plan"| node_linux_perf
node_cpu_probe -->|"counter requests"| node_linux_perf
node_cpu_probe -->|"counter requests"| node_windows_perf
node_command_workload -->|"measured command"| node_linux_perf
node_pid_workload -->|"measured PID"| node_linux_perf
node_systemwide_workload -->|"system measurement"| node_linux_perf
node_remote_linux -->|"remote execution"| node_linux_perf
node_linux_perf -->|"counter samples"| node_cpu_probe
node_benchmarks -->|"validation input"| node_command_workload
node_perf_json_generator -.->|"perf metadata"| node_linux_perf
node_linux_perf -->|"SPE/perf input"| node_spe_parser

click node_cpu_schema "https://github.com/xinydev/telemetry-solution/blob/main/data/pmu/cpu/schemas/v1.2.schema.json"
click node_cpu_spec "https://github.com/xinydev/telemetry-solution/blob/main/data/pmu/cpu/specifications/neoverse/neoverse_v3_r0p0_pmu.json"
click node_cmn_spec "https://github.com/xinydev/telemetry-solution/blob/main/data/pmu/cmn/specifications/cmn_700_r0p0_pmu.json"
click node_cli "https://github.com/xinydev/telemetry-solution/blob/main/tools/topdown_tool/topdown_tool/__main__.py"
click node_probe_orchestrator "https://github.com/xinydev/telemetry-solution/blob/main/tools/topdown_tool/topdown_tool/probe/probe.py"
click node_spec_loader "https://github.com/xinydev/telemetry-solution/blob/main/tools/topdown_tool/topdown_tool/common/spec_loader.py"
click node_cpu_detector "https://github.com/xinydev/telemetry-solution/blob/main/tools/topdown_tool/topdown_tool/cpu_probe/cpu_detector.py"
click node_cpu_factory "https://github.com/xinydev/telemetry-solution/blob/main/tools/topdown_tool/topdown_tool/cpu_probe/cpu_factory.py"
click node_cpu_probe "https://github.com/xinydev/telemetry-solution/blob/main/tools/topdown_tool/topdown_tool/cpu_probe/cpu_probe.py"
click node_cmn_factory "https://github.com/xinydev/telemetry-solution/blob/main/tools/topdown_tool/topdown_tool/cmn_probe/cmn_factory.py"
click node_cmn_model "https://github.com/xinydev/telemetry-solution/blob/main/tools/topdown_tool/topdown_tool/cmn_probe/cmn_model.py"
click node_cmn_scheduler "https://github.com/xinydev/telemetry-solution/blob/main/tools/topdown_tool/topdown_tool/cmn_probe/scheduler.py"
click node_multi_cmn_scheduler "https://github.com/xinydev/telemetry-solution/blob/main/tools/topdown_tool/topdown_tool/cmn_probe/multi_cmn_scheduler.py"
click node_command_workload "https://github.com/xinydev/telemetry-solution/blob/main/tools/topdown_tool/topdown_tool/workload/command_workload.py"
click node_pid_workload "https://github.com/xinydev/telemetry-solution/blob/main/tools/topdown_tool/topdown_tool/workload/pid_workload.py"
click node_systemwide_workload "https://github.com/xinydev/telemetry-solution/blob/main/tools/topdown_tool/topdown_tool/workload/systemwide_workload.py"
click node_linux_perf "https://github.com/xinydev/telemetry-solution/blob/main/tools/topdown_tool/topdown_tool/perf/linux_perf.py"
click node_windows_perf "https://github.com/xinydev/telemetry-solution/blob/main/tools/topdown_tool/topdown_tool/perf/windows_perf.py"
click node_remote_linux "https://github.com/xinydev/telemetry-solution/blob/main/tools/topdown_tool/topdown_tool/common/command_runner/remote_linux.py"
click node_perf_json_generator "https://github.com/xinydev/telemetry-solution/blob/main/tools/perf_json_generator/generate.py"
click node_spe_parser "https://github.com/xinydev/telemetry-solution/blob/main/tools/spe_parser/spe_parser/parser.py"
click node_benchmarks "https://github.com/xinydev/telemetry-solution/blob/main/benchmarks/ustress/Makefile"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_cpu_schema,node_cpu_spec,node_cmn_spec toneBlue
class node_cli,node_probe_orchestrator,node_spec_loader,node_cpu_detector,node_cpu_factory,node_cpu_probe,node_results toneAmber
class node_cmn_factory,node_cmn_model,node_cmn_scheduler,node_multi_cmn_scheduler toneMint
class node_command_workload,node_pid_workload,node_systemwide_workload,node_linux_perf,node_windows_perf,node_remote_linux toneRose
class node_perf_json_generator,node_spe_parser,node_benchmarks toneIndigo
```

## Components

### Telemetry specifications

Versioned data contract for CPU and CMN telemetry.

- [CPU JSON schema v1.2](https://github.com/xinydev/telemetry-solution/blob/main/data/pmu/cpu/schemas/v1.2.schema.json): schema · `data/pmu/cpu/schemas/v1.2.schema.json`
- [Neoverse V3 PMU spec](https://github.com/xinydev/telemetry-solution/blob/main/data/pmu/cpu/specifications/neoverse/neoverse_v3_r0p0_pmu.json): CPU specification · Defines CPU events, metrics, groups, and methodology. · `data/pmu/cpu/specifications/neoverse/neoverse_v3_r0p0_pmu.json`
- [CMN-700 PMU spec](https://github.com/xinydev/telemetry-solution/blob/main/data/pmu/cmn/specifications/cmn_700_r0p0_pmu.json): CMN specification · Defines static CMN events and metrics. · `data/pmu/cmn/specifications/cmn_700_r0p0_pmu.json`

### Topdown analysis

Python CLI orchestration and CPU analysis.

- [Topdown CLI](https://github.com/xinydev/telemetry-solution/blob/main/tools/topdown_tool/topdown_tool/__main__.py): Python entry point · `tools/topdown_tool/topdown_tool/__main__.py`
- [Probe orchestrator](https://github.com/xinydev/telemetry-solution/blob/main/tools/topdown_tool/topdown_tool/probe/probe.py): analysis router · Selects CPU or CMN analysis flow. · `tools/topdown_tool/topdown_tool/probe/probe.py`
- [Specification loader](https://github.com/xinydev/telemetry-solution/blob/main/tools/topdown_tool/topdown_tool/common/spec_loader.py): JSON loader · Loads telemetry definitions as the implementation boundary. · `tools/topdown_tool/topdown_tool/common/spec_loader.py`
- [CPU detector](https://github.com/xinydev/telemetry-solution/blob/main/tools/topdown_tool/topdown_tool/cpu_probe/cpu_detector.py): target discovery · `tools/topdown_tool/topdown_tool/cpu_probe/cpu_detector.py`
- [CPU model factory](https://github.com/xinydev/telemetry-solution/blob/main/tools/topdown_tool/topdown_tool/cpu_probe/cpu_factory.py): model builder · Matches the target CPU to its specification. · `tools/topdown_tool/topdown_tool/cpu_probe/cpu_factory.py`
- [CPU Topdown probe](https://github.com/xinydev/telemetry-solution/blob/main/tools/topdown_tool/topdown_tool/cpu_probe/cpu_probe.py): metric engine · Resolves dependencies, computes metrics, and renders results. · `tools/topdown_tool/topdown_tool/cpu_probe/cpu_probe.py`
- **CLI / CSV results**: analysis output

### CMN analysis

Topology-aware interconnect modeling and scheduling.

- [CMN model factory](https://github.com/xinydev/telemetry-solution/blob/main/tools/topdown_tool/topdown_tool/cmn_probe/cmn_factory.py): model builder · `tools/topdown_tool/topdown_tool/cmn_probe/cmn_factory.py`
- [CMN topology model](https://github.com/xinydev/telemetry-solution/blob/main/tools/topdown_tool/topdown_tool/cmn_probe/cmn_model.py): hardware model · Combines static definitions with discovered mesh topology. · `tools/topdown_tool/topdown_tool/cmn_probe/cmn_model.py`
- [CMN scheduler](https://github.com/xinydev/telemetry-solution/blob/main/tools/topdown_tool/topdown_tool/cmn_probe/scheduler.py): collection planner · Fits events, filters, and watchpoints to hardware resources. · `tools/topdown_tool/topdown_tool/cmn_probe/scheduler.py`
- [Multi-CMN coordinator](https://github.com/xinydev/telemetry-solution/blob/main/tools/topdown_tool/topdown_tool/cmn_probe/multi_cmn_scheduler.py): instance scheduler · Coordinates plans across CMN instances. · `tools/topdown_tool/topdown_tool/cmn_probe/multi_cmn_scheduler.py`

### Collection runtime

Workload execution and platform PMU collection.

- [Command workload](https://github.com/xinydev/telemetry-solution/blob/main/tools/topdown_tool/topdown_tool/workload/command_workload.py): workload mode · `tools/topdown_tool/topdown_tool/workload/command_workload.py`
- [PID workload](https://github.com/xinydev/telemetry-solution/blob/main/tools/topdown_tool/topdown_tool/workload/pid_workload.py): workload mode · `tools/topdown_tool/topdown_tool/workload/pid_workload.py`
- [System-wide workload](https://github.com/xinydev/telemetry-solution/blob/main/tools/topdown_tool/topdown_tool/workload/systemwide_workload.py): workload mode · `tools/topdown_tool/topdown_tool/workload/systemwide_workload.py`
- [Linux perf backend](https://github.com/xinydev/telemetry-solution/blob/main/tools/topdown_tool/topdown_tool/perf/linux_perf.py): PMU collector · `tools/topdown_tool/topdown_tool/perf/linux_perf.py`
- [Windows perf backend](https://github.com/xinydev/telemetry-solution/blob/main/tools/topdown_tool/topdown_tool/perf/windows_perf.py): PMU collector · `tools/topdown_tool/topdown_tool/perf/windows_perf.py`
- [Remote Linux runner](https://github.com/xinydev/telemetry-solution/blob/main/tools/topdown_tool/topdown_tool/common/command_runner/remote_linux.py): target transport · Abstracts local and remote command execution. · `tools/topdown_tool/topdown_tool/common/command_runner/remote_linux.py`

### Supporting toolchain

Metadata generation, trace parsing, and validation workloads.

- [Perf JSON generator](https://github.com/xinydev/telemetry-solution/blob/main/tools/perf_json_generator/generate.py): metadata generator · Generates Linux perf metadata from mappings and categories. · `tools/perf_json_generator/generate.py`
- [SPE parser](https://github.com/xinydev/telemetry-solution/blob/main/tools/spe_parser/spe_parser/parser.py): trace decoder · Decodes SPE/perf input into CSV or Parquet-oriented data. · `tools/spe_parser/spe_parser/parser.py`
- [Native stress benchmarks](https://github.com/xinydev/telemetry-solution/blob/main/benchmarks/ustress/Makefile): validation workloads · CPU, cache, memory, lock, and interconnect pressure workloads. · `benchmarks/ustress/Makefile`

## Connections

- CPU JSON schema v1.2 → Neoverse V3 PMU spec: validates
- Topdown CLI → Probe orchestrator: invokes
- Probe orchestrator → Specification loader: loads definitions
- Neoverse V3 PMU spec → Specification loader: CPU definitions
- CMN-700 PMU spec → Specification loader: CMN definitions
- Probe orchestrator → CPU detector: CPU flow
- CPU detector → CPU model factory: target identity
- Specification loader → CPU model factory: matched spec
- CPU model factory → CPU Topdown probe: CPU model
- CPU Topdown probe → CLI / CSV results: metrics and Topdown output
- Probe orchestrator → CMN model factory: CMN flow
- Specification loader → CMN model factory: CMN definitions
- CMN model factory → CMN topology model: static model
- CMN topology model → CMN scheduler: topology and events
- CMN scheduler → Multi-CMN coordinator: per-instance plans
- Multi-CMN coordinator → Linux perf backend: collection plan
- CPU Topdown probe → Linux perf backend: counter requests
- CPU Topdown probe → Windows perf backend: counter requests
- Command workload → Linux perf backend: measured command
- PID workload → Linux perf backend: measured PID
- System-wide workload → Linux perf backend: system measurement
- Remote Linux runner → Linux perf backend: remote execution
- Linux perf backend → CPU Topdown probe: counter samples
- Native stress benchmarks → Command workload: validation input
- Perf JSON generator → Linux perf backend: perf metadata
- Linux perf backend → SPE parser: SPE/perf input
