Skip to content

Commit 5472512

Browse files
committed
admission: remove unused grantKind
Epic: none Release note: None
1 parent 004984b commit 5472512

File tree

7 files changed

+8
-46
lines changed

7 files changed

+8
-46
lines changed

pkg/util/admission/admission.go

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,6 @@ type requester interface {
167167
// WorkKind will interact with a granter. See admission.go for an overview of
168168
// how this fits into the overall structure.
169169
type granter interface {
170-
grantKind() grantKind
171170
// tryGet is used by a requester to get slots/tokens for a piece of work
172171
// that has encountered no waiting/queued work. This is the fast path that
173172
// avoids queueing in the requester. The optional parameter
@@ -379,8 +378,9 @@ type elasticCPULimiter interface {
379378
// expect this to be called every scheduler_latency.sample_period.
380379
type SchedulerLatencyListener = schedulerlatency.LatencyObserver
381380

382-
// grantKind represents the two kind of ways we grant admission: using a slot
383-
// or a token. The slot terminology is akin to a scheduler, where a scheduling
381+
// There are two ways we grant admission: using a slot or a token.
382+
//
383+
// The slot terminology is akin to a scheduler, where a scheduling
384384
// slot must be free for a thread to run. But unlike a scheduler, we don't
385385
// have visibility into the fact that work execution may be blocked on IO. So
386386
// a slot can also be viewed as a limit on concurrency of ongoing work. The
@@ -402,12 +402,6 @@ type SchedulerLatencyListener = schedulerlatency.LatencyObserver
402402
// completion information such as how many tokens were actually used, which
403403
// can differ from the up front information, and is utilized to adjust the
404404
// available tokens.
405-
type grantKind int8
406-
407-
const (
408-
slot grantKind = iota
409-
token
410-
)
411405

412406
type grantResult int8
413407

pkg/util/admission/elastic_cpu_granter.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -140,11 +140,6 @@ func (e *elasticCPUGranter) setRequester(requester requester) {
140140
e.requester = requester
141141
}
142142

143-
// grantKind implements granter.
144-
func (e *elasticCPUGranter) grantKind() grantKind {
145-
return token
146-
}
147-
148143
// tryGet implements granter.
149144
func (e *elasticCPUGranter) tryGet(_ burstQualification, count int64) (granted bool) {
150145
e.mu.Lock()

pkg/util/admission/elastic_cpu_work_queue_test.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -126,10 +126,6 @@ type testElasticCPUGranter struct {
126126

127127
var _ granter = &testElasticCPUGranter{}
128128

129-
func (t *testElasticCPUGranter) grantKind() grantKind {
130-
return token
131-
}
132-
133129
func (t *testElasticCPUGranter) tryGet(_ burstQualification, count int64) (granted bool) {
134130
panic("unimplemented")
135131
}

pkg/util/admission/granter.go

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,6 @@ type slotGranter struct {
4747
var _ granterWithLockedCalls = &slotGranter{}
4848
var _ granter = &slotGranter{}
4949

50-
// grantKind implements granter.
51-
func (sg *slotGranter) grantKind() grantKind {
52-
return slot
53-
}
54-
5550
// tryGet implements granter.
5651
func (sg *slotGranter) tryGet(_ burstQualification, count int64) bool {
5752
return sg.coord.tryGet(sg.workKind, count, 0 /*arbitrary*/)
@@ -188,11 +183,6 @@ func (tg *tokenGranter) refillBurstTokens(skipTokenEnforcement bool) {
188183
tg.skipTokenEnforcement = skipTokenEnforcement
189184
}
190185

191-
// grantKind implements granter.
192-
func (tg *tokenGranter) grantKind() grantKind {
193-
return token
194-
}
195-
196186
// tryGet implements granter.
197187
func (tg *tokenGranter) tryGet(_ burstQualification, count int64) bool {
198188
return tg.coord.tryGet(tg.workKind, count, 0 /*arbitrary*/)
@@ -336,11 +326,6 @@ type kvStoreTokenChildGranter struct {
336326
var _ granterWithStoreReplicatedWorkAdmitted = &kvStoreTokenChildGranter{}
337327
var _ granter = &kvStoreTokenChildGranter{}
338328

339-
// grantKind implements granter.
340-
func (cg *kvStoreTokenChildGranter) grantKind() grantKind {
341-
return token
342-
}
343-
344329
// tryGet implements granter.
345330
func (cg *kvStoreTokenChildGranter) tryGet(_ burstQualification, count int64) bool {
346331
return cg.parent.tryGet(cg.workType, count)

pkg/util/admission/replicated_write_admission_test.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -380,9 +380,6 @@ func newTestReplicatedWriteGranter(
380380
buf: buf,
381381
}
382382
}
383-
func (tg *testReplicatedWriteGranter) grantKind() grantKind {
384-
return token
385-
}
386383

387384
func (tg *testReplicatedWriteGranter) tryGet(_ burstQualification, count int64) bool {
388385
if count > tg.tokens {

pkg/util/admission/snapshot_queue_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ func TestSnapshotQueue(t *testing.T) {
4646
switch d.Cmd {
4747
case "init":
4848
closeFn()
49-
tg = &testGranter{gk: token, buf: &buf}
49+
tg = &testGranter{buf: &buf}
5050
q = makeSnapshotQueue(tg, metrics)
5151
q.ts = timeutil.NewManualTime(initialTime)
5252
tg.r = q

pkg/util/admission/work_queue_test.go

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@ func (b *builderWithMu) stringAndReset() string {
5858
}
5959

6060
type testGranter struct {
61-
gk grantKind
6261
name string
6362
buf *builderWithMu
6463
r requester
@@ -70,10 +69,6 @@ type testGranter struct {
7069

7170
var _ granterWithStoreReplicatedWorkAdmitted = &testGranter{}
7271

73-
func (tg *testGranter) grantKind() grantKind {
74-
return tg.gk
75-
}
76-
7772
func (tg *testGranter) tryGet(_ burstQualification, count int64) bool {
7873
tg.buf.printf("tryGet%s: returning %t", tg.name, tg.returnValueFromTryGet)
7974
return tg.returnValueFromTryGet
@@ -192,7 +187,7 @@ func TestWorkQueueBasic(t *testing.T) {
192187
switch d.Cmd {
193188
case "init":
194189
closeFn()
195-
tg = &testGranter{gk: slot, buf: &buf}
190+
tg = &testGranter{buf: &buf}
196191
opts := makeWorkQueueOptions(KVWork)
197192
timeSource = timeutil.NewManualTime(initialTime)
198193
opts.timeSource = timeSource
@@ -375,7 +370,7 @@ func TestWorkQueueTokenResetRace(t *testing.T) {
375370
defer log.Scope(t).Close(t)
376371

377372
var buf builderWithMu
378-
tg := &testGranter{gk: slot, buf: &buf}
373+
tg := &testGranter{buf: &buf}
379374
st := cluster.MakeTestingClusterSettings()
380375
registry := metric.NewRegistry()
381376
metrics := makeWorkQueueMetrics("", registry)
@@ -566,8 +561,8 @@ func TestStoreWorkQueueBasic(t *testing.T) {
566561
switch d.Cmd {
567562
case "init":
568563
closeFn()
569-
tg[admissionpb.RegularWorkClass] = &testGranter{gk: token, name: " regular", buf: &buf}
570-
tg[admissionpb.ElasticWorkClass] = &testGranter{gk: token, name: " elastic", buf: &buf}
564+
tg[admissionpb.RegularWorkClass] = &testGranter{name: " regular", buf: &buf}
565+
tg[admissionpb.ElasticWorkClass] = &testGranter{name: " elastic", buf: &buf}
571566
opts := makeWorkQueueOptions(KVWork)
572567
opts.usesTokens = true
573568
opts.timeSource = timeutil.NewManualTime(timeutil.FromUnixMicros(0))

0 commit comments

Comments
 (0)