New anti-windup technique: use the request arrival time as the floor
on the virtual dispatch time. Prevent bound violations where they
might arise rather than fixing up just one queue at dispatch time,
so that the fixed up dispatch times figure into the dispatching choice.
Two tweaks to the shuffle sharding. Take seats of executing requests
into account as well as seats of waiting requests. Do not always
consider the generated hand in the same order.
Rename the queueset methods that do shuffle sharding and finding the
queue to dispatch from, because the old names were confusingly
similar.
Tighten up some request margins.
Name the test cases in TestNoRestraint and TestWindup.
Kubernetes-commit: 4b9cba85874158b25b5c994773a4ec04343820c2
Canonicalize listing of test cases.
Make TestNoRestraint try both cases: competition and none.
Kubernetes-commit: 0ee1a7b4ff9012b050bd447055ad5e1e8c57c30e
Make TestNoRestraint verify that fairness is NOT achieved
when there is real competition.
Make TestWindup run two cases, to show that 0.1 is too narrow
a margin and 0.26 is wide enough.
Kubernetes-commit: c4945fdf0c14ba2032a5c8edf192678d9fe00374
These behavioral unit tests of queueset were failing because the
evaluation criteria were too strict.
Kubernetes-commit: 59d319ec06bb33289a87036418b4a61ed3bb215f
So that the width estimate has some effect but not a grossly excessive
one.
Added the fifo::Peek method to simplify the fifo client code.
Also renamed the queueSet::estimatedServiceTime field to
estimatedServiceSeconds to make the units clear.
Kubernetes-commit: a0c161f2f6908ee424ea888ff40f75ff071bd20a
Instead of a plain `Mutex`, use an `RWMutex` so that the common
operations can proceed in parallel.
Kubernetes-commit: 58927c1abede11ce7a8a74104328cf823df1b39e
The cmp comparison is relatively expensive (#104821). If we're not
going to log it, we shouldn't make the comparison.
Kubernetes-commit: f9f556dc7061df1dfc8c1628db983eeb97149317
Now tries a little harder to get to meaningful stack frames.
This revision seems to strike a balance that is useful in the queueset tests.
Kubernetes-commit: b56dd725032cb7a14aa27e4c50c1c9d7c6d23eb1
Added missing dispatching after delayed release of seats.
Updated logging for all six situations of execution completion and
seat release.
Added behavioral tests for non-zero extra latency and non-unit width.
Also added two tests for baseline functionality.
Also improved some comments and other logging in `queueset.go`.
Kubernetes-commit: d2a27a58f0af20c6185fa1c21890d666e9d3746b
Add comment outlining TestContextCancel.
Stop calling `t.Errorf` from wrong goroutine.
Package up queueNoteFn expectation checking.
Add counting of goroutine in req1 exec fn.
Remove unnecessary assignment to `_`.
Make TestContextCancel wait on fake clock, to insulate timing check
from scheduler noise.
Factor goroutine counting out of queueset.go, into queueset_test.go,
where it matters.
Refactor promise: Use a simple channel-based implementation for normal
code, a mutex-based one for testing code.
Took all the panics out of queueset.go
Shrink the timeouts in promise tests to 1 second.
Kubernetes-commit: 1db36ae3b30e30d70972998a22987a7db470479b
Rename from `clock` to `eventclock`.
Simplify by removing the prohibition on an EventFunc suspending and
resuming activity.
Remove "EventClock" from names to avoid stuttering.
Start to consolidate test code under fairqueuing/testing/.
Kubernetes-commit: 80ca6a4ae6ff571c32962a7155efd55edefff9e6
So we can move off of the apimachinery clock package.
Switch queueset to new clocks.
Removed event clocks based on apimachinery clocks,
because this PR introduces ones based on k8s.io/utils/clock .
Removed interface that is implemented by only one interesting type.
Simplify RealEventClock::EventAfterTime.
Kubernetes-commit: dcb298c9552de44e27ed52f5e2b58a0dd7cd8d54
- add plumbing that allows us to estimated "width" of a request
- the default implementation returns 1 as the "width" of all
incoming requests, this is in keeping with the current behavior.
Kubernetes-commit: 9b72eb1929a64b9d5a5234090a631ba312fb4d41
Adds counters to generic webhook code and to the kube aggregator
so that it is possible to effectively measure the impact of
Golang 1.15's deprecation of x509 cert CN hostname
verification.
Kubernetes-commit: 9d6a19efff05a40081337a2fcb3dce6331b04022
- don't expose the internal states of the apf controller to the caller
- return a boolean, instead of the priority level states
Kubernetes-commit: f20c6cb2d9060920cae9ff5cade1739c7e0b7f7a
webhook.WithExponentialBackoff returns an error, and the priority is:
- A: if the last invocation of the webhook function returned an error
that error should be returned, otherwise
- B: the error associated with the context if it has been canceled or
it has expired, or the ErrWaitTimeout returned by the wait package
once all retries have been exhausted.
caller should check the error returned by webhook.WithExponentialBackoff
to handle both A and B. Currently, we only handle A.
Kubernetes-commit: ae2b353fbf519b29d168c534f88c373fd67a1c31
When the error is due to the object having been deleted, the
controller does not need to do anything before the coming
notification.
Kubernetes-commit: ef1e2039b5fc7f955ec4f9c636a64aa403cba2ab
Collect the parameters of newTestableController into a named type.
Also tolerate the surprising situation in which a request's user
groups include neither `system:authenticated` nor
`system:unauthenticated` --- because this is observed to happen in
some tests.
Also a few other minor fixups.
Kubernetes-commit: 10df6d459b5bca7b42471f9409182417fbc3f253
Changed quantization to use monotonic clock readings.
Stopping panicing when monotonic clock readings go backwards because
https://github.com/kubernetes/kubernetes/issues/96459 reported it
happening.
Re-organized sampleAndWaterMarkHistograms::innerSet to `defer` the
Unlock call, because that is the preferred pattern.
Kubernetes-commit: 0809220fd04d26892f0fcfd3bf54cc4baeda22da
Currently webhook retry backoff parameters are hard coded, we want
to have the ability to configure the backoff parameters for webhook
retry logic.
Kubernetes-commit: 53a1307f68ccf6c9ffd252eeea2b333e818c1103
- Inside WithExponentialBackoff function, handle error returned
by wait.ExponentialBackoff.
- Ensure that the wait time is bound to the given context.
Kubernetes-commit: f8e35de156f212b6989b465e608dd99b525bd5dc
Introduce min, average, and standard deviation for the number of
executing mutating and readOnly requests.
Introduce min, max, average, and standard deviation for the number
waiting and number waiting per priority level.
Later:
Revised to use a series of windows
Use three individuals instead of array of powers
Later:
Add coarse queue count metrics, removed windowed avg and stddev
Add metrics for number of queued mutating and readOnly requests,
to complement metrics for number executing.
Later:
Removed windowed average and standard deviation because consumers can
derive such from integrals of consumer's chosen window.
Also replaced "requestKind" Prometheus label with "request_kind".
Later:
Revised to focus on sampling
Make the clock intrinsic to a TimedObserver
... so that the clock can be read while holding the observer's lock;
otherwise, forward progress is not guaranteed (and violations were
observed in testing).
Bug fixes and histogram buckets revision
SetX1 to 1 when queue length limit is zero, beause dividing by zero is nasty.
Remove obsolete argument in gen_test.go.
Add a bucket boundary at 0 for sample-and-water-mark histograms, to
distinguish zeroes from non-zeros.
This includes adding Integrator test.
Simplified test code.
More pervasively used "ctlr" instead of "ctl" as abbreviation for
"controller".
Kubernetes-commit: 57ecea22296797a93b0157169db0ff2e477f58d0
The current design for Fair Queueing for Server Requests has a
problem: if the min-max fair result stays different from an even
division for a long time and no queue involved in the imbalance goes
empty then the imbalance keeps accruing in queue virtual state times.
This commit adds a test that demonstrates the problem.
It also has some other tweaks to make other tests less flaky.
Factor the big scenario-testing func into pieces, with supporting
structs.
Kubernetes-commit: f3fdd5cf9f51f2a03ebfddef82bc2014e04b62a0
... to match the comment on that field.
Also generalized the test case generator to exercise the new
generality.
Kubernetes-commit: 2e97d3c8732147c3ba2f11d668f50b44e6374348
Added LockingWriteMultipleOnly and LockingWriteOnceOnly interfaces,
so that further extensions are possible (in this package or others).
Moved common SetLocked behavior into promisoid.
Made comments say things that were implied.
Kubernetes-commit: cbdd3a279e6161d73f2c4e8a2b916ae74b258621
Previously, a `decisionCancel` could overwrite a `decisionReject` or
`decisionExecute`, causing confusion. Now a request gets exactly one
decision and there is no confusion.
Also added write-once to the promise package and refactored.
Kubernetes-commit: 1c092bf635954bde9c9c363672fa156b9430206b
So that errors can be detected before resolving concurrency shares
into concurrency counts.
Kubernetes-commit: 1e170637c3ce6c4ccd378275d9e52192f4be12b7
This commit responds to the comments on PR #85192 that were not yet
addressed at the time it merged, apart from the one fixed in PR
Generalized fairqueuing to allow for zero queues, to support a
priority level that limits concurrency but does no queuing.
Kubernetes-commit: b123a43e7117e977606bacd31d77f4a30d2ed212
(1) Replaced random-looking assortment of counter increments and
decrements with something hopefully more principalled-looking. Most
importantly, introduced the MutablePromise abstraction to neatly wrap
up the complicated business of unioning multiple sources of
unblocking.
(2) Improved debug logging.
(3) Somewhat more interesting test cases, and a bug fix wrt round
robin index.
Kubernetes-commit: 1c31b2bdc65377f502c2306dbdf32a802eb1afb7
Clean up useless functions, only keep the basic function Deal
and the function DealIntoHand which will be used by Priority
and Fairness.
Improve some comments for constants and functions.
Introduce Dealer to combine parameters and methods into a whole.
Use fixed-size slice to improve performance.
Use math.Ceil and math.Log2 to calculate required entropy bits.
Make the given hand adaptive to handSize in DealIntoHand.
Signed-off-by: Bruce Ma <brucema19901024@gmail.com>
Kubernetes-commit: 7a3ca070cdd9804a22bf5db8a99576b09fc52484
Changes following up on shuffle sharding util package.
Made the validation checking function return a slice of error messages
rather than just a bit.
Replaced all the `int32` with `int` because this is intended for more
than just the priority-and-faireness feature and so should not be a
slave to its configuration datatypes.
Introduced ShuffleAndDealIntoHand, to make memory allocation the
caller's problem/privilege.
Made the hand uniformity tester avoid reflection, evaluate the
histogram against the expected range of counts, and run multiple test
cases, including one in which the number of hash values is a power of
two with four extra bits (as the validation check requires) and one in
which the deck size is not a power of two.
Kubernetes-commit: da0b647155912c6b1e6b971aa5685768915d810d
Implement several shuffle sharding functions including ShuffleAndDeal,
ShuffleAndDealToSlice.
Add benchmarks and tests for shuffle sharding to test performance,
correctness and distribution uniformity.
Signed-off-by: Bruce Ma <brucema19901024@gmail.com>
Kubernetes-commit: e97eaef4f65ec2cbfebf4fd9e726c9e2a6bf5499
Normal files should have permissions 644 by default,
and does not require the last bit to be
executable
Signed-off-by: Odin Ugedal <odin@ugedal.com>
Kubernetes-commit: 35cb87f9cf71776e99a970dfff751cd29ba7ebfb
Moved all flag code from `staging/src/k8s.io/apiserver/pkg/util/[flag|globalflag]` to `component-base/cli/[flag|globalflag]` except for the term function because of unwanted dependencies.
Kubernetes-commit: 7744f908306e5131be5a94815ac76a7cba6454f2