eio
eio copied to clipboard
Integrate Eio's CTF tracing with OCaml's tracing
Eio's Ctf
module provides a ring-buffer for storing trace events. Currently, this only works for a single domain. OCaml has its own CTF-based eventlog
system (https://ocaml.org/manual/instrumented-runtime.html) and we should probably just use that somehow. It might not currently support user-defined events. There's also a proposal to replace it with eventring
(https://github.com/ocaml-multicore/ocaml-multicore/pull/793), which says:
This implementation is designed to be open for extension to user tracing events in the future, as well as integration with statmemprof (e.g continuous allocation profiling).
/cc @sadiqj
@sadiqj and I discussed a couple of ways of doing this today:
- eio could watch eventring to get GC events and then copy them to its own ring, or
- eventring could allow users to add custom events and we store everything there.
The second option seems better, because:
- Having a single ring means events get recorded in the right order.
- It saves us a lot of code managing CTF buffers.
- It allows other tools to add extra events of their own.
The default eventring size is quite small (64KB) but is configurable. Eio uses 1MB by default.
Custom event rings PR: https://github.com/ocaml/ocaml/pull/11474 We should make sure that it fits Eio's requirements.
Had a quick go at using custom runtime events: https://github.com/patricoferris/eio/commit/671a5b421e0eb2f861204322f98fe222cab0be67#diff-b48e492abda9e349dd9f1df758814b45a11c5a63fcd89d65d09dc0bb7194125b -- looks good @TheLortex, but I didn't test it fully.
(note: I had to do some questionable changes to your OCaml PR to get it running on macOS)
PR: https://github.com/ocaml-multicore/eio/pull/554
This was done in #635.