Documentation
¶
Overview ¶
Package profile is the storage tier's EXPLAIN ANALYZE: a profiled tree of the fetch operators with per-node timing and I/O counters, showing where and how much time a query spent (which parts were scanned vs pruned, rows in/out, bytes decoded). The library owns the fetch-tier subtree; an embedder's query engine splices it under its own language operators (DESIGN §16.5).
It is opt-in and zero-overhead when off: a caller installs a collector with WithCollector and reads Collector.Root after the fetch; operators call Begin (a no-op when no collector is in ctx, so the default fetch path makes no timing reads or allocations). It is safe for the concurrent fan-out a split/cluster fetch performs.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Collector ¶
type Collector struct {
// contains filtered or unexported fields
}
Collector accumulates a profile tree. Safe for concurrent Begin/End across fan-out sub-fetches.
func WithCollector ¶
WithCollector installs a fresh collector rooted at a "query" node and returns it. Operators below (via Begin) attach to this root. Reading Collector.Root after the fetch yields the tree.
type Handle ¶
type Handle struct {
// contains filtered or unexported fields
}
Handle is an open operator node; End it (defer) when the operator finishes, and Add counters to it. A nil Handle is valid and no-ops, which is what Begin returns when no collector is installed.
func Begin ¶
Begin starts a child operator named name under the current node in ctx and returns the child ctx (so nested Begin calls attach beneath it) and a Handle to End/Add. When no collector is in ctx it returns ctx unchanged and a nil Handle, so instrumented operators cost nothing off the profiling path.
type Node ¶
type Node struct {
Name string // operator name (e.g. "engine.fetch", "part-scan")
Dur time.Duration // wall time of this operator (including children)
Counters map[string]int64 // I/O counters (rows, parts_scanned, bytes_decoded, …)
Children []*Node
}
Node is one operator in the profiled query tree.
func Decode ¶
Decode parses a Node.Encode payload, returning the node and the unconsumed tail. It bounds-checks every length so a corrupt or hostile payload never panics or over-allocates.
func (*Node) Encode ¶
Encode appends the binary encoding of the subtree rooted at n to dst (a peer's read RPC returns it so the requester can graft it). The shape is, recursively: name, duration (nanos, varint), sorted counters, then children.