deadlineadmit

package
v0.47.0 Latest Latest
Warning

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

Go to latest
Published: Sep 4, 2026 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Overview

Package deadlineadmit is a pure, tier-1 admission policy. It orders pending work earliest-deadline-first (EDF) and sheds degradation-eligible items it predicts will miss their deadline, so the survivors keep their SLO under contention instead of every request missing together.

It is a clean-room policy inspired by Mooncake's admission queue (Apache-2.0); no source bytes are vendored. The package imports only the Go standard library so it stays tier-1 pure-root eligible.

The clock is an abstract integer chosen by the caller: Deadline, now, and PredictedCost must all be expressed in the same unit. An item is dispatched no earlier than now, so it is predicted to finish at now+PredictedCost.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Order

func Order(items []Item) []int

Order returns the earliest-deadline-first dispatch order of the given items as a slice of IDs. Ties on Deadline are broken by ascending ID, so the order is deterministic and independent of input order. Order does not apply shedding; every input item appears in the result. The input slice is not modified.

func Shed

func Shed(items []Item, now, dropThreshold int) []int

Shed returns the IDs of items dropped as predicted deadline misses, in earliest-deadline-first order. Only degradable items appear: a non-degradable item that is predicted to miss is retained (never silently dropped). The input slice is not modified.

Types

type ComparisonArm added in v0.44.0

type ComparisonArm struct {
	Name      string        `json:"name"`
	Kind      string        `json:"kind"`
	Available bool          `json:"available"`
	Correct   bool          `json:"correct"`
	Latency   time.Duration `json:"latency"`
	Admitted  int           `json:"admitted"`
	Shed      int           `json:"shed"`
	Bytes     int64         `json:"bytes"`
	CostUSD   float64       `json:"cost_usd"`
	Note      string        `json:"note,omitempty"`
}

ComparisonArm is one independently reportable deadline-admission arm.

type ComparisonResult added in v0.44.0

type ComparisonResult struct {
	Workload string          `json:"workload"`
	Arms     []ComparisonArm `json:"arms"`
}

func CompareLocal added in v0.44.0

func CompareLocal() ComparisonResult

CompareLocal executes only the native and no-feature FIFO arms. External schedulers and fak integrations stay unavailable until their real runtimes execute this exact workload; adapters and mocks are not external witnesses.

type Item

type Item struct {
	// ID is a caller-assigned stable identifier, echoed back in a Plan's Order
	// and Shed slices. Callers are expected to keep IDs unique.
	ID int
	// Deadline is the absolute time by which the item must finish.
	Deadline int
	// PredictedCost is the predicted time the item takes to complete once it is
	// dispatched.
	PredictedCost int
	// Degradable reports whether the item may be shed (degradation-eligible).
	// A non-degradable item is never shed, even when it is predicted to miss.
	Degradable bool
}

Item is one unit of pending work considered for deadline-ordered admission. All fields are plain policy inputs.

type Plan

type Plan struct {
	// Order lists the surviving item IDs in earliest-deadline-first dispatch
	// order. Shed items are excluded from Order.
	Order []int
	// Shed lists the item IDs dropped as predicted deadline misses, also in
	// earliest-deadline-first order. Every ID here is degradable; a
	// non-degradable item is never placed in Shed.
	Shed []int
}

Plan is the outcome of Admit.

func Admit

func Admit(items []Item, now, dropThreshold int) Plan

Admit computes the full admission plan: the surviving items in EDF dispatch order and the shed set. An item is shed only when it is degradable and its predicted finish overshoots its deadline by at least dropThreshold; every other item — including a non-degradable predicted miss — survives and is dispatched in earliest-deadline-first order. The input slice is not modified.

Jump to

Keyboard shortcuts

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