mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-24 12:15:52 +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{
|
||||
InitialSeats: initialSeats,
|
||||
FinalSeats: finalSeats,
|
||||
|
@ -811,8 +811,8 @@ func (qs *queueSet) findDispatchQueueLocked() (*queue, *request) {
|
||||
// If the requested final seats exceed capacity of that queue,
|
||||
// we reduce them to current capacity and adjust additional latency
|
||||
// to preserve the total amount of work.
|
||||
if oldestReqFromMinQueue.workEstimate.FinalSeats > uint(qs.dCfg.ConcurrencyLimit) {
|
||||
finalSeats := uint(qs.dCfg.ConcurrencyLimit)
|
||||
if oldestReqFromMinQueue.workEstimate.FinalSeats > uint64(qs.dCfg.ConcurrencyLimit) {
|
||||
finalSeats := uint64(qs.dCfg.ConcurrencyLimit)
|
||||
additionalLatency := oldestReqFromMinQueue.workEstimate.finalWork.DurationPerSeat(float64(finalSeats))
|
||||
oldestReqFromMinQueue.workEstimate.FinalSeats = finalSeats
|
||||
oldestReqFromMinQueue.workEstimate.AdditionalLatency = additionalLatency
|
||||
|
@ -120,9 +120,9 @@ type uniformClient struct {
|
||||
// period
|
||||
split bool
|
||||
// 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 uint
|
||||
finalSeats uint64
|
||||
}
|
||||
|
||||
func newUniformClient(hash uint64, nThreads, nCalls int, execDuration, thinkDuration time.Duration) uniformClient {
|
||||
@ -142,13 +142,13 @@ func (uc uniformClient) setSplit() uniformClient {
|
||||
return uc
|
||||
}
|
||||
|
||||
func (uc uniformClient) setInitWidth(seats uint) uniformClient {
|
||||
func (uc uniformClient) setInitWidth(seats uint64) uniformClient {
|
||||
uc.initialSeats = seats
|
||||
return uc
|
||||
}
|
||||
|
||||
func (uc uniformClient) pad(finalSeats int, duration time.Duration) uniformClient {
|
||||
uc.finalSeats = uint(finalSeats)
|
||||
uc.finalSeats = uint64(finalSeats)
|
||||
uc.padDuration = duration
|
||||
return uc
|
||||
}
|
||||
|
@ -38,13 +38,13 @@ type WorkEstimatorConfig struct {
|
||||
*MutatingWorkEstimatorConfig `json:"mutatingWorkEstimatorConfig,omitempty"`
|
||||
|
||||
// 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
|
||||
//
|
||||
// NOTE: work_estimate_seats_samples metric uses the value of maximumSeats
|
||||
// as the upper bound, so when we change maximumSeats we should also
|
||||
// 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.
|
||||
|
@ -113,7 +113,7 @@ func (e *listWorkEstimator) estimate(r *http.Request, flowSchemaName, priorityLe
|
||||
// will be processed by the list request.
|
||||
// we will come up with a different formula for the transformation function and/or
|
||||
// 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
|
||||
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.
|
||||
// We allow the accounting of that work in P&F to be reshaped into another
|
||||
// rectangle of equal area for practical reasons.
|
||||
var finalSeats uint
|
||||
var finalSeats uint64
|
||||
var additionalLatency time.Duration
|
||||
|
||||
// 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
|
||||
// events are equal and try to estimate the cost of a single event based on
|
||||
// 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())
|
||||
|
||||
// While processing individual events is highly parallel,
|
||||
|
@ -30,11 +30,11 @@ import (
|
||||
type WorkEstimate struct {
|
||||
// InitialSeats is the number of seats occupied while the server is
|
||||
// executing this request.
|
||||
InitialSeats uint
|
||||
InitialSeats uint64
|
||||
|
||||
// FinalSeats is the number of seats occupied at the end,
|
||||
// during the AdditionalLatency.
|
||||
FinalSeats uint
|
||||
FinalSeats uint64
|
||||
|
||||
// AdditionalLatency specifies the additional duration the seats allocated
|
||||
// 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 {
|
||||
// the minimum number of seats a request must occupy
|
||||
minimumSeats uint
|
||||
minimumSeats uint64
|
||||
// the maximum number of seats a request can occupy
|
||||
maximumSeats uint
|
||||
maximumSeats uint64
|
||||
// listWorkEstimator estimates work for list request(s)
|
||||
listWorkEstimator WorkEstimatorFunc
|
||||
// mutatingWorkEstimator calculates the width of mutating request(s)
|
||||
|
@ -37,8 +37,8 @@ func TestWorkEstimator(t *testing.T) {
|
||||
counts map[string]int64
|
||||
countErr error
|
||||
watchCount int
|
||||
initialSeatsExpected uint
|
||||
finalSeatsExpected uint
|
||||
initialSeatsExpected uint64
|
||||
finalSeatsExpected uint64
|
||||
additionalLatencyExpected time.Duration
|
||||
}{
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user