Skip to content

Commit 83c1d70

Browse files
authored
Merge pull request kubernetes#85259 from MikeSpreitzer/fq-followup
Brushed up fairqueuing package
2 parents 6c49283 + b123a43 commit 83c1d70

File tree

13 files changed

+273
-193
lines changed

13 files changed

+273
-193
lines changed

staging/src/k8s.io/apiserver/BUILD

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@ filegroup(
4848
"//staging/src/k8s.io/apiserver/pkg/util/flowcontrol/metrics:all-srcs",
4949
"//staging/src/k8s.io/apiserver/pkg/util/flushwriter:all-srcs",
5050
"//staging/src/k8s.io/apiserver/pkg/util/openapi:all-srcs",
51-
"//staging/src/k8s.io/apiserver/pkg/util/promise:all-srcs",
5251
"//staging/src/k8s.io/apiserver/pkg/util/proxy:all-srcs",
5352
"//staging/src/k8s.io/apiserver/pkg/util/shufflesharding:all-srcs",
5453
"//staging/src/k8s.io/apiserver/pkg/util/term:all-srcs",

staging/src/k8s.io/apiserver/pkg/util/flowcontrol/fairqueuing/BUILD

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ filegroup(
1919
name = "all-srcs",
2020
srcs = [
2121
":package-srcs",
22+
"//staging/src/k8s.io/apiserver/pkg/util/flowcontrol/fairqueuing/promise:all-srcs",
2223
"//staging/src/k8s.io/apiserver/pkg/util/flowcontrol/fairqueuing/queueset:all-srcs",
2324
"//staging/src/k8s.io/apiserver/pkg/util/flowcontrol/fairqueuing/testing:all-srcs",
2425
],

staging/src/k8s.io/apiserver/pkg/util/flowcontrol/fairqueuing/interface.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,9 @@ type QueueSetConfig struct {
7070
Name string
7171
// ConcurrencyLimit is the maximum number of requests of this QueueSet that may be executing at a time
7272
ConcurrencyLimit int
73-
// DesiredNumQueues is the number of queues that the API says should exist now
73+
// DesiredNumQueues is the number of queues that the API says
74+
// should exist now. This may be zero, in which case
75+
// QueueLengthLimit, HandSize, and RequestWaitLimit are ignored.
7476
DesiredNumQueues int
7577
// QueueLengthLimit is the maximum number of requests that may be waiting in a given queue at a time
7678
QueueLengthLimit int

staging/src/k8s.io/apiserver/pkg/util/promise/BUILD renamed to staging/src/k8s.io/apiserver/pkg/util/flowcontrol/fairqueuing/promise/BUILD

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ load("@io_bazel_rules_go//go:def.bzl", "go_library")
33
go_library(
44
name = "go_default_library",
55
srcs = ["interface.go"],
6-
importmap = "k8s.io/kubernetes/vendor/k8s.io/apiserver/pkg/util/promise",
7-
importpath = "k8s.io/apiserver/pkg/util/promise",
6+
importmap = "k8s.io/kubernetes/vendor/k8s.io/apiserver/pkg/util/flowcontrol/fairqueuing/promise",
7+
importpath = "k8s.io/apiserver/pkg/util/flowcontrol/fairqueuing/promise",
88
visibility = ["//visibility:public"],
99
)
1010

@@ -19,7 +19,7 @@ filegroup(
1919
name = "all-srcs",
2020
srcs = [
2121
":package-srcs",
22-
"//staging/src/k8s.io/apiserver/pkg/util/promise/lockingpromise:all-srcs",
22+
"//staging/src/k8s.io/apiserver/pkg/util/flowcontrol/fairqueuing/promise/lockingpromise:all-srcs",
2323
],
2424
tags = ["automanaged"],
2525
visibility = ["//visibility:public"],
File renamed without changes.

staging/src/k8s.io/apiserver/pkg/util/promise/lockingpromise/BUILD renamed to staging/src/k8s.io/apiserver/pkg/util/flowcontrol/fairqueuing/promise/lockingpromise/BUILD

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@ load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")
33
go_library(
44
name = "go_default_library",
55
srcs = ["lockingpromise.go"],
6-
importmap = "k8s.io/kubernetes/vendor/k8s.io/apiserver/pkg/util/promise/lockingpromise",
7-
importpath = "k8s.io/apiserver/pkg/util/promise/lockingpromise",
6+
importmap = "k8s.io/kubernetes/vendor/k8s.io/apiserver/pkg/util/flowcontrol/fairqueuing/promise/lockingpromise",
7+
importpath = "k8s.io/apiserver/pkg/util/flowcontrol/fairqueuing/promise/lockingpromise",
88
visibility = ["//visibility:public"],
99
deps = [
1010
"//staging/src/k8s.io/apiserver/pkg/util/flowcontrol/counter:go_default_library",
11-
"//staging/src/k8s.io/apiserver/pkg/util/promise:go_default_library",
11+
"//staging/src/k8s.io/apiserver/pkg/util/flowcontrol/fairqueuing/promise:go_default_library",
1212
],
1313
)
1414

staging/src/k8s.io/apiserver/pkg/util/promise/lockingpromise/lockingpromise.go renamed to staging/src/k8s.io/apiserver/pkg/util/flowcontrol/fairqueuing/promise/lockingpromise/lockingpromise.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import (
2020
"sync"
2121

2222
"k8s.io/apiserver/pkg/util/flowcontrol/counter"
23-
"k8s.io/apiserver/pkg/util/promise"
23+
"k8s.io/apiserver/pkg/util/flowcontrol/fairqueuing/promise"
2424
)
2525

2626
// lockingPromise implements LockingMutable based on a condition
File renamed without changes.

staging/src/k8s.io/apiserver/pkg/util/flowcontrol/fairqueuing/queueset/BUILD

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ go_library(
1515
"//staging/src/k8s.io/apimachinery/pkg/util/runtime:go_default_library",
1616
"//staging/src/k8s.io/apiserver/pkg/util/flowcontrol/counter:go_default_library",
1717
"//staging/src/k8s.io/apiserver/pkg/util/flowcontrol/fairqueuing:go_default_library",
18+
"//staging/src/k8s.io/apiserver/pkg/util/flowcontrol/fairqueuing/promise:go_default_library",
19+
"//staging/src/k8s.io/apiserver/pkg/util/flowcontrol/fairqueuing/promise/lockingpromise:go_default_library",
1820
"//staging/src/k8s.io/apiserver/pkg/util/flowcontrol/metrics:go_default_library",
19-
"//staging/src/k8s.io/apiserver/pkg/util/promise:go_default_library",
20-
"//staging/src/k8s.io/apiserver/pkg/util/promise/lockingpromise:go_default_library",
2121
"//staging/src/k8s.io/apiserver/pkg/util/shufflesharding:go_default_library",
2222
"//vendor/github.com/pkg/errors:go_default_library",
2323
"//vendor/k8s.io/klog:go_default_library",

staging/src/k8s.io/apiserver/pkg/util/flowcontrol/fairqueuing/queueset/doc.go

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -14,33 +14,31 @@ See the License for the specific language governing permissions and
1414
limitations under the License.
1515
*/
1616

17-
package queueset
18-
19-
// This package implements a technique called "fair queuing for server
20-
// requests". One QueueSet is a set of queues operating according to
21-
// this technique.
22-
17+
// Package queueset implements a technique called "fair queuing for
18+
// server requests". One QueueSet is a set of queues operating
19+
// according to this technique.
20+
//
2321
// Fair queuing for server requests is inspired by the fair queuing
2422
// technique from the world of networking. You can find a good paper
2523
// on that at https://dl.acm.org/citation.cfm?doid=75247.75248 or
2624
// http://people.csail.mit.edu/imcgraw/links/research/pubs/networks/WFQ.pdf
2725
// and there is an implementation outline in the Wikipedia article at
2826
// https://en.wikipedia.org/wiki/Fair_queuing .
29-
27+
//
3028
// Fair queuing for server requests differs from traditional fair
31-
// queuing in three ways: (1) we are dispatching requests to be
32-
// executed within a process rather than transmitting packets on a
33-
// network link, (2) multiple requests can be executing at once, and
34-
// (3) the service time (execution duration) is not known until the
35-
// execution completes.
36-
29+
// queuing in three ways: (1) we are dispatching application layer
30+
// requests to a server rather than transmitting packets on a network
31+
// link, (2) multiple requests can be executing at once, and (3) the
32+
// service time (execution duration) is not known until the execution
33+
// completes.
34+
//
3735
// The first two differences can easily be handled by straightforward
3836
// adaptation of the concept called "R(t)" in the original paper and
3937
// "virtual time" in the implementation outline. In that
4038
// implementation outline, the notation now() is used to mean reading
4139
// the virtual clock. In the original paper’s terms, "R(t)" is the
42-
// number of "rounds" that have been completed at real time t, where a
43-
// round consists of virtually transmitting one bit from every
40+
// number of "rounds" that have been completed at real time t ---
41+
// where a round consists of virtually transmitting one bit from every
4442
// non-empty queue in the router (regardless of which queue holds the
4543
// packet that is really being transmitted at the moment); in this
4644
// conception, a packet is considered to be "in" its queue until the
@@ -55,12 +53,12 @@ package queueset
5553
// respect to t is
5654
//
5755
// 1 / NEQ(t) .
58-
56+
//
5957
// To generalize from transmitting one packet at a time to executing C
6058
// requests at a time, that derivative becomes
6159
//
6260
// C / NEQ(t) .
63-
61+
//
6462
// However, sometimes there are fewer than C requests available to
6563
// execute. For a given queue "q", let us also write "reqs(q, t)" for
6664
// the number of requests of that queue that are executing at that
@@ -79,25 +77,25 @@ package queueset
7977
// real nanosecond). Where the networking implementation outline adds
8078
// packet size to a virtual time, in our version this corresponds to
8179
// adding a service time (i.e., duration) to virtual time.
82-
80+
//
8381
// The third difference is handled by modifying the algorithm to
8482
// dispatch based on an initial guess at the request’s service time
8583
// (duration) and then make the corresponding adjustments once the
8684
// request’s actual service time is known. This is similar, although
8785
// not exactly isomorphic, to the original paper’s adjustment by
88-
// `$delta` for the sake of promptness.
89-
86+
// `$\delta$` for the sake of promptness.
87+
//
9088
// For implementation simplicity (see below), let us use the same
9189
// initial service time guess for every request; call that duration
9290
// G. A good choice might be the service time limit (1
9391
// minute). Different guesses will give slightly different dynamics,
9492
// but any positive number can be used for G without ruining the
9593
// long-term behavior.
96-
94+
//
9795
// As in ordinary fair queuing, there is a bound on divergence from
9896
// the ideal. In plain fair queuing the bound is one packet; in our
9997
// version it is C requests.
100-
98+
//
10199
// To support efficiently making the necessary adjustments once a
102100
// request’s actual service time is known, the virtual finish time of
103101
// a request and the last virtual finish time of a queue are not
@@ -118,3 +116,5 @@ package queueset
118116
// queue’s virtual start time is advanced by G. When a request
119117
// finishes being served, and the actual service time was S, the
120118
// queue’s virtual start time is decremented by G - S.
119+
//
120+
package queueset

0 commit comments

Comments
 (0)