cockroach: github.com/cockroachdb/cockroach/pkg/storage/split Index | Files

package split

import "github.com/cockroachdb/cockroach/pkg/storage/split"

Index

Package Files

decider.go finder.go

Constants

const (
    // RecordDurationThreshold is the minimum duration of time the split finder
    // will record a range for, before being ready for a split.
    RecordDurationThreshold = 10 * time.Second // 10s

)

func Init Uses

func Init(lbs *Decider, intn func(n int) int, qpsThreshold func() float64)

Init initializes a Decider (which is assumed to be zero). The signature allows embedding the Decider into a larger struct outside of the scope of this package without incurring a pointer reference. This is relevant since many Deciders may exist in the system at any given point in time.

type Decider Uses

type Decider struct {
    // contains filtered or unexported fields
}

A Decider collects measurements about the activity (measured in qps) on a Replica and, assuming that qps thresholds are exceeded, tries to determine a split key that would approximately result in halving the load on each of the resultant ranges.

Operations should call `Record` with a current timestamp. Operation counts are aggregated over a second and a qps computed. If the QPS is above threshold, a split finder is instantiated and the spans supplied to Record are sampled for a duration (on the order of ten seconds). Assuming that load consistently remains over threshold, and the workload touches a diverse enough set of keys to benefit from a split, sampling will eventually instruct a caller of Record to carry out a split. When the split is initiated, it can obtain the suggested split point from MaybeSplitKey (which may have disappeared either due to a drop in qps or a change in the workload).

func (*Decider) LastQPS Uses

func (d *Decider) LastQPS(now time.Time) float64

LastQPS returns the most recent QPS measurement.

func (*Decider) MaybeSplitKey Uses

func (d *Decider) MaybeSplitKey(now time.Time) roachpb.Key

MaybeSplitKey returns a key to perform a split at. The return value will be nil if either the Decider hasn't decided that a split should be carried out or if it wasn't able to determine a suitable split key.

It is legal to call MaybeSplitKey at any time.

func (*Decider) Record Uses

func (d *Decider) Record(now time.Time, n int, span func() roachpb.Span) bool

Record notifies the Decider that 'n' operations are being carried out which operate on the span returned by the supplied method. The closure will only be called when necessary, that is, when the Decider is considering a split and is sampling key spans to determine a suitable split point.

If the returned boolean is true, a split key is available (though it may disappear as more keys are sampled) and should be initiated by the caller, which can call MaybeSplitKey to retrieve the suggested key.

func (*Decider) Reset Uses

func (d *Decider) Reset()

Reset deactivates any current attempt at determining a split key.

type Finder Uses

type Finder struct {
    // contains filtered or unexported fields
}

Finder is a structure that is used to determine the split point using the Reservoir Sampling method.

func NewFinder Uses

func NewFinder(startTime time.Time) *Finder

NewFinder initiates a Finder with the given time.

func (*Finder) Key Uses

func (f *Finder) Key() roachpb.Key

Key finds an appropriate split point based on the Reservoir sampling method. Returns a nil key if no appropriate key was found.

func (*Finder) Ready Uses

func (f *Finder) Ready(nowTime time.Time) bool

Ready checks if the Finder has been initialized with a sufficient sample duration.

func (*Finder) Record Uses

func (f *Finder) Record(span roachpb.Span, intNFn func(int) int)

Record informs the Finder about where the span lies with regard to the keys in the samples.

Package split imports 5 packages (graph) and is imported by 1 packages. Updated 2019-07-21. Refresh now. Tools for package owners.