@@ -220,70 +220,30 @@ Calling an operation that performs an effect (such as `yield`) can switch to a d
220
220
When OCaml's tracing is turned on, Eio writes events about many actions,
221
221
such as creating fibers or resolving promises.
222
222
223
- [ examples/trace] ( ./examples/trace/ ) shows how to consume the events manually:
223
+ You can use [ eio-trace] [ ] to capture a trace and display it in a window.
224
+ For example, this is a trace of the counting example above:
224
225
225
- <!-- $MDX skip -->
226
- ``` sh
227
- $ dune exec -- ./examples/trace/main.exe
228
- +tracer: starting
229
- 30926487700447:ring 0: create fiber 0
230
- 30926487702032:ring 0: running fiber 0
231
- 30926487705057:ring 0: create switch 1
232
- 30926487707264:ring 0: create fiber 2
233
- 30926487707512:ring 0: running fiber 2
234
- 30926487720213:ring 0: log " tracer: starting"
235
- +server: starting
236
- +client: connecting socket...
237
- +server: got connection from client
238
- +server: read " Hello" from socket
239
- 30926487769298:ring 0: running fiber 0
240
- 30926487769877:ring 0: create fiber 3
241
- 30926487770083:ring 0: running fiber 3
242
- 30926487771198:ring 0: create switch 4
243
- 30926487807888:ring 0: create switch 5
244
- 30926487808329:ring 0: create fiber 6
245
- 30926487808555:ring 0: running fiber 6
246
- 30926487812219:ring 0: log " server: starting"
247
- 30926487818883:ring 0: running fiber 3
248
- 30926487819091:ring 0: create fiber 7
249
- 30926487819155:ring 0: running fiber 7
250
- 30926487822428:ring 0: log " client: connecting socket..."
251
- 30926487901604:ring 0: running fiber 3
252
- 30926487904947:ring 0: running fiber 0
253
- 30926487907318:ring 0: running fiber 6
254
- 30926487917202:ring 0: log " server: got connection from client"
255
- 30926487929993:ring 0: running fiber 6
256
- 30926487941403:ring 0: running fiber 7
257
- 30926487948000:ring 0: running fiber 7
258
- 30926487971898:ring 0: resolve 7
259
- 30926487974810:ring 0: running fiber 6
260
- 30926487975215:ring 0: running fiber 6
261
- 30926487977869:ring 0: running fiber 6
262
- 30926487984514:ring 0: log " server: read \" Hello\" from socket"
263
- 30926487990785:ring 0: resolve 6
264
- 30926487991752:ring 0: running fiber 3
265
- 30926488022310:ring 0: resolve 3
266
- 30926497839725:ring 0: running fiber 2
267
- +tracer: stopping
268
226
```
227
+ dune build ./examples
228
+ eio-trace run -- ./_build/default/examples/both/main.exe
229
+ ```
230
+
231
+ <p align =' center ' >
232
+ <img src =" ./doc/traces/both-posix.svg " />
233
+ </p >
269
234
235
+ The upper horizontal bar is the initial fiber, and the brackets show ` Fiber.both ` creating a second fiber.
236
+ The green segments show when each fiber is running.
270
237
Note that the output from ` traceln ` appears in the trace as well as on the console.
238
+ In the eio-trace window, scrolling with the mouse or touchpad will zoom in or out of the diagram.
271
239
272
- There are various third-party tools that can consume this data
240
+ There are various third-party tools that can also consume this data
273
241
(but may currently require patches to support the new system):
274
242
275
243
- [ Meio] [ ] (Monitoring for Eio) provides an interactive console-based UI for exploring running fibers.
276
244
- [ Olly] [ ] can save Perfetto traces and report statistics.
277
- - [ mirage-trace-viewer] [ ] renders traces visually.
278
-
279
- For example, this is how mirage-trace-viewer renders the counting example above:
280
-
281
- <p align =' center ' >
282
- <img src =" ./doc/trace.svg " />
283
- </p >
284
245
285
- This shows the two counting threads as two horizonal lines.
286
- The white regions indicate when each thread was running.
246
+ [ examples/trace] ( ./examples/trace/ ) shows how to consume the events manually.
287
247
288
248
## Cancellation
289
249
@@ -1893,3 +1853,4 @@ Some background about the effects system can be found in:
1893
1853
[ Eio.Process ] : https://ocaml-multicore.github.io/eio/eio/Eio/Process/index.html
1894
1854
[ Dev meetings ] : https://docs.google.com/document/d/1ZBfbjAkvEkv9ldumpZV5VXrEc_HpPeYjHPW_TiwJe4Q
1895
1855
[ Olly ] : https://github.com/tarides/runtime_events_tools
1856
+ [ eio-trace ] : https://github.com/ocaml-multicore/eio-trace
0 commit comments