Skip to main content

Module open_tail

Module open_tail 

Source
Expand description

agent:open_tail: an agent pane’s first screen from one small read. The open-first-screen design (#5156), under #5141.

The pane used to open with three or four calls (the snapshot, the line count, a range of up to 10,000 lines) before it showed anything, and those could write under the store’s single write lock: extending output.idx, catching the line counter up, a stat on a cache miss. This returns the newest ~64 KB of the transcript, the line positions the live feed resumes from, and the snapshot overlay, from one reader snapshot: it takes the WAL reader pool only, never the writer mutex, and never writes or extends an index.

Line positions come from the line counter, caught up in memory when the file has grown past it (SnapshotReader::tail_state). A transcript with no usable counter epoch is counted first (transcript::counting, one scan at a time per file, off this read’s snapshot): a small one is counted within the call, a large one answers counting and the pane asks again. Without that the pane’s usual open could not read it either: output.idx is never fresh for a file with no generation. A transcript whose newest line fits no window comes back without line positions and the pane opens the usual way.

Structs§

Slice 🔒

Enums§

Read 🔒
What one pass over the reader snapshot found.

Constants§

COUNT_WAIT 🔒
How long a call waits for a transcript with no epoch to be counted before it answers “counting” (the pane’s call times out at 5 s). A small file is counted well inside it.
DEFAULT_TAIL_BYTES 🔒
A first screen: about what fits one pane, plus a margin.
MAX_CATCH_UP_BYTES 🔒
The most a counter that is only behind is caught up by in memory.
MAX_WINDOW_BYTES 🔒
The most a tail read grows to when the newest line is larger than the window.
RESTORE_BUDGET_BYTES 🔒
The most a slice is extended back to reach a turn start, and the most tail_bytes asks for: the pane’s restore size today.

Functions§

open_tail 🔒
open_tail_waiting 🔒
[open_tail], waiting up to count_wait for a transcript with no epoch to be counted.
pick_source 🔒
Which store and zone a block’s transcript is read from: the same rule blockfile:read_range and blockfile:line_count use (global_output_source: the agent’s global zone when the block has a valid agentId, is not archived and the zone has content, the block’s own otherwise), so the first screen and the older pages the pane reads next come from one file. Decided here from a reader snapshot rather than stat, which takes the writer mutex on a cache miss.
read_overlay 🔒
The agent’s session snapshot, from reader snapshots: the global store first (it always holds the agent-anchored copy), the block’s store as a fallback, as agent:session:read does.
read_slice 🔒
read_stamps 🔒
Receive-time stamps for lines starting at offsets (ascending byte offsets), from output.tsidx in this snapshot: the same lookup blockfile:read_range uses (stamps_for), which finds the records around the range wherever they are in the sidecar. None without a sidecar or records near the range.
read_window 🔒
The newest want bytes (the newest line always) of the complete lines in [0, complete_end), with the non-blank lines in them and each one’s byte offset. None when the bytes aren’t all stored or the newest line is larger than MAX_WINDOW_BYTES.
register
trim_window 🔒
window trimmed by the rules blockfile:read_range uses (tail_turns, then tail_bytes), with its receive-time stamps.