Module Core_profiler_offline_tool__Reader.Short_message.Header

Packs Probe_id.t and Time_ns.t into a single int.

The goal of Short_header is to pack a Timer.record into one word (we want to write an integer number of words for alignment, and don't want to pay for the size or time of writing a second word if we don't have to).

A short header "contains" an Probe_id.t and a Time_ns.t. A short header is a single word / integer; we have 63 bits to play with. The 9 most significant bits contain Probe_id.to_int_exn; the remaining 54 bits contain a time, stored as a number of nanoseconds from some Profiler_epoch.t (the epoch is written into the header; see Writer.write_epoch).

2 ** 54 nanoseconds is approximately 208 days. The epoch is set to equal a little before now when OCaml starts up, so the header should continue to work for ~208 days after that.

val id_bits : int
val time_bits : int
val max_id : int
val max_time_diff : Core.Time_ns.Span.t
val pack_exn : Core_profiler.Profiler_epoch.t ‑> Core_profiler.Probe_id.t ‑> Core.Time_ns.t ‑> int
val pack_unsafe : Core_profiler.Profiler_epoch.t ‑> Core_profiler.Probe_id.t ‑> Core.Time_ns.t ‑> int
val unpack_id : int ‑> Core_profiler.Probe_id.t
val unpack_time : Core_profiler.Profiler_epoch.t ‑> int ‑> Core.Time_ns.t
val unpack : Core_profiler.Profiler_epoch.t ‑> int ‑> Core_profiler.Probe_id.t * Core.Time_ns.t