scheduling

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Oct 14, 2025 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrMClockSchedulerClosed               = errors.New("mClock scheduler is closed")
	ErrMClockSchedulerRequestLimitExceeded = errors.New("mClock scheduler request limit exceeded")
	ErrMClockSchedulerUnknownTag           = errors.New("unknown tag")
	ErrInvalidTagInfo                      = errors.New("invalid tag info: shares, limit and reservation must be greater than zero")
	ErrInvalidRunLimit                     = errors.New("invalid run limit: must be greater than zero")
	ErrTagRequestsProhibited               = errors.New("tag requests are prohibited")
)

Functions

This section is empty.

Types

type MClock

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

MClock is mClock scheduling algorithm implementation.

See https://www.usenix.org/legacy/event/osdi10/tech/full_papers/Gulati.pdf for details.

func NewMClock

func NewMClock(runLimit, waitLimit uint64, tagInfo map[string]TagInfo, idleTimeout time.Duration) (*MClock, error)

NewMClock creates new MClock scheduler instance with runLimit maximum allowed count of running requests and waitLimit maximum allowed count of waiting requests for tags specified by tagInfo. The value of idleTimeout defines the difference between the current time and the time of the previous request, at which the tag considered idle. If idleTimeout is negative, it means that there is no idle tags allowed. If waitLimit equals zero, it means that there is no limit on the number of waiting requests.

func (*MClock) Close

func (q *MClock) Close()

Close closes MClock scheduler. No new requests for scheduling will be accepted after the closing.

func (*MClock) RequestArrival

func (q *MClock) RequestArrival(ctx context.Context, tag string) (ReleaseFunc, error)

RequestArrival schedules new request with tag value. Method call is blocked until one of the following events occurs: request with the tag is scheduled for execution, context ctx is canceled or the scheduler is closed. If the method call returned non-nil ReleaseFunc, then it must be called after the request is completed.

type ReleaseFunc

type ReleaseFunc func()

ReleaseFunc is the type of function that should be called after the request is completed.

type TagInfo

type TagInfo struct {
	ReservedIOPS *float64
	LimitIOPS    *float64
	Share        float64
	Prohibited   bool
}

TagInfo contains reserved IOPS, IOPS limit and share values for a tag.

Jump to

Keyboard shortcuts

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