Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // DefaultLevels are the default Level(s) used for compaction options. DefaultLevels = []Level{ Level{ MinSizeInclusive: 0, MaxSizeExclusive: 1 << 18, }, Level{ MinSizeInclusive: 1 << 18, MaxSizeExclusive: 1 << 19, }, Level{ MinSizeInclusive: 1 << 19, MaxSizeExclusive: 1 << 20, }, Level{ MinSizeInclusive: 1 << 20, MaxSizeExclusive: 1 << 21, }, Level{ MinSizeInclusive: 1 << 21, MaxSizeExclusive: 1 << 23, }, } // DefaultOptions are the default compaction PlannerOptions. DefaultOptions = PlannerOptions{ MutableSegmentSizeThreshold: 1 << 16, MutableCompactionAgeThreshold: 15 * time.Second, Levels: DefaultLevels, OrderBy: TasksOrderedByOldestMutableAndSize, } )
Functions ¶
This section is empty.
Types ¶
type Level ¶
Level defines a range of (min, max) sizes such that any segments within the Level are allowed to be compacted together.
type Plan ¶
type Plan struct { Tasks []Task UnusedSegments []Segment OrderBy TasksOrderBy }
Plan is a logical collection of compaction Tasks. The tasks do not depened on each other, and maybe performed sequentially or in parallel.
type PlannerOptions ¶
type PlannerOptions struct { // MutableSegmentSizeThreshold is the maximum size a mutable segment is // allowed to grow before it's rotated out for compactions. MutableSegmentSizeThreshold int64 // MutableCompactionAgeThreshold is minimum age required of a mutable segment // before it would be considered for compaction in steady state. MutableCompactionAgeThreshold time.Duration // Levels define the levels for compactions. Levels []Level // OrderBy defines the order of tasks in the compaction plan returned. OrderBy TasksOrderBy }
PlannerOptions are the knobs to tweak planning behaviour.
func (PlannerOptions) Validate ¶
func (o PlannerOptions) Validate() error
Validate ensures the receiver PlannerOptions specify valid values for each of the knobs.
type Segment ¶
Segment identifies a candidate for compaction.
func (Segment) Compactable ¶
func (s Segment) Compactable(opts PlannerOptions) bool
Compactable returns whether the current segment meets the requirements to be compacted in steady-state. NB: Steady-state here refers to the usual operating mode for M3DB, where the database is constantly receiving new writes. In these situations, we don't compact as soon as we receive a write to allow segments to buffer incoming writes to reduce the number of total compactions required by the process. However, in times where the process isn't already compacting, mutable segments that don't meet the requirements laid herein may still be considered compactable.
type Task ¶
type Task struct {
Segments []Segment
}
Task identifies a collection of segments to compact.
func (Task) Summary ¶
func (t Task) Summary() TaskSummary
Summary returns the TaskSummary for the given task.
type TaskSummary ¶
type TaskSummary struct { NumMutable int NumFST int CumulativeMutableAge time.Duration CumulativeSize int64 }
TaskSummary is a collection of statistics about a compaction task.
type TasksOrderBy ¶
type TasksOrderBy byte
TasksOrderBy controls the order of tasks returned in the plan.
const ( // TasksOrderedByOldestMutableAndSize orders tasks with oldest mutable segment age (cumulative), and then by size. TasksOrderedByOldestMutableAndSize TasksOrderBy = iota )