lanescheduling

package
v0.1.4 Latest Latest
Warning

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

Go to latest
Published: Nov 19, 2026 License: AGPL-3.0, AGPL-3.0 Imports: 2 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package lanescheduling implements the Go receiver's local delivery policy. Forecasts, read-ahead admission and rescue timing can evolve independently of other receivers; they grant no content authenticity or resumable progress.

Package lanescheduling owns network supply estimates, authenticated delivery evidence, and bounded exploration. Route permission and transport liveness remain with their existing owners.

Index

Constants

View Source
const (
	InitialBlockTime        = 250 * time.Millisecond
	MinimumSampleTime       = time.Millisecond
	EvidenceLifetime        = time.Second
	MaximumEstimate         = time.Hour
	UserRelayCostFactor     = 1.05
	RelayCostFactor         = 1.1
	StaleEvidenceCostFactor = 2
)
View Source
const (
	ProbeInterval      = 5 * time.Second
	MinimumRescueDelay = 10 * time.Millisecond
	HedgeDelayFactor   = 2
	MaximumSupplements = 2
)
View Source
const (
	SampleLifetime             = 12 * time.Second
	SampleByteBudget    uint64 = 8 * 1024 * 1024
	SampleAttemptBudget        = 8
)
View Source
const (
	MeasurementWindow = time.Second
)

Variables

This section is empty.

Functions

func CompareDelivery

func CompareDelivery(left, right DeliveryEstimate) int

func ConservativeDuration

func ConservativeDuration(estimate DeliveryEstimate) time.Duration

ConservativeDuration permits bounded revalidation without treating old capacity as current.

func Cost

func Cost(estimate time.Duration, factor float64) float64

func EstimateQueue

func EstimateQueue(load DeliveryLoad) time.Duration

EstimateQueue counts only bytes still expected from the transport.

func FitsReadAhead

func FitsReadAhead(estimate DeliveryEstimate, bytes, distance uint64, aggregateRate float64) bool

FitsReadAhead admits spare capacity only when it should finish before consumption.

func ProbeDue

func ProbeDue(p *Performance, now time.Time) bool

Types

type DeliveryEstimate

type DeliveryEstimate struct {
	Evidence DeliveryEvidence
	Duration time.Duration
}

func EstimateCompletion

func EstimateCompletion(load DeliveryLoad, bytes uint64) DeliveryEstimate

type DeliveryEvidence

type DeliveryEvidence string
const (
	DeliveryUnknown DeliveryEvidence = "unknown"
	DeliveryRecent  DeliveryEvidence = "recent"
	DeliveryStale   DeliveryEvidence = "stale"
)

type DeliveryLoad

type DeliveryLoad struct {
	RemainingBytes   uint64
	PendingResponses uint32
	Evidence         DeliveryEvidence
	BytesPerSecond   float64
	Startup          time.Duration
}

DeliveryLoad describes network supply, not authenticated plaintext or retained output.

type DeliveryProgress

type DeliveryProgress struct {
	RemainingBytes uint64
	Elapsed        time.Duration
	Silent         time.Duration
	Remaining      DeliveryEstimate
}

type Exploration

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

Exploration grants at most one supplemental attempt per demand (enforced by the caller), and bounds concurrent duplicates across the entire lane set. Probes consume a separate time budget; idle paths need no content to stay open.

func (*Exploration) Acquire

func (e *Exploration) Acquire(purpose Purpose, now time.Time) bool

func (*Exploration) Available

func (e *Exploration) Available(purpose Purpose, now time.Time) bool

func (*Exploration) NextProbe

func (e *Exploration) NextProbe() time.Time

func (*Exploration) Release

func (e *Exploration) Release(purpose Purpose)

type Performance

type Performance struct {
	PendingBytes        uint64
	BytesPerSecond      float64
	HasSuccessfulSample bool
	LastAttempt         time.Time
	// contains filtered or unexported fields
}

Performance measures authenticated payload over a lane's busy interval, so overlapping requests do not each claim the lane's entire throughput.

func (*Performance) Begin

func (p *Performance) Begin(now time.Time, bytes uint64)

Begin accounts for unsettled plaintext, independently of remaining network bytes.

func (*Performance) BusyTime

func (p *Performance) BusyTime(now time.Time) time.Duration

BusyTime counts overlapping requests once. Paused jobs and output backpressure must not look like a slow network simply because wall time kept advancing.

func (*Performance) Complete

func (p *Performance) Complete(now time.Time, bytes uint64, successful bool)

func (*Performance) Superseded

func (p *Performance) Superseded(bytes uint64, elapsed time.Duration)

Superseded is a censored observation, not a path failure. It prevents a lane that never finishes before cancellation from retaining an optimistic estimate.

type Purpose

type Purpose string
const (
	Content Purpose = "content"
	Probe   Purpose = "probe"
	Sample  Purpose = "sample"
	Rescue  Purpose = "rescue"
)

type ReceivePermit

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

func (*ReceivePermit) Close

func (p *ReceivePermit) Close()

func (*ReceivePermit) Complete

func (p *ReceivePermit) Complete(now time.Time)

func (*ReceivePermit) Progress

func (p *ReceivePermit) Progress(now time.Time) DeliveryProgress

func (*ReceivePermit) Receive

func (p *ReceivePermit) Receive(bytes uint64, now time.Time) bool

Receive updates every fragment's supply estimate and reports a blocked-to-ready transition. Waiters check and reserve under the same owner lock, so another broadcast is unnecessary while capacity stays available.

type ReceiveWindow

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

ReceiveWindow owns unfinished responses, independently of authenticated plaintext or output retention. Its caller serializes access with lane state.

func (*ReceiveWindow) Available

func (w *ReceiveWindow) Available() bool

func (*ReceiveWindow) EstimateCompletion

func (w *ReceiveWindow) EstimateCompletion(bytes uint64, now time.Time) DeliveryEstimate

func (*ReceiveWindow) EstimateQueue

func (w *ReceiveWindow) EstimateQueue(now time.Time) time.Duration

func (*ReceiveWindow) Load

func (w *ReceiveWindow) Load(now time.Time) DeliveryLoad

func (*ReceiveWindow) TryReserve

func (w *ReceiveWindow) TryReserve(bytes uint64, now time.Time) *ReceivePermit

func (*ReceiveWindow) UnfinishedBytes

func (w *ReceiveWindow) UnfinishedBytes() uint64

type RescueReason

type RescueReason string
const (
	RescueFasterDelivery   RescueReason = "faster-delivery"
	RescueNoProgress       RescueReason = "no-progress"
	RescueBootstrapOverdue RescueReason = "bootstrap-overdue"
)

func RescueDecision

func RescueDecision(progress DeliveryProgress, initial, alternative DeliveryEstimate) RescueReason

type Sampling

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

func (*Sampling) Available

func (s *Sampling) Available(bytes uint64, now time.Time) bool

func (*Sampling) Offered

func (s *Sampling) Offered(bytes uint64, now time.Time)

func (*Sampling) Settled

func (s *Sampling) Settled(bytes uint64, now time.Time, outcome SamplingOutcome)

func (*Sampling) Snapshot

func (s *Sampling) Snapshot(now time.Time) SamplingEvidence

func (*Sampling) Start

func (s *Sampling) Start(now time.Time)

func (*Sampling) Stop

func (s *Sampling) Stop()

type SamplingEvidence

type SamplingEvidence struct {
	OfferedBytes       uint64
	SettledBytes       uint64
	CompletedBytes     uint64
	CompletedAttempts  uint64
	FailedAttempts     uint64
	SupersededAttempts uint64
	CancelledAttempts  uint64
	BusyMilliseconds   int64
}

SamplingEvidence counts unique assigned work, separately from authenticated winners and output. Caller cancellation cannot prove a path lacks capacity.

type SamplingOutcome

type SamplingOutcome string
const (
	SampleCompleted  SamplingOutcome = "completed"
	SampleFailed     SamplingOutcome = "failed"
	SampleSuperseded SamplingOutcome = "superseded"
	SampleCancelled  SamplingOutcome = "cancelled"
)

Jump to

Keyboard shortcuts

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