beetlebug▾
/

Watch a running app

ztk top shows what a ztk app does while it runs: its interpreters and threads, the compute units and memory of each one, and the time of each frame of its window. It reads the app through the observe service of ztcl, and only the user who started the app can read it.

A model of the window panel that ztk observe is to open runs live on the page The observe panel, live, with made-up data.

Start the app with the service

Start the app with --observe:

ztk --observe app.tcl

The program prints the address of the service on stderr:

ztk: observe at /tmp/ztcl-501/observe-4242.sock

The number in the name is the process id of the app. With no --observe, the app has no service.

Open the panel

In another terminal, give ztk top the process id:

ztk top 4242

The panel opens in a window and reads the app five times a second.

The overview of ztk top: a summary of interpreters, compute, memory, frames, and widgets, then the tree of the program with main, a child interpreter, and a busy thread, and the pane of main with its capabilities
The overview of an app with a child interpreter and a busy thread

The summary at the top has the count of interpreters and threads, the compute units each second of the whole app with a trend, the memory, the 99th percentile of the frame time, and the count of widgets.

The overview lists each interpreter, child interpreter, and thread, with:

Click a row to see its capabilities, the procs on its stack, and its WebAssembly instances in the pane on the right.

The frames of the window

Press 2, or click Frames, for the time of each frame of the window.

The frames view of ztk top: stacked columns of the time of each stage, a table of the 50th and 99th percentile of each stage, and the counts of frames, late frames, and slow frames
The time of each stage of a frame

A frame has five stages: events, style, layout, paint, and render. The chart has the median time of each stage for each sample. The table has the 50th and 99th percentile of each stage over the last 256 frames. A late frame needed more than 16.7 ms of work in its stages, the time of one frame at 60 Hz, and a slow frame more than 100 ms. A Debug build of ztk has many late frames: Skate Pond on Windows gave 99 late frames of 469 in a Debug build, and none in a ReleaseFast build. Slow frames explains how to find the cause of one.

Keys

Key Action
1 The overview
2 The frames
P Pause the view; the app runs on

Another address

--observe=PATH puts the socket at PATH, and ztk top PATH reads it. Use a folder that only you can open.

ztcl top reads the same service in a terminal, and ztcl top --json PID prints one snapshot as JSON, with the frames of the window in its field ztk. Debugging lists the fields.

Safety

Limits