eio icon indicating copy to clipboard operation
eio copied to clipboard

Ctf tracing: extend the `Fiber` API to allow labelling fibers

Open TheLortex opened this issue 2 years ago • 2 comments

Similarly to how Promise.create has an optional label argument, we could have a similar feature for labelling tasks that are spawned using functions from the Fiber module.

For fork, the signature could be val fork : ?label:string -> sw:Switch.t -> (unit -> unit) -> unit.

For combinators we can choose between:

  • val any : ?label:string -> (unit -> 'a) list -> 'a: label all tasks with the same name
  • val any_labelled : (string * (unit -> 'a)) list -> 'a : new function to label each task separately

I have a small implementation for this be cause it's very useful to have this when tracing complex Eio programs.

TheLortex avatar May 17 '22 08:05 TheLortex

Is this different to calling Ctf.label in the new thread? Originally, Ctf was supposed to be a user-facing API, but it's hidden inside Eio.Private for now because the API is likely to change.

For a label on any, it would be useful instead to label the cancellation context tree (shown with e.g. Cancel.dump).

talex5 avatar May 18 '22 09:05 talex5

Looking at the implementation it's indeed equivalent, thanks for the pointer.

But yes labelling the cancellation context remains useful.

TheLortex avatar May 18 '22 10:05 TheLortex