33eio-trace can be used to record and display traces of programs using the [ Eio] [ ] library
44(requires Eio 0.14 or later).
55
6+ ## Installation
7+
68To install eio-trace:
79
810```
@@ -11,6 +13,36 @@ cd eio-trace
1113dune build
1214```
1315
16+ ### macOS
17+
18+ These instructions will walk you through installing the system dependencies necessary in order to install eio-trace's dependencies from OPAM.
19+
20+ These instructions make use of [ Homebrew] ( https://brew.sh/ ) , adapt them to MacPorts, Fink, etc., if needed.
21+
22+ First ensure everything is up-to-date:
23+ ``` sh
24+ brew update
25+ brew upgrade
26+ opam update
27+ ```
28+
29+ Then install the required packages:
30+ ``` sh
31+ brew install bash cairo gtk+3 m4 pkg-config libffi
32+ ```
33+
34+ Consider restarting your terminal session at this stage.
35+
36+ You can now install eio-trace's dependencies.
37+
38+ If installing ` conf-gtk3 ` fails with a ` libffi ` version error, run the following before trying again:
39+ ``` sh
40+ export PKG_CONFIG_PATH=/usr/local/Cellar/libffi/3.4.4/lib/pkgconfig
41+ ```
42+ Update the version number to match the currently installed version of libffi.
43+
44+ ## Tracing a program
45+
1446To run an Eio program and display the trace:
1547
1648```
@@ -20,13 +52,15 @@ dune exec -- eio-trace run -- myprog ...
2052You might like to start by tracing the example that comes with eio-trace:
2153
2254```
23- dune exec -- eio-trace run -- ./_build/default/examples/net/main.exe
55+ dune build && dune exec -- eio-trace run -- ./_build/default/examples/net/main.exe
2456```
2557
2658<p align =' center ' >
2759 <img src =" ./doc/net.svg " />
2860</p >
2961
62+ Scrolling with the mouse or touchpad will zoom in or out of the diagram.
63+
3064To record a trace:
3165
3266```
@@ -50,35 +84,42 @@ To convert a trace to SVG format:
5084dune exec -- eio-trace render -f trace.fxt trace.svg
5185```
5286
53- [ Eio ] : https://github.com/ocaml-multicore/eio
54- [ Perfetto ] : https://ui.perfetto.dev/
87+ ## Reading traces
5588
56- ## macOS
89+ Eio fibers are shown as horizontal bars.
90+ Green regions show when the fiber is running.
91+ Lighter-green regions highlight particular operations.
92+ Dark grey regions indicate that the fiber is suspended (allowing other fibers to run).
93+ Only one fiber in a domain can be running at a time.
5794
58- These instructions will walk you through installing the system dependencies necessary in order to install eio-trace's dependencies from OPAM .
95+ When a new fiber is created, a vertical green line links the parent fiber to the child .
5996
60- These instructions make use of [ Homebrew] ( https://brew.sh/ ) , adapt them to MacPorts, Fink, etc., if needed.
97+ Cancellation contexts (including switches) are shown as brackets.
98+ Switched can be named using ` Switch.run ~name ` . Unnamed switches are shown as "switch".
99+ A context being cancelled is indicated by a vertical red line.
61100
62- First ensure everything is up-to-date:
63- ``` sh
64- brew update
65- brew upgrade
66- opam update
67- ```
101+ Domain-wide events, such as garbage collection and waiting for events,
102+ are shown as yellow regions behind all the fibers in the domain.
103+ Nested events get progressively darker yellow.
104+ When there are multiple domains, they are shown stacked vertically:
68105
69- Then install the required packages:
70- ``` sh
71- brew install bash cairo gtk+3 m4 pkg-config libffi
72- ```
106+ <p align =' center ' >
107+ <img src =" ./doc/gc.svg " />
108+ </p >
73109
74- Consider restarting your terminal session at this stage.
110+ In the above trace, the upper domain performed GC while suspended
111+ (the dark "minor" region in the top right, inside the "suspend-domain" region).
112+ This is possible because each domain has a "backup" thread that handles GC while the domain is suspended.
75113
76- You can now install eio-trace's dependencies.
114+ ## Limitations
77115
78- ### lablgtk3
116+ - OCaml 5.1 can [ deadlock when tracing multiple domains] ( https://github.com/ocaml/ocaml/issues/12897 ) . This should be fixed in OCaml 5.2.
117+ - Events are reported per-domain, but not per-systhread.
118+ Events generated in systhreads will get mixed up and cannot be shown correctly.
119+ They will either appear attached to whatever fiber happens to be running, or shown as domain-level events.
120+ - If events are produced too fast, some will be lost. eio-trace is unlikely to handle this well.
121+ - The rendering is not optimised yet and may become quite slow on larger traces.
122+
123+ [ Eio ] : https://github.com/ocaml-multicore/eio
124+ [ Perfetto ] : https://ui.perfetto.dev/
79125
80- If installing ` conf-gtk3 ` fails with a ` libffi ` version error, run the following before trying again:
81- ``` sh
82- export PKG_CONFIG_PATH=/usr/local/Cellar/libffi/3.4.4/lib/pkgconfig
83- ```
84- Update the version number to match the currently installed version of libffi.
0 commit comments