compaction

package
v0.4.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 27, 2018 License: Apache-2.0 Imports: 6 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

View Source
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 ByMinSize

type ByMinSize []Level

ByMinSize orders a []Level by MinSize in ascending order.

func (ByMinSize) Len

func (a ByMinSize) Len() int

func (ByMinSize) Less

func (a ByMinSize) Less(i, j int) bool

func (ByMinSize) Swap

func (a ByMinSize) Swap(i, j int)

type Level

type Level struct {
	MinSizeInclusive int64
	MaxSizeExclusive int64
}

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.

func NewPlan

func NewPlan(compactableSegments []Segment, opts PlannerOptions) (*Plan, error)

NewPlan returns a new compaction.Plan per the rules above and the knobs provided.

func (*Plan) Len

func (p *Plan) Len() int

func (*Plan) Less

func (p *Plan) Less(i, j int) bool

func (*Plan) Swap

func (p *Plan) Swap(i, j int)

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

type Segment struct {
	Age     time.Duration
	Size    int64
	Type    segments.Type
	Segment segment.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
)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL