eio icon indicating copy to clipboard operation
eio copied to clipboard

Integrate Eio's CTF tracing with OCaml's tracing

Open talex5 opened this issue 3 years ago • 2 comments

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

talex5 avatar Jan 07 '22 14:01 talex5

@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.

talex5 avatar Jan 07 '22 16:01 talex5

Custom event rings PR: https://github.com/ocaml/ocaml/pull/11474 We should make sure that it fits Eio's requirements.

TheLortex avatar Sep 08 '22 15:09 TheLortex

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)

patricoferris avatar Nov 03 '22 09:11 patricoferris

PR: https://github.com/ocaml-multicore/eio/pull/554

talex5 avatar Jun 20 '23 12:06 talex5

This was done in #635.

talex5 avatar Nov 20 '23 11:11 talex5