Documentation
¶
Overview ¶
Package capacity finds, on a node whose query memory is pinned, the largest limit each data model can serve from a data set far larger than that limit: a ladder of growing limits, whose top rung is the capacity of the node.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrExhausted = errors.New("query memory exhausted")
ErrExhausted is what a probe returns when the node refused the query for lack of query memory.
Functions ¶
func CheckMarginalMemory ¶
func CheckMarginalMemory(small, large *Result, smallPool, largePool uint64, probe func(int) (Outcome, error), scenario string)
CheckMarginalMemory compares what each further result costs in real memory with what the budget charges for it, on the node with the larger memory. The budget's cost is the extra allowance that doubling the pool gives, over the extra results it buys. The real cost is the growth of the peak heap between a low and a high limit over the results between them. Both are differences, so the fixed costs of a query, which depend on the machine, cancel in each. The spec fails when a result costs in memory more than marginalMargin times what the budget charges for it: the budget would then admit queries that hold more than it says.
func CheckScaling ¶
CheckScaling asserts the property the memory budget exists for: a node with twice the query memory serves a larger limit, by about twice, whatever the data set holds. It compares two runs of the same scenario in the same process, so the constants of the machine cancel.
func MeasureHeap ¶
func MeasureHeap(fn func()) uint64
MeasureHeap runs fn once, with the garbage collector set tight, and returns how far the heap of the process grew above where it stood before, at its peak while fn ran. The nodes of an in-process cluster and the client share the heap, so the result is the memory of all of them.
func MedianHeap ¶
func MedianHeap(fn func()) uint64
MedianHeap is the median of MeasureHeap over measureRepeats runs of fn.
Types ¶
type Expect ¶
type Expect struct {
// Floor is the fewest results the node must serve, the regression guard of the scenario.
Floor int
}
Expect is what a scenario must serve on one topology.
type Outcome ¶
type Outcome struct {
// Returned is the number of results: traces, elements or data points.
Returned int
// Bytes is the size of the payload that came back, as far as the scenario can tell.
Bytes int
}
Outcome is what one query returned.
type Result ¶
type Result struct {
// Rungs are the probes in the order they ran.
Rungs []Rung
// Max is the outcome of the largest limit that succeeded; its Returned is the capacity.
Max Outcome
// MaxLimit is the largest limit that succeeded.
MaxLimit int
// FirstFail is the smallest limit that was refused, or 0 when none was.
FirstFail int
// Saturated reports that even the whole data set was served, so the ladder found no ceiling.
Saturated bool
}
Result is the outcome of a ladder.
func Climb ¶
func Climb(conn *grpc.ClientConn, base time.Time, sc *Scenario, where string) (*Result, func(limit int) (Outcome, error))
Climb writes the data set, waits until all of it is stored, climbs the ladder and checks what it found:
- every query that is served returns exactly the limit it was given, since the data set holds more;
- every query that is refused is refused with RESOURCE_EXHAUSTED, never with another error;
- the node serves at least a limit of 1, and the data set is larger than the capacity, or the ladder measured the data and not the memory;
- the boundary holds: a limit a tenth below the capacity is served again, and one a tenth above it is refused;
- every byte the queries reserved is returned once they are done.
The ladder is reported either way, so a run shows how much each data model returns on the memory it was given.
func Find ¶
Find climbs the limits 1, 2, 4, ... up to total, then bisects between the last limit that succeeded and the first that was refused. A probe returns ErrExhausted (possibly wrapped) when the node ran out of query memory; any other error aborts the ladder, since a query that fails for another reason says nothing about capacity. total is the number of results the data set holds: a limit of total or more asks for all of them.
type Scenario ¶
type Scenario struct {
// Write stores the data set: Total results the probe can return.
Write func(conn *grpc.ClientConn, base time.Time)
// Count returns how many of the results are stored and queryable, counting window by window so the count never
// asks for more than the node can serve.
Count func(ctx context.Context, conn *grpc.ClientConn, base time.Time) (int, error)
// Probe runs the query of the scenario with the limit and reports what it returned.
Probe func(ctx context.Context, conn *grpc.ClientConn, base time.Time, limit int) (Outcome, error)
// Name names the scenario in reports.
Name string
// PoolBytes is the query pool the node under test gets; a query may reserve an eighth of it.
PoolBytes uint64
// Total is the number of results the data set holds.
Total int
}
Scenario is one data model, with a data set far larger than the query memory of the node under test and a query whose limit the ladder raises.
func MeasureIndexMode ¶
MeasureIndexMode is an index-mode measure of 20000 small documents, one series each, queried with a limit and no order: the shape of the endpoint list whose limit used to be ignored until every document had been read.
func MeasurePoints ¶
MeasurePoints is a measure of 8000 data points of 8 KiB spread over 8 entities, about 63 MiB, queried newest first: a measure whose points are large, so the limit has to bound what is read.
func StreamHotSeries ¶
StreamHotSeries is a stream whose elements all belong to one series, the shape of a busy service's log: 400 elements of 64 KiB, about 25 MiB, queried newest first. The data set is many times what a query may hold, and a query with a limit has to read only the newest elements of it.
func TraceNewest ¶
TraceNewest is a trace group of 300 traces of 8 spans of 16 KiB each, about 38 MiB, queried newest first: the shape of a trace list, where every trace comes back whole and the limit counts traces.