Expand description
Receive-time stamps for a range of transcript lines, from the
output.tsidx sidecar — without loading the sidecar whole.
The sidecar holds one record per append, {"off":<byte offset>,"ms":<unix ms>}\n, in append order, so off rises through the file. A line’s stamp is
the newest record at or before the line’s own byte offset (0 = unknown).
blockfile:read_range used to read the whole sidecar and parse every
record to stamp ~200 lines: 38 MB and ~1.1M records on a long-lived agent,
about 0.6 s per read. Instead, a binary search over the sidecar’s bytes
finds the record the first line needs, and only a window around the
requested range is read and parsed.
Records a little out of order (two srv instances mirroring into one global
zone, older builds stamping outside the append’s transaction) are
tolerated: the window reaches MARGIN bytes past both ends of the range
and its records are sorted. A record further out of place than that can be
missed, so a line may get an earlier stamp — stamps are best-effort display
times, and a miss that far out would need thousands of records out of
order.
Structs§
- Record 🔒
Enums§
- Probe 🔒
Constants§
- CHUNK 🔒
- Chunk size for the window read.
- MARGIN 🔒
- Bytes read before the range’s first record and past its last, for out-of-order records (~2,000 records at ~30 bytes each).
- PROBE 🔒
- Bytes read at each binary-search probe; a record is ~30 bytes.
- SEARCH_
STOP 🔒 - Once the search interval is this small, the window just covers it.
Functions§
- first_
record_ 🔒after - The first parsable record that starts after
pos(at a line boundary strictly past it) and beforehi. - parse 🔒
- stamps_
for 🔒 - Stamps for
line_offsets(ascending byte offsets inoutput), read from a sidecar ofsizebytes throughread(offset, len)—Nonefromreadmeans those bytes aren’t all stored (a writer mid-append), and so no stamps.Ok(None): no sidecar records near the range at all.