@@ -14,33 +14,31 @@ See the License for the specific language governing permissions and
14
14
limitations under the License.
15
15
*/
16
16
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
+ //
23
21
// Fair queuing for server requests is inspired by the fair queuing
24
22
// technique from the world of networking. You can find a good paper
25
23
// on that at https://dl.acm.org/citation.cfm?doid=75247.75248 or
26
24
// http://people.csail.mit.edu/imcgraw/links/research/pubs/networks/WFQ.pdf
27
25
// and there is an implementation outline in the Wikipedia article at
28
26
// https://en.wikipedia.org/wiki/Fair_queuing .
29
-
27
+ //
30
28
// 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
+ //
37
35
// The first two differences can easily be handled by straightforward
38
36
// adaptation of the concept called "R(t)" in the original paper and
39
37
// "virtual time" in the implementation outline. In that
40
38
// implementation outline, the notation now() is used to mean reading
41
39
// 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
44
42
// non-empty queue in the router (regardless of which queue holds the
45
43
// packet that is really being transmitted at the moment); in this
46
44
// conception, a packet is considered to be "in" its queue until the
@@ -55,12 +53,12 @@ package queueset
55
53
// respect to t is
56
54
//
57
55
// 1 / NEQ(t) .
58
-
56
+ //
59
57
// To generalize from transmitting one packet at a time to executing C
60
58
// requests at a time, that derivative becomes
61
59
//
62
60
// C / NEQ(t) .
63
-
61
+ //
64
62
// However, sometimes there are fewer than C requests available to
65
63
// execute. For a given queue "q", let us also write "reqs(q, t)" for
66
64
// the number of requests of that queue that are executing at that
@@ -79,25 +77,25 @@ package queueset
79
77
// real nanosecond). Where the networking implementation outline adds
80
78
// packet size to a virtual time, in our version this corresponds to
81
79
// adding a service time (i.e., duration) to virtual time.
82
-
80
+ //
83
81
// The third difference is handled by modifying the algorithm to
84
82
// dispatch based on an initial guess at the request’s service time
85
83
// (duration) and then make the corresponding adjustments once the
86
84
// request’s actual service time is known. This is similar, although
87
85
// 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
+ //
90
88
// For implementation simplicity (see below), let us use the same
91
89
// initial service time guess for every request; call that duration
92
90
// G. A good choice might be the service time limit (1
93
91
// minute). Different guesses will give slightly different dynamics,
94
92
// but any positive number can be used for G without ruining the
95
93
// long-term behavior.
96
-
94
+ //
97
95
// As in ordinary fair queuing, there is a bound on divergence from
98
96
// the ideal. In plain fair queuing the bound is one packet; in our
99
97
// version it is C requests.
100
-
98
+ //
101
99
// To support efficiently making the necessary adjustments once a
102
100
// request’s actual service time is known, the virtual finish time of
103
101
// a request and the last virtual finish time of a queue are not
@@ -118,3 +116,5 @@ package queueset
118
116
// queue’s virtual start time is advanced by G. When a request
119
117
// finishes being served, and the actual service time was S, the
120
118
// queue’s virtual start time is decremented by G - S.
119
+ //
120
+ package queueset
0 commit comments