xtop Profiler Guide

The xtop profiler provides on-demand analysis of .xpti profile data collected by xtop run or xtop attach. It offers timeline visualization, map-level summaries, and task-level inspection.

Analysis commands (xtop task, xtop map, xtop convert, xtop export) do not require root privileges. On hardware, xtop run and the target process for xtop attach may require sudo depending on device permissions. Run standalone xtop attach as the same effective user as the target (for a root target, use sudo xtop attach ... too). If the target itself must run as root, put the variable inside the sudo command (sudo XPTI_ATTACHABLE=1 ./your_application, or XPTI_ATTACHABLE=1 sudo -E ./your_application). Otherwise sudo’s default env_reset strips it and no attach socket is created.


Prerequisites

Before using the profiler, collect one or more .xpti profile files:

# Start and profile a new process
sudo xtop run -- ./your_application [args...]

# Or profile an already-running, prepared process as its owner
xtop attach --pid <PID>

These commands generate .xpti files (SQLite format). Depending on the capture interval and devices used, a profile can contain host events, device events, cache metrics, and hardware topology. For the standalone attach flow documented here, start the target with XPTI_ATTACHABLE=1. See attach mode for the exact commands.

On multi-device systems, xtop run produces one computing_..._devN.xpti file per device under ./xtop/. Devices that were not used by the application are filtered out. Commands that accept the output directory auto-pick the latest matching run profile.

Use a generated .xpti file with xtop map, xtop task, xtop convert, or xtop export. Attach writes one file per device to ./xtop/attach_<pid>_<timestamp>/session_<sid>_dev<id>.xpti (or under the directory given with -o). Pass that .xpti file itself rather than its parent directory: directory auto-pick is non-recursive and only matches xtop run output, so xtop map ./xtop can silently analyze an older run profile instead.

Bundled dependencies and limits:

  • The SDK’s xtop bundle includes matplotlib; no separate pip installation is needed.
  • The bundled xtop open command is currently unavailable. Use conversion and Perfetto UI instead; installing Flask separately does not enable it.
  • Plotting requires a compatible CPU. For X86_V2 failures and alternatives, see xtop troubleshooting.

Independent SDK containers

For independent SDK containers, use the profiling capabilities documented for the exact SDK build in each image. Compatible device metadata does not guarantee identical capture or observer behavior across releases. The analysis commands below operate on already saved files.


Quick Reference

Command Purpose Example
xtop convert <file> Convert to Perfetto format xtop convert profile.xpti
xtop export <file> --catalog ID Export catalog results to CSV xtop export profile.xpti --catalog cache.l1.hit_ratio.total --csv ./metrics
xtop map <file-or-dir> Full execution summary xtop map ./xtop
xtop map <file> --plot Generate analysis plots (PNG) xtop map profile.xpti --plot
xtop map <file> --json Export analysis as JSON xtop map profile.xpti --json
xtop task <file> List all tasks with timing xtop task profile.xpti
xtop task <file> <id> Detailed analysis of one task xtop task profile.xpti 17

Timeline Visualization

Use the execution timeline to compare host dispatch with device execution. Perfetto UI displays the recorded events on separate host and device tracks.

Convert to Perfetto Format

xtop convert profile.xpti

Options:

Option Description Default
-o, --output <path> Output file path <input>.perfetto (e.g. profile.xpti.perfetto)
--json Generate legacy JSON format instead of protobuf off
--debug Print debug information during conversion off

Output:

Converting profile.xpti -> profile.xpti.perfetto (protobuf)
Perfetto trace saved to: profile.xpti.perfetto
Open in browser: https://ui.perfetto.dev

The generated .perfetto file can be opened at https://ui.perfetto.dev.

Reading the Timeline

The screenshot below shows a Perfetto timeline from a sort example (sort_with_ptr):

Perfetto Timeline

The timeline is organized into tracks:

Track Events Description
Host TaskDispatch / TaskComplete Host-side API calls. Each span represents the time from dispatch to completion of a task.
Device Launch / Terminate Device-side kernel execution on each Sub/Cluster/MU/Thread.
Flow arrows Host to Device Visual connection from host dispatch to the corresponding device execution.

What to look for:

  • Gaps in host tracks indicate scheduling delays or synchronization waits.
  • Uneven device track lengths suggest workload imbalance across hardware threads.
  • Long flow arrows show a delay between the linked host and device events. Compare the event timestamps and task durations before attributing that delay to scheduling.

Open in Perfetto UI

The bundled xtop open command is currently unavailable. Convert the recording instead:

xtop convert profile.xpti

In Perfetto UI, choose Open trace file and select profile.xpti.perfetto. No local Flask server is needed for this workflow.


Catalog CSV Export

Use xtop export when you need files for scripts, notebooks, or external tooling. Each export names one or more catalog IDs; xtop catalog list lists them and xtop catalog describe ID explains one. See the Profiling Catalog Reference for all 62 IDs, grouped by purpose, with their result types, units, and availability limits.

# One file per catalog in ./metrics
xtop export profile.xpti --catalog cache.l1.hit_ratio.total --catalog profile.task_count --csv ./metrics

# One catalog to a chosen file, combined to at most 1000 points for a graph
xtop export profile.xpti --catalog cache.hit_ratio.timeseries --output cache.csv --param max_points=1000

# Only one Job or Map, for catalogs that support that scope
xtop export profile.xpti --catalog profile.task_count --csv ./metrics --job-id 1

Recordings keep catalog counters and interval series rather than every raw counter sample, so whole-session tables and raw records (--raw) are no longer exported. --csv DIR without --catalog no longer writes the per-layer statistics files: it exits with status 2 and prints an xtop export command for the catalogs that replace them (cache.counter_totals, cache.hit_ratio.timeseries, cache.l1.hit_ratio.by_sub, cache.l2.hit_ratio.by_sub, and pxl.maps). --raw, --layers, and --debug also exit with status 2 and say what replaced them. Compact and legacy cache/MU time series stream automatically, including an offset without a limit. Use max_points for a sampled summary or limit for one bounded page. A *_valid column of zero marks an unavailable or incomplete observation; its value is not a measurement.

CSV files get the invoking process’s umask (0666 & ~umask). xtop export stages every requested catalog before it replaces any output. If one catalog fails, the command exits with status 1 (2 for a --param value the catalog does not accept) and publishes none of its CSV files, not even those of the catalogs that succeeded; existing destination files remain intact. Only a filesystem error while moving the staged files into place can leave some outputs replaced; the error names them and leaves the rest unchanged.

Large recordings

Time-series exports stream from disk; a long recording does not require its whole history in memory. Catalogs that materialize device executions have a bounded row limit. If that limit is exceeded, export fails with exit status 1 and publishes no CSV for any catalog of that command. Existing destination files remain intact.

The error names the supported way to narrow the query: a start_ms/end_ms window, --job-id, or --map-id. When the catalog cannot use those parameters, the message says so. Use XCENA Compass or xtop query-server with a bounded time range to inspect a dense execution timeline.

start_ms and end_ms are absolute epoch milliseconds, not offsets from the recording start. A range outside the recording selects nothing: the command still exits with status 0 and writes header-only CSV files, and it prints a warning with the recording’s epoch span and, for offsets within it, the epoch values to use. The profile.run_facts catalog reports the recording’s start and end in epoch microseconds:

xtop export profile.xpti --catalog profile.run_facts --output run_facts.csv
grep -E 'profile (start|end)' run_facts.csv
profile.run_facts,directly_computed,,Profile,profile start,1790917965554578,epoch_us
profile.run_facts,directly_computed,,Profile,profile end,1790917968586061,epoch_us

Divide those values by 1000 when choosing a time window, for example:

xtop export profile.xpti --catalog device.execution_timeline --output clock-window.csv \
  --param start_ms=1790917965554 --param end_ms=1790917966554

If a window still exceeds the row limit, make it shorter.

A device-only capture longer than one MU clock wrap cannot be placed on the host clock, so its start_ms/end_ms window is refused with a message that names device_start_us. Export it in device-time parts with device_start_us and device_end_us, microseconds after the scope’s earliest device tick; see device execution viewports.

Exports from an application

An application that profiles itself through the PXL or XPTI API writes its own files. XPTI 1.6 changes what the session-level CSV export writes: map->exportProfilingCsv(), map->exportProfiling(dir, xpti::ExportFormat::Csv) or ExportFormat::Both, xpti::exportSessionCsv(), and XPTI_OUTPUT_PATH with the default XPTI_OUTPUT_FORMAT=csv now write one catalog CSV per available ID among profile.total_us, profile.task_count, profile.host_event_count, cache.counter_totals, cache.l1.per_sub_hit_rate, and cache.l2.per_sub_hit_rate, named <ID>_dev<device>[_<timestamp>].csv. The former HostEvents_*.csv, DeviceEvents_*.csv, statistics, and raw metric tables are no longer written, and the call still succeeds. Update scripts that read those files:

  • For event rows, use xpti::exportFilteredCsv(path, sessionId, xpti::QueryKey::EventsHost, {}) or xpti::QueryKey::EventsDevice with a QueryFilter. This streams the full selection without the 262,144-row materialization limit. getSessionDataDelta reads bounded pages; its result’s exportCsv(path) also exports the full session selection. The event CSV columns and escaping are unchanged.
  • For everything else, export .xpti (ExportFormat::Xpti, or XPTI_OUTPUT_FORMAT=xpti) and run xtop export --catalog ID on it.

A .xpti export writes session_<id>_dev<device>.xpti and replaces the file an earlier export left at that path; session IDs repeat across executions and runs, so the file always holds the latest export. A path that another recording or an open reader still uses is refused. Exported recordings get the mode SQLite gives a new database (0644 & ~umask). An export taken before the session ends is a snapshot: it holds every row collected and the Job, Map, and executor metadata registered up to the call, and its end_time_us is 0. Export after the session ends for a complete recording.

xpti::startProfileSession() returns 0 when a session cannot start, for example when its metadata does not fit the recording memory budget or XPTI_MEMORY_LIMIT_MB is invalid, and prints one line with the cause. It does not throw, so check the returned ID before using it.


Map Analysis

Analyze the overall Map execution with parallelism, load balance, cache efficiency, and bottleneck detection. Pass either a computing .xpti file or the xtop run output directory.

Basic Summary

xtop map ./xtop

Options:

Option Description Default
--plot Generate PNG plot with analysis charts off
--json Output analysis results as JSON off
-o, --output <path> Output file path (for --plot or --json) --plot: <input stem>.analysis.png; --json: printed to stdout

Output:

============================================================
 MAP SUMMARY
============================================================

[Hardware]
  Subs: 2   Clusters/Sub: 2   MUs/Cluster: 4   Threads/MU: 8
  Total threads    : 128
  MU frequency     : 1100 MHz

[Duration - Host]
  Wall time        : 1.75 s
  Task count       : 1,024
  avg              : 7.08 ms
  median           : 6.92 ms
  min              : 3.21 ms
  max              : 24.91 ms
  std_dev          : 2.34 ms

[Duration - Device]
  Task count       : 1,024
  avg              : 6.55 ms
  median           : 6.40 ms
  min              : 2.98 ms
  max              : 23.12 ms
  std_dev          : 2.10 ms

[Parallelism - Host]
  max_concurrent   : 128
  avg_concurrent   : 95.3
  ramp_up          : 45.23 ms
  max_hold         : 1.61 s
  ramp_down        : 89.23 ms

[Parallelism - Device]
  max_concurrent   : 128
  avg_concurrent   : 94.5
  ramp_up          : 48.90 ms
  max_hold         : 1.61 s
  ramp_down        : 90.66 ms

[Skew] (Sub/Cluster distribution)
  Sub0    : ██████████     52%
  Sub1    : █████████      48%
  Cluster0: ...
  Cluster1: ...
  balance_score    : 0.96 (1.0 = perfectly even)

[Overhead]
  Map-level (execute → synchronize)
    ...

  Task-level (dispatch → complete)
    avg_overhead   : 0.53 ms
    p95_overhead   : 1.82 ms
    max_overhead   : 6.41 ms

[Cache]
  L1 hit rate      : 92.1% (r:95.0% w:88.0%)
  L2 hit rate      : 74.3%
  L3 hit rate      : 88.9%

[Memory Bandwidth]
  Unavailable: the XPTI catalog does not expose a validated DRAM bandwidth metric

[Stragglers]
  straggler_ratio  : 1.23x (1.0 = even, >2.0 = imbalanced)
  Top busy:
    0/0/0/0              120 tasks, avg 7.25 ms
    1/1/2/3              115 tasks, avg 7.18 ms
  Least busy:
    0/1/3/7              95 tasks, avg 6.80 ms

[Idle]
  total_idle       : 12.34 ms
  total_active     : 1.73 s
  idle_percentage  : 0.7%
  gap_count        : ...
  Top idle threads:
    ...

[Long Tail]
  bottleneck       : ...
  bottleneck time  : ...
  avg time         : ...
  straggler_ratio  : ...

[Utilization]
  active_threads   : 128 / 128 (100.0%)
  idle_threads     : 0
  total_tasks      : 1,024

============================================================

Sections explained:

Section What it tells you
Hardware Device topology and clock frequency from profile metadata.
Duration Task execution time statistics from both host and device perspectives. A large gap between Host and Device averages indicates high scheduling overhead.
Parallelism How many tasks run concurrently over time. Ramp-up is the time to reach peak concurrency; ramp-down is the time from peak to completion. A long ramp-down suggests stragglers.
Skew Task distribution across Subs and Clusters. A balance score close to 1.0 means work is evenly distributed.
Overhead Map-level: host execute-to-synchronize time against the device span. Task-level: difference between host-measured and device-measured task duration, which includes scheduling latency, driver communication, and queue wait time.
Cache Aggregate cache hit rates. A low L2 hit rate may indicate poor data locality.
Memory Bandwidth Always Unavailable for now: XPTI has no validated DRAM bandwidth metric, and L3 command counts are not reported as DRAM traffic.
Stragglers Threads with disproportionately high or low workload. A straggler ratio above 2.0 indicates significant imbalance.
Idle Time gaps between consecutive tasks on each thread. A high idle percentage suggests underutilization.
Long Tail The unit (stream, or thread for a single stream) with the longest time, its time against the average, and the resulting straggler ratio.
Utilization Fraction of hardware threads that received at least one task.

Generate Plots

xtop map profile.xpti --plot -o analysis.png

Generates a multi-panel PNG image for visual analysis. The screenshot below shows the plot output from a sort example:

Map Analysis Plot

The plot contains 8 panels:

Panel Description
Host concurrency over time Number of concurrent host tasks (Dispatch-Complete) at each point in time. The red dashed line shows peak concurrency.
Device concurrency over time Number of concurrent device tasks (Launch-Terminate). Compare with host concurrency to spot scheduling overhead.
Task count per thread Bar chart showing how many tasks each hardware thread executed. Even bars indicate good load balance.
Duration histogram Distribution of individual task execution times. A long tail indicates straggler tasks.
Sub/Cluster task count heatmap Task count distribution across the Sub x Cluster grid. Darker cells received more tasks.
MU/Thread task count heatmap Task count distribution across the MU x Thread grid.
Sub/Cluster duration heatmap Total execution time per Sub x Cluster combination. Uneven colors indicate workload imbalance.
MU/Thread duration heatmap Total execution time per MU x Thread combination.

Plotting uses the SDK-bundled matplotlib. Installing another copy with pip will not change the bundled executable. If the CPU cannot run its plotting dependencies, use JSON output or a compatible host.

Export as JSON

xtop map profile.xpti --json -o analysis.json

--json writes the analysis result as JavaScript Object Notation (JSON). Use that file as input to scripts that compare profile results.


Task Analysis

Inspect individual task execution timing and hardware placement from a computing profile.

List All Tasks

xtop task profile.xpti

Options:

Option Description Default
--sort {id,active,overhead} Sort order id
--filter <expr> Filter tasks (e.g., sub=0, cluster=1) none
--limit N Limit number of rows all

Output:

==============================================================================
 TASK LIST
==============================================================================

 ID     Job   Map   Kernel           Active       Overhead     Sub  Cluster
------------------------------------------------------------------------------
 0      1     1     sort_kernel      7.08 ms      -            0    0
 1      1     1     sort_kernel      6.92 ms      -            0    1
 2      1     1     sort_kernel      8.21 ms      -            1    0
 ...
------------------------------------------------------------------------------
 Total: 1024 tasks

The list has a row per task execution: a Map executed N times lists each of its tasks N times, with the same ID. It reads the executions from the recording one at a time and keeps only the rows it prints, so --limit N holds N rows and stays fast on a large recording. Only --sort active without --limit keeps every row, and it is refused with the --limit advice when those rows exceed the analysis memory budget. This list reads device spans only, so its Overhead column is -, including with --filter. --sort overhead and a specific task ID read the full history to show host overhead; the full-history list labels its Map column PK, the profile key. A recording that cannot use the streaming path also falls back to the full-history list and its PK column.

If reading the recording fails after rows were printed, the table ends without its Total line and xtop exits with status 1, naming the SQLite error and what to do. For a disk error, free space in SQLite’s temporary directory or point SQLITE_TMPDIR at a directory with more room.

Columns explained:

Column Description
ID Task index (assigned at dispatch)
Job Job ID of the task
Map Map ID of the task (PK, the profile key, in the full-history list selected by --sort overhead or a legacy fallback)
Kernel Kernel function name
Active Device execution time (Launch to Terminate)
Overhead Host duration minus device active time (scheduling + communication); - where the list has no host pairing for the row
Sub Sub where the task executed
Cluster Cluster where the task executed

Examples:

# Sort by longest execution time
xtop task profile.xpti --sort active

# Show only tasks on Sub 0
xtop task profile.xpti --filter sub=0

# Top 10 slowest tasks
xtop task profile.xpti --sort active --limit 10

Task Detail

xtop task profile.xpti 17

xtop task <file> <id> reports timing and hardware placement for the selected task. Cache counters are sampled per device interval, not per task, so the report shows the session’s cache hit rates and marks them as not attributed to the task.

Output:

============================================================
 Task 17 (kernel: sort_kernel)
============================================================

[Identity]
  job_id          : ...
  map_id          : ...
  profile_key     : ...
  generation      : ...

[Timing]
  Host:
    dispatch      : +...  (... us)
    complete      : +...  (... us)
    duration      : 11.73 ms

  Device:
    launch        : +...  (500 ticks)
    terminate     : +...  (9942 ticks)
    active_time   : 9.44 ms

  overhead        : 2.29 ms (19.5%)

[Placement]
  sub / cluster / mu / thread
  0 / 0 / 3 / 2

[Cache] Task attribution is unavailable; counters describe shared device intervals.
  Session aggregate (not attributed to this task):
  L1 hit   : 92.1%
  L2 hit   : 74.3%
  L3 hit   : 88.9%

[Diagnosis]
  ✓ No issues detected

Sections explained:

Section Description
Identity Job ID, Map ID, profile key and generation of the task (shown when any of them is non-zero).
Timing Host-side dispatch/complete and device-side launch/terminate, each as +time from session start with the raw value (host us, device ticks). Overhead = host duration - active_time.
Placement Which Sub/Cluster/MU/Thread executed this task.
Cache Session-wide L1/L2/L3 hit rates, the same values as the xtop map Cache section. They are not attributed to this task. Without cache data the section says so and lists the reasons.
Diagnosis Automated warning when overhead is above 20% of host duration.

Typical Workflow

A common profiling workflow:

# 1. Collect profile data
sudo xtop run -- ./my_application

# 2. Quick overview. Directory input auto-picks the latest computing profile.
xtop map ./xtop

# 3. Convert the timeline, then open the generated .perfetto file in Perfetto UI
xtop convert ./xtop/computing_20260210_143022_123456_dev0.xpti

# 4. Identify slow tasks
xtop task ./xtop/computing_20260210_143022_123456_dev0.xpti --sort active --limit 10

# 5. Export catalog CSV if needed
xtop export ./xtop/computing_20260210_143022_123456_dev0.xpti --catalog cache.l1.hit_ratio.total --csv ./metrics

What to Look For

Symptom Where to check Possible cause
Long wall time xtop map Duration section Too few tasks, or stragglers
High overhead xtop map Overhead section Scheduling bottleneck
Uneven distribution xtop map Skew / Stragglers Data-dependent workload imbalance
Low cache hit rate xtop map Cache section Poor data locality
Long ramp-down xtop map Parallelism section Straggler tasks holding up completion
Individual slow task xtop task <file> <id> High overhead, or more work in that task