You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/source/live_tracing.md
+55-2Lines changed: 55 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,16 +1,34 @@
1
-
# Real-time tracing
1
+
# Live tracing of events from the board
2
2
3
3
This chapter covers the usage of [Zephelin Trace Viewer](visual_interface) for live visualization of traces being gathered during application execution.
4
4
5
5
Real-time visualization requires running a local Python server responsible for ingesting CTF traces, parsing them into TEF, and forwarding them to the visualizer.
6
6
7
+
## Real-time tracing server structure
8
+
9
+
```{pipeline_manager} Live tracing diagram
10
+
:spec: ./zephelin-flow-spec.json
11
+
:graph: ./zephelin-flow-graph-live.json
12
+
:preview: true
13
+
```
14
+
15
+
Compared to diagram from {ref}`zephelin-trace-collection`, instead of saving and converting complete CTF traces to TEF format and uploading them to Zephelin Trace Viewer, we continuously deliver traces over TCP to a Zephelin's server, convert them chunk by chunk to TEF format and deliver to Zephelin Trace Viewer over Remote Procedure Calls (RPC).
16
+
17
+
The Zephelin's server consists of:
18
+
19
+
*[Trace Handler](https://github.com/antmicro/zephelin/blob/main/server/handlers/trace_handler.py) - configures Parser Proxy, `libbtrace` live plugin and RPC Dispatcher and controls delivery of traces and commands to the Zephelin Trace Viewer.
20
+
*[RPC Dispatcher](https://github.com/antmicro/zephelin/blob/main/server/rpc_dispatcher.py) - sends and receives messages from Zephelin Trace Viewer.
21
+
*[Stream Parser Proxy](https://github.com/antmicro/zephelin/blob/main/server/handlers/trace_handler.py) - collects data from `west zpl-<backend>-capture` over TCP and subdivides it to the commands' stream and traces.
22
+
Traces are delivered to `libbtrace` live plugin.
23
+
*[`libbtrace` live plugin](https://github.com/antmicro/libbtrace/tree/main/src/plugins/ctf/live-src) - receives parts of CTF traces and converts them to parts of TEF messages that are later delivered to Trace Handler.
24
+
7
25
## Prerequisites
8
26
9
27
Before running the server, you need to install required backend dependencies and compile the frontend visualizer.
10
28
11
29
### Install server dependencies
12
30
13
-
Apart from regular dependencies of Zephelin, server dependencies need to be installed as well with the following command:
31
+
Apart from installing Zephelin's dependencies (see {ref}`setting-up-workspace`), server dependencies need to be installed as well with the following command:
14
32
15
33
```bash
16
34
pip install -r server/requirements.txt
@@ -62,6 +80,7 @@ You can customize the server's networking interfaces, and specify trace parsing
62
80
*`--tcp-server-port`- Port of the Zephelin TCP socket for CTF trace ingestion (Default: `5000`).
63
81
*`--backend-host` - Address where the backend API and visualizer are hosted (Default: `127.0.0.1`).
64
82
*`--backend-port` - Port where the backend API and visualizer are hosted (Default: `8000`).
83
+
*`--bt-port` - Port used by `libbtrace` live plugin to collect pure CTF traces (Default: `42674`).
65
84
*`--frontend-directory` - Path to compiled frontend directory.
66
85
*`--build-dir` - Path to the traced application build directory.
67
86
*`--tflm-model-paths` - Paths to the TFLM models.
@@ -71,6 +90,13 @@ You can customize the server's networking interfaces, and specify trace parsing
71
90
*`--tvm-model-op-remove-suffix` - Regex pattern used for removing TVM operator suffixes.
72
91
*`--verbosity` - Set the logging verbosity level (`DEBUG, INFO, WARNING, ERROR, CRITICAL`).
73
92
93
+
### Additional configuration options for tests
94
+
95
+
There is a possibility to run the server in a mock mode, where TEF traces are delivered as inputs and sent to the website at specified speed:
96
+
97
+
*`--mock-trace-file` - Path to the TEF/JSON trace file to use for the mock.
98
+
*`--mock-playback-speed` - Playback speed multiplier for the mock.
99
+
74
100
## Providing traces to the server
75
101
76
102
Once the server is running, it listens for CTF traces on the TCP socket.
@@ -119,6 +145,33 @@ In the end, run collection of traces from:
119
145
west zpl-uart-capture <path-to-uart> 115200 ./trace-hw.ctf --send-to-remote 127.0.0.1:5000
120
146
```
121
147
148
+
## Communication flow
149
+
150
+
Server implementation in `server/run_backend.py` consists of following access points:
151
+
152
+
*`<tcp_server_host>:<tcp_server_port>` - allows communication between `west` capture subcommands and the server.
153
+
*`<backend_host>:<backend_port>` - this hosts the website loaded from `--frontend-directory` directory and configures communication between website and server.
154
+
*`127.0.0.1:<bt_port>` - allows delivery of pure CTF events to the `libbtrace` live plugin (it is a one-way communication).
155
+
156
+
As in file-based Zephelin flow, the traces are first collected and sent by the board to the host using a selected backend (e.g. UART).
157
+
After this, `west zpl-<backend>-capture` command with `--send-to-remote` flag configured to e.g. `127.0.0.1:5000` will send CTF traces with additional data (such as `_zpl_ctf_start__` start tag) to a given address.
158
+
159
+
This address should match `--tcp-server-host` and `--tcp-server-port` settings in the `server/run_backend.py` script.
160
+
[`Stream Parser Proxy`](https://github.com/antmicro/zephelin/blob/main/server/handlers/trace_handler.py) will receive packets sent by the `west` subcommand and subdivide them into commands (such as restart the viewer based on start tag) that should be sent as RPC commands to the website, and pure CTF events.
161
+
162
+
Pure CTF events are sent to [`libbtrace` live plugin](https://github.com/antmicro/libbtrace/tree/main/src/plugins/ctf/live-src) over `--bt-port` port on loopback (e.g. `127.0.0.1:42674`), for fast conversion to TEF events in C++.
163
+
The plugin communicates with the `libbtrace` module running in the server, delivering `bt2` messages with parts of parsed TEF events - it is not socket-based communication.
164
+
165
+
:::{note}
166
+
It is possible to deliver pure CTF events directly to `libbtrace` live plugin by sending events directly to `--bt-port`, skipping the `Stream Parser Proxy`.
167
+
:::
168
+
169
+
Those `bt2` messages are delivered to the [`Trace Handler`](https://github.com/antmicro/zephelin/blob/main/server/handlers/trace_handler.py).
170
+
Trace Handler performs final adjustments of the TEF events and sends them to the website.
171
+
172
+
In the meantime, [`RPC Dispatcher`](https://github.com/antmicro/zephelin/blob/main/server/rpc_dispatcher.py) allows sending calls between server and website, and controls the state of the Zephelin Trace Viewer using procedures described in {ref}`server-api-reference`.
173
+
174
+
(server-api-reference)=
122
175
## Server API reference
123
176
124
177
The Zephelin real-time tracing server supports the following JSON-RPC requests sent as rpc_request WebSocket event:
0 commit comments