ocaml-multicore / eio

Effects-based direct-style IO for multicore OCaml
Other
529 stars 67 forks source link

Improve tracing #656

Closed talex5 closed 7 months ago

talex5 commented 7 months ago

This adds tracing of cancellation contexts and OS operations, and documents and cleans up the API a bit.

When reading events, instead of the consumer providing one function per event, we now use a single function taking a variant. This makes the API easier to use and lets the caller decide whether they want to handle all events (checked by the compiler) or just some of them.

Note: eio_posix yields before each operation to avoid starvation. However, if it needed to block then it did another yield afterwards when retrying, which isn't necessary and clutters up the traces. This commit also removes that.

(based on #554)

talex5 commented 7 months ago

Using a prototype visualiser, this is what examples/net looks like with these events:

trace

c-cube commented 7 months ago

are the green zones representing times where a fiber is actually running?

talex5 commented 7 months ago

Yes, that's right.

c-cube commented 7 months ago

That's fairly cool, I don't think I've seen that in any "classic" trace visualizer (perfetto, tracy, etc.). It means you emit a lot of events though, don't you?

talex5 commented 7 months ago

We only switch fibers when a fiber suspends, and we need to log why it's suspending anyway, so it's not a lot more events.