kubernetes/staging/src/k8s.io/apiserver/pkg/util/flowcontrol/conc_alloc.go

type allocProblemItem

type relativeAllocItem

type relativeAllocProblem

// initIndices fills in ascendingIndices and sorts them
func (rap *relativeAllocProblem) initIndices() *relativeAllocProblem {}

func (rap *relativeAllocProblem) getItemIndex(idx int) (int, bool) {}

// decode(J) returns the bound associated with ascendingIndices[J], the associated items index,
// and a bool indicating whether the bound is the item's lower bound.
func (rap *relativeAllocProblem) decode(idx int) (float64, int, bool) {}

func (rap *relativeAllocProblem) getProportion(idx int) float64 {}

func (rap *relativeAllocProblem) Len() int {}

func (rap *relativeAllocProblem) Less(i, j int) bool {}

func (rap *relativeAllocProblem) Swap(i, j int) {}

type minMax

// note scans one more number
func (mm *minMax) note(x float64) {}

const MinTarget

const epsilon

// computeConcurrencyAllocation returns the unique `allocs []float64`, and
// an associated `fairProp float64`, that jointly have
// all of the following properties (to the degree that floating point calculations allow)
// if possible otherwise returns an error saying why it is impossible.
// `allocs` sums to `requiredSum`.
// For each J in [0, len(classes)):
//  1. `classes[J].lowerBound <= allocs[J] <= classes[J].upperBound` and
//  2. exactly one of the following is true:
//     2a. `allocs[J] == fairProp * classes[J].target`,
//     2b. `allocs[J] == classes[J].lowerBound && classes[J].lowerBound > fairProp * classes[J].target`, or
//     2c. `allocs[J] == classes[J].upperBound && classes[J].upperBound < fairProp * classes[J].target`.
//
// Each allocProblemItem is required to have `target >= lowerBound >= 0` and `upperBound >= lowerBound`.
// A target smaller than MinTarget is treated as if it were MinTarget.
func computeConcurrencyAllocation(requiredSum int, classes []allocProblemItem) ([]float64, float64, error) {}