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.
Functions§
- byte_
after_ time - The byte offset in
outputof the first line received afterat_ms: where a reader showing the transcript up to that time stops.Ok(Some(None))when every record is at or before it;Ok(None)when bytes it needs aren’t stored. Records rise in time as they do in offset, so a binary search finds the region; a scan from there finds the record. - 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.