mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-28 05:57:25 +00:00
Switch initial/final seats type to uint64
This commit is contained in:
parent
a4a22a2562
commit
3c46482eb0
@ -195,7 +195,7 @@ func TestFIFOQueueWorkEstimate(t *testing.T) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
newRequest := func(initialSeats, finalSeats uint, additionalLatency time.Duration) *request {
|
newRequest := func(initialSeats, finalSeats uint64, additionalLatency time.Duration) *request {
|
||||||
return &request{workEstimate: qs.completeWorkEstimate(&fcrequest.WorkEstimate{
|
return &request{workEstimate: qs.completeWorkEstimate(&fcrequest.WorkEstimate{
|
||||||
InitialSeats: initialSeats,
|
InitialSeats: initialSeats,
|
||||||
FinalSeats: finalSeats,
|
FinalSeats: finalSeats,
|
||||||
|
@ -811,8 +811,8 @@ func (qs *queueSet) findDispatchQueueLocked() (*queue, *request) {
|
|||||||
// If the requested final seats exceed capacity of that queue,
|
// If the requested final seats exceed capacity of that queue,
|
||||||
// we reduce them to current capacity and adjust additional latency
|
// we reduce them to current capacity and adjust additional latency
|
||||||
// to preserve the total amount of work.
|
// to preserve the total amount of work.
|
||||||
if oldestReqFromMinQueue.workEstimate.FinalSeats > uint(qs.dCfg.ConcurrencyLimit) {
|
if oldestReqFromMinQueue.workEstimate.FinalSeats > uint64(qs.dCfg.ConcurrencyLimit) {
|
||||||
finalSeats := uint(qs.dCfg.ConcurrencyLimit)
|
finalSeats := uint64(qs.dCfg.ConcurrencyLimit)
|
||||||
additionalLatency := oldestReqFromMinQueue.workEstimate.finalWork.DurationPerSeat(float64(finalSeats))
|
additionalLatency := oldestReqFromMinQueue.workEstimate.finalWork.DurationPerSeat(float64(finalSeats))
|
||||||
oldestReqFromMinQueue.workEstimate.FinalSeats = finalSeats
|
oldestReqFromMinQueue.workEstimate.FinalSeats = finalSeats
|
||||||
oldestReqFromMinQueue.workEstimate.AdditionalLatency = additionalLatency
|
oldestReqFromMinQueue.workEstimate.AdditionalLatency = additionalLatency
|
||||||
|
@ -120,9 +120,9 @@ type uniformClient struct {
|
|||||||
// period
|
// period
|
||||||
split bool
|
split bool
|
||||||
// initialSeats is the number of seats this request occupies in the first phase of execution
|
// initialSeats is the number of seats this request occupies in the first phase of execution
|
||||||
initialSeats uint
|
initialSeats uint64
|
||||||
// finalSeats is the number occupied during the second phase of execution
|
// finalSeats is the number occupied during the second phase of execution
|
||||||
finalSeats uint
|
finalSeats uint64
|
||||||
}
|
}
|
||||||
|
|
||||||
func newUniformClient(hash uint64, nThreads, nCalls int, execDuration, thinkDuration time.Duration) uniformClient {
|
func newUniformClient(hash uint64, nThreads, nCalls int, execDuration, thinkDuration time.Duration) uniformClient {
|
||||||
@ -142,13 +142,13 @@ func (uc uniformClient) setSplit() uniformClient {
|
|||||||
return uc
|
return uc
|
||||||
}
|
}
|
||||||
|
|
||||||
func (uc uniformClient) setInitWidth(seats uint) uniformClient {
|
func (uc uniformClient) setInitWidth(seats uint64) uniformClient {
|
||||||
uc.initialSeats = seats
|
uc.initialSeats = seats
|
||||||
return uc
|
return uc
|
||||||
}
|
}
|
||||||
|
|
||||||
func (uc uniformClient) pad(finalSeats int, duration time.Duration) uniformClient {
|
func (uc uniformClient) pad(finalSeats int, duration time.Duration) uniformClient {
|
||||||
uc.finalSeats = uint(finalSeats)
|
uc.finalSeats = uint64(finalSeats)
|
||||||
uc.padDuration = duration
|
uc.padDuration = duration
|
||||||
return uc
|
return uc
|
||||||
}
|
}
|
||||||
|
@ -38,13 +38,13 @@ type WorkEstimatorConfig struct {
|
|||||||
*MutatingWorkEstimatorConfig `json:"mutatingWorkEstimatorConfig,omitempty"`
|
*MutatingWorkEstimatorConfig `json:"mutatingWorkEstimatorConfig,omitempty"`
|
||||||
|
|
||||||
// MinimumSeats is the minimum number of seats a request must occupy.
|
// MinimumSeats is the minimum number of seats a request must occupy.
|
||||||
MinimumSeats uint `json:"minimumSeats,omitempty"`
|
MinimumSeats uint64 `json:"minimumSeats,omitempty"`
|
||||||
// MaximumSeats is the maximum number of seats a request can occupy
|
// MaximumSeats is the maximum number of seats a request can occupy
|
||||||
//
|
//
|
||||||
// NOTE: work_estimate_seats_samples metric uses the value of maximumSeats
|
// NOTE: work_estimate_seats_samples metric uses the value of maximumSeats
|
||||||
// as the upper bound, so when we change maximumSeats we should also
|
// as the upper bound, so when we change maximumSeats we should also
|
||||||
// update the buckets of the metric.
|
// update the buckets of the metric.
|
||||||
MaximumSeats uint `json:"maximumSeats,omitempty"`
|
MaximumSeats uint64 `json:"maximumSeats,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// ListWorkEstimatorConfig holds work estimator parameters related to list requests.
|
// ListWorkEstimatorConfig holds work estimator parameters related to list requests.
|
||||||
|
@ -113,7 +113,7 @@ func (e *listWorkEstimator) estimate(r *http.Request, flowSchemaName, priorityLe
|
|||||||
// will be processed by the list request.
|
// will be processed by the list request.
|
||||||
// we will come up with a different formula for the transformation function and/or
|
// we will come up with a different formula for the transformation function and/or
|
||||||
// fine tune this number in future iteratons.
|
// fine tune this number in future iteratons.
|
||||||
seats := uint(math.Ceil(float64(estimatedObjectsToBeProcessed) / e.config.ObjectsPerSeat))
|
seats := uint64(math.Ceil(float64(estimatedObjectsToBeProcessed) / e.config.ObjectsPerSeat))
|
||||||
|
|
||||||
// make sure we never return a seat of zero
|
// make sure we never return a seat of zero
|
||||||
if seats < e.config.MinimumSeats {
|
if seats < e.config.MinimumSeats {
|
||||||
|
@ -74,7 +74,7 @@ func (e *mutatingWorkEstimator) estimate(r *http.Request, flowSchemaName, priori
|
|||||||
// is taking 1/Nth of a seat for M milliseconds.
|
// is taking 1/Nth of a seat for M milliseconds.
|
||||||
// We allow the accounting of that work in P&F to be reshaped into another
|
// We allow the accounting of that work in P&F to be reshaped into another
|
||||||
// rectangle of equal area for practical reasons.
|
// rectangle of equal area for practical reasons.
|
||||||
var finalSeats uint
|
var finalSeats uint64
|
||||||
var additionalLatency time.Duration
|
var additionalLatency time.Duration
|
||||||
|
|
||||||
// TODO: Make this unconditional after we tune the algorithm better.
|
// TODO: Make this unconditional after we tune the algorithm better.
|
||||||
@ -86,7 +86,7 @@ func (e *mutatingWorkEstimator) estimate(r *http.Request, flowSchemaName, priori
|
|||||||
// TODO: As described in the KEP, we should take into account that not all
|
// TODO: As described in the KEP, we should take into account that not all
|
||||||
// events are equal and try to estimate the cost of a single event based on
|
// events are equal and try to estimate the cost of a single event based on
|
||||||
// some historical data about size of events.
|
// some historical data about size of events.
|
||||||
finalSeats = uint(math.Ceil(float64(watchCount) / e.config.WatchesPerSeat))
|
finalSeats = uint64(math.Ceil(float64(watchCount) / e.config.WatchesPerSeat))
|
||||||
finalWork := SeatsTimesDuration(float64(finalSeats), e.config.eventAdditionalDuration())
|
finalWork := SeatsTimesDuration(float64(finalSeats), e.config.eventAdditionalDuration())
|
||||||
|
|
||||||
// While processing individual events is highly parallel,
|
// While processing individual events is highly parallel,
|
||||||
|
@ -30,11 +30,11 @@ import (
|
|||||||
type WorkEstimate struct {
|
type WorkEstimate struct {
|
||||||
// InitialSeats is the number of seats occupied while the server is
|
// InitialSeats is the number of seats occupied while the server is
|
||||||
// executing this request.
|
// executing this request.
|
||||||
InitialSeats uint
|
InitialSeats uint64
|
||||||
|
|
||||||
// FinalSeats is the number of seats occupied at the end,
|
// FinalSeats is the number of seats occupied at the end,
|
||||||
// during the AdditionalLatency.
|
// during the AdditionalLatency.
|
||||||
FinalSeats uint
|
FinalSeats uint64
|
||||||
|
|
||||||
// AdditionalLatency specifies the additional duration the seats allocated
|
// AdditionalLatency specifies the additional duration the seats allocated
|
||||||
// to this request must be reserved after the given request had finished.
|
// to this request must be reserved after the given request had finished.
|
||||||
@ -85,9 +85,9 @@ func (e WorkEstimatorFunc) EstimateWork(r *http.Request, flowSchemaName, priorit
|
|||||||
|
|
||||||
type workEstimator struct {
|
type workEstimator struct {
|
||||||
// the minimum number of seats a request must occupy
|
// the minimum number of seats a request must occupy
|
||||||
minimumSeats uint
|
minimumSeats uint64
|
||||||
// the maximum number of seats a request can occupy
|
// the maximum number of seats a request can occupy
|
||||||
maximumSeats uint
|
maximumSeats uint64
|
||||||
// listWorkEstimator estimates work for list request(s)
|
// listWorkEstimator estimates work for list request(s)
|
||||||
listWorkEstimator WorkEstimatorFunc
|
listWorkEstimator WorkEstimatorFunc
|
||||||
// mutatingWorkEstimator calculates the width of mutating request(s)
|
// mutatingWorkEstimator calculates the width of mutating request(s)
|
||||||
|
@ -37,8 +37,8 @@ func TestWorkEstimator(t *testing.T) {
|
|||||||
counts map[string]int64
|
counts map[string]int64
|
||||||
countErr error
|
countErr error
|
||||||
watchCount int
|
watchCount int
|
||||||
initialSeatsExpected uint
|
initialSeatsExpected uint64
|
||||||
finalSeatsExpected uint
|
finalSeatsExpected uint64
|
||||||
additionalLatencyExpected time.Duration
|
additionalLatencyExpected time.Duration
|
||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user