package eio

  1. Overview
  2. Docs

This library is used to write event traces in mirage-profile's CTF format.

type id = private int

Each thread/fiber/promise is identified by a unique ID.

Recording events

Libraries and applications can use these functions to make the traces more useful.

val label : string -> unit

label msg attaches text msg to the current thread.

val note_increase : string -> int -> unit

note_increase counter delta records that counter increased by delta. If delta is negative, this records a decrease.

val note_counter_value : string -> int -> unit

note_counter_value counter value records that counter is now value.

val should_resolve : id -> unit

should_resolve id records that id is expected to resolve, and should be highlighted if it doesn't.

Recording system events

These are normally only called by the scheduler.

type hiatus_reason =
  1. | Wait_for_work
  2. | Suspend
  3. | Hibernate
type event =
  1. | Wait
  2. | Task
  3. | Bind
  4. | Try
  5. | Choose
  6. | Pick
  7. | Join
  8. | Map
  9. | Condition
  10. | On_success
  11. | On_failure
  12. | On_termination
  13. | On_any
  14. | Ignore_result
  15. | Async
  16. | Promise
  17. | Semaphore
  18. | Switch
  19. | Stream
  20. | Mutex
    (*

    Types of threads or other recorded objects.

    *)
val mint_id : unit -> id

mint_id () is a fresh unique id.

val note_created : ?label:string -> id -> event -> unit

note_created t id ty records the creation of id.

val note_read : ?reader:id -> id -> unit

note_read src records that promise src's value was read.

  • parameter reader

    The thread doing the read (default is the current thread).

val note_try_read : id -> unit

note_try_read src records that the current thread wants to read from src (which is not currently ready).

val note_switch : id -> unit

note_switch id records that id is now the current thread.

val note_hiatus : hiatus_reason -> unit

note_hiatus r records that the system will sleep for reason r.

val note_resume : id -> unit

note_resume id records that the system has resumed (used after note_hiatus), and is now running id.

val note_fork : unit -> id

note_fork () records that a new thread has been forked and returns a fresh ID for it.

val note_resolved : id -> ex:exn option -> unit

note_resolved id ~ex records that id is now resolved. If ex = None then id was successful, otherwise it failed with exception ex.

val note_signal : ?src:id -> id -> unit

note_signal ~src dst records that dst was signalled.

  • parameter src

    The thread sending the signal (default is the current thread).

Controlling tracing

type log_buffer = (char, Stdlib.Bigarray.int8_unsigned_elt, Stdlib.Bigarray.c_layout) Stdlib.Bigarray.Array1.t
module Control : sig ... end