@@ -18,9 +18,6 @@ type Workspace struct {
18
18
NrThrottled uint64
19
19
Usage CPUTime
20
20
QoS int
21
-
22
- BaseLimit Bandwidth
23
- BurstLimit Bandwidth
24
21
}
25
22
26
23
type WorkspaceHistory struct {
@@ -116,7 +113,7 @@ func (d *Distributor) Tick(dt time.Duration) (DistributorDebug, error) {
116
113
return DistributorDebug {}, err
117
114
}
118
115
119
- wsidx := make (map [string ]Workspace , len (ws ))
116
+ f := make (map [string ]struct {} , len (ws ))
120
117
for _ , w := range ws {
121
118
h , ok := d .History [w .ID ]
122
119
if ! ok {
@@ -126,10 +123,10 @@ func (d *Distributor) Tick(dt time.Duration) (DistributorDebug, error) {
126
123
d .History [w .ID ] = h
127
124
}
128
125
h .Update (w )
129
- wsidx [w .ID ] = w
126
+ f [w .ID ] = struct {}{}
130
127
}
131
128
for oldWS := range d .History {
132
- if _ , found := wsidx [oldWS ]; ! found {
129
+ if _ , found := f [oldWS ]; ! found {
133
130
delete (d .History , oldWS )
134
131
}
135
132
}
@@ -175,23 +172,15 @@ func (d *Distributor) Tick(dt time.Duration) (DistributorDebug, error) {
175
172
var burstBandwidth Bandwidth
176
173
for _ , id := range wsOrder {
177
174
ws := d .History [id ]
178
- limiter := d .Limiter
179
- if w := wsidx [id ]; w .BaseLimit > 0 {
180
- limiter = FixedLimiter (w .BaseLimit )
181
- }
182
- limit := limiter .Limit (ws .Usage ())
175
+ limit := d .Limiter .Limit (ws .Usage ())
183
176
184
177
// if we didn't get the max bandwidth, but were throttled last time
185
178
// and there's still some bandwidth left to give, let's act as if had
186
179
// never spent any CPU time and assume the workspace will spend their
187
180
// entire bandwidth at once.
188
181
var burst bool
189
182
if totalBandwidth < d .TotalBandwidth && ws .Throttled () {
190
- limiter := d .BurstLimiter
191
- if w := wsidx [id ]; w .BaseLimit > 0 {
192
- limiter = FixedLimiter (w .BurstLimit )
193
- }
194
- limit = limiter .Limit (ws .Usage ())
183
+ limit = d .BurstLimiter .Limit (ws .Usage ())
195
184
196
185
// We assume the workspace is going to use as much as their limit allows.
197
186
// This might not be true, because their process which consumed so much CPU
0 commit comments