Documentation
¶
Overview ¶
Package diskio says which of the daemon's work read its disk.
The footprint's disk reads are one counter for the whole process (procstat.SelfDiskIO): the doctor could say the daemon read 4 GB in an hour but not what read it, and the slow-query log names only the statements that took long, which was not where most of it went (the owner's daemon, 2026-11-21). This package splits that counter by source.
The split is by what was running when the bytes were read. Every statement the store runs, and every read the transcript tailers and the other file readers make, is an operation with a source name; at each operation's start and end the process counter is read once, and what it moved since the last reading goes to the operations in flight in that interval, in equal shares — to "unattributed" when none was. The shares add up to the process counter, so nothing is invented and nothing is lost, but two sources running at once split what either of them read: a source is exact when it runs alone and an even split of an overlap otherwise. Reads made by code with no operation around it while another operation runs land on that operation, which is why the list carries "unattributed": when it is large, something that reads is not counted.
File readers also count the bytes they asked for (logical): a re-read of a file the OS still holds costs the disk nothing, so a source with high logical and low disk bytes is re-reading, not hurting yet.
The cost is one counter read (a single system call) and a mutex per operation boundary; nothing is written anywhere.
Index ¶
Constants ¶
const Unattributed = "unattributed"
Unattributed is the source of reads made while no operation was running.
Variables ¶
This section is empty.
Functions ¶
func Begin ¶
func Begin(name string) (end func())
Begin starts an operation of source name; the function it returns ends it and must be called exactly once.
func OpenSQL ¶
OpenSQL is sql.Open(driverName, dsn) with every query and statement an operation of source name: for the other programs' databases the daemon reads (Cursor's, OpenCode's, Hermes's, Codex's), each one source. The daemon's own database counts per asking function instead (internal/store/slowlog.go).
func Reader ¶
Reader wraps r so that each Read is an operation of source name and the bytes it returns count as that source's logical bytes.
Types ¶
type File ¶
File is an open file whose reads are operations of one source.
type Source ¶
type Source struct {
Name string `json:"source"`
// ReadBytes is the share of the process's storage reads made while this
// source's operations ran.
ReadBytes uint64 `json:"read_bytes"`
// LogicalBytes is what a file reader asked for, page cache hits
// included; 0 for a source that is not a file reader.
LogicalBytes uint64 `json:"logical_bytes,omitempty"`
// Ops is how many operations ran.
Ops uint64 `json:"ops"`
}
Source is one source's running totals since the process started.