Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

admission: remove soft/moderate load slots #95590

Merged
merged 1 commit into from
Jan 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 0 additions & 23 deletions pkg/server/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ import (
"github.com/cockroachdb/cockroach/pkg/storage/enginepb"
"github.com/cockroachdb/cockroach/pkg/ts"
"github.com/cockroachdb/cockroach/pkg/util"
"github.com/cockroachdb/cockroach/pkg/util/admission"
"github.com/cockroachdb/cockroach/pkg/util/envutil"
"github.com/cockroachdb/cockroach/pkg/util/humanizeutil"
"github.com/cockroachdb/cockroach/pkg/util/log"
Expand Down Expand Up @@ -343,10 +342,6 @@ type KVConfig struct {
// The value is split evenly between the stores if there are more than one.
CacheSize int64

// SoftSlotGranter can be optionally passed into a store to allow the store
// to perform additional CPU bound work.
SoftSlotGranter *admission.SoftSlotGranter

// TimeSeriesServerConfig contains configuration specific to the time series
// server.
TimeSeriesServerConfig ts.ServerConfig
Expand Down Expand Up @@ -632,19 +627,6 @@ func (e *Engines) Close() {
*e = nil
}

// cpuWorkPermissionGranter implements the pebble.CPUWorkPermissionGranter
// interface.
//type cpuWorkPermissionGranter struct {
//*admission.SoftSlotGranter
//}

//func (c *cpuWorkPermissionGranter) TryGetProcs(count int) int {
//return c.TryGetSlots(count)
//}
//func (c *cpuWorkPermissionGranter) ReturnProcs(count int) {
//c.ReturnSlots(count)
//}

// CreateEngines creates Engines based on the specs in cfg.Stores.
func (cfg *Config) CreateEngines(ctx context.Context) (Engines, error) {
engines := Engines(nil)
Expand Down Expand Up @@ -775,11 +757,6 @@ func (cfg *Config) CreateEngines(ctx context.Context) (Engines, error) {
pebbleConfig.Opts.TableCache = tableCache
pebbleConfig.Opts.MaxOpenFiles = int(openFileLimitPerStore)
pebbleConfig.Opts.Experimental.MaxWriterConcurrency = 2
// TODO(jackson): Implement the new pebble.CPUWorkPermissionGranter
// interface.
//pebbleConfig.Opts.Experimental.CPUWorkPermissionGranter = &cpuWorkPermissionGranter{
//cfg.SoftSlotGranter,
//}
if storeKnobs.SmallEngineBlocks {
for i := range pebbleConfig.Opts.Levels {
pebbleConfig.Opts.Levels[i].BlockSize = 1
Expand Down
5 changes: 0 additions & 5 deletions pkg/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -244,11 +244,6 @@ func NewServer(cfg Config, stopper *stop.Stopper) (*Server, error) {
admissionOptions.Override(opts)
}
gcoords := admission.NewGrantCoordinators(cfg.AmbientCtx, st, admissionOptions, registry)
ssg, err := admission.MakeSoftSlotGranter(gcoords.Regular)
if err != nil {
return nil, errors.Wrap(err, "failed to soft slot granter")
}
cfg.SoftSlotGranter = ssg

engines, err := cfg.CreateEngines(ctx)
if err != nil {
Expand Down
2 changes: 0 additions & 2 deletions pkg/ts/catalog/chart_catalog.go
Original file line number Diff line number Diff line change
Expand Up @@ -3726,8 +3726,6 @@ var charts = []sectionDescription{
Metrics: []string{
"admission.granter.total_slots.kv",
"admission.granter.used_slots.kv",
"admission.granter.total_moderate_slots.kv",
"admission.granter.used_soft_slots.kv",
"admission.granter.used_slots.sql-leaf-start",
"admission.granter.used_slots.sql-root-start",
},
Expand Down
75 changes: 27 additions & 48 deletions pkg/util/admission/grant_coordinator.go
Original file line number Diff line number Diff line change
Expand Up @@ -272,12 +272,8 @@ var _ CPULoadListener = &GrantCoordinator{}

// Options for constructing GrantCoordinators.
type Options struct {
MinCPUSlots int
MaxCPUSlots int
// RunnableAlphaOverride is used to override the alpha value used to
// compute the ewma of the runnable goroutine counts. It is only used
// during testing. A 0 value indicates that there is no override.
RunnableAlphaOverride float64
MinCPUSlots int
MaxCPUSlots int
SQLKVResponseBurstTokens int64
SQLSQLResponseBurstTokens int64
SQLStatementLeafStartWorkSlots int
Expand Down Expand Up @@ -434,10 +430,7 @@ func makeRegularGrantCoordinator(
settings: st,
minCPUSlots: opts.MinCPUSlots,
maxCPUSlots: opts.MaxCPUSlots,
moderateSlotsClamp: opts.MaxCPUSlots,
runnableAlphaOverride: opts.RunnableAlphaOverride,
totalSlotsMetric: metrics.KVTotalSlots,
totalModerateSlotsMetric: metrics.KVTotalModerateSlots,
cpuLoadShortPeriodDurationMetric: metrics.KVCPULoadShortPeriodDuration,
cpuLoadLongPeriodDurationMetric: metrics.KVCPULoadLongPeriodDuration,
slotAdjusterIncrementsMetric: metrics.KVSlotAdjusterIncrements,
Expand All @@ -457,10 +450,8 @@ func makeRegularGrantCoordinator(
kvg := &slotGranter{
coord: coord,
workKind: KVWork,
totalHighLoadSlots: opts.MinCPUSlots,
totalModerateLoadSlots: opts.MinCPUSlots,
totalSlots: opts.MinCPUSlots,
usedSlotsMetric: metrics.KVUsedSlots,
usedSoftSlotsMetric: metrics.KVUsedSoftSlots,
slotsExhaustedDurationMetric: metrics.KVSlotsExhaustedDuration,
}

Expand Down Expand Up @@ -500,11 +491,11 @@ func makeRegularGrantCoordinator(
coord.granters[SQLSQLResponseWork] = tg

sg := &slotGranter{
coord: coord,
workKind: SQLStatementLeafStartWork,
totalHighLoadSlots: opts.SQLStatementLeafStartWorkSlots,
cpuOverload: kvSlotAdjuster,
usedSlotsMetric: metrics.SQLLeafStartUsedSlots,
coord: coord,
workKind: SQLStatementLeafStartWork,
totalSlots: opts.SQLStatementLeafStartWorkSlots,
cpuOverload: kvSlotAdjuster,
usedSlotsMetric: metrics.SQLLeafStartUsedSlots,
}
wqMetrics = makeWorkQueueMetrics(workKindString(SQLStatementLeafStartWork), registry, admissionpb.NormalPri, admissionpb.LockingPri)
req = makeRequester(ambientCtx,
Expand All @@ -514,11 +505,11 @@ func makeRegularGrantCoordinator(
coord.granters[SQLStatementLeafStartWork] = sg

sg = &slotGranter{
coord: coord,
workKind: SQLStatementRootStartWork,
totalHighLoadSlots: opts.SQLStatementRootStartWorkSlots,
cpuOverload: kvSlotAdjuster,
usedSlotsMetric: metrics.SQLRootStartUsedSlots,
coord: coord,
workKind: SQLStatementRootStartWork,
totalSlots: opts.SQLStatementRootStartWorkSlots,
cpuOverload: kvSlotAdjuster,
usedSlotsMetric: metrics.SQLRootStartUsedSlots,
}
wqMetrics = makeWorkQueueMetrics(workKindString(SQLStatementRootStartWork), registry, admissionpb.NormalPri, admissionpb.LockingPri)
req = makeRequester(ambientCtx,
Expand Down Expand Up @@ -585,11 +576,11 @@ func NewGrantCoordinatorSQL(
coord.granters[SQLSQLResponseWork] = tg

sg := &slotGranter{
coord: coord,
workKind: SQLStatementLeafStartWork,
totalHighLoadSlots: opts.SQLStatementLeafStartWorkSlots,
cpuOverload: sqlNodeCPU,
usedSlotsMetric: metrics.SQLLeafStartUsedSlots,
coord: coord,
workKind: SQLStatementLeafStartWork,
totalSlots: opts.SQLStatementLeafStartWorkSlots,
cpuOverload: sqlNodeCPU,
usedSlotsMetric: metrics.SQLLeafStartUsedSlots,
}
wqMetrics = makeWorkQueueMetrics(workKindString(SQLStatementLeafStartWork), registry)
req = makeRequester(ambientCtx,
Expand All @@ -599,11 +590,11 @@ func NewGrantCoordinatorSQL(
coord.granters[SQLStatementLeafStartWork] = sg

sg = &slotGranter{
coord: coord,
workKind: SQLStatementRootStartWork,
totalHighLoadSlots: opts.SQLStatementRootStartWorkSlots,
cpuOverload: sqlNodeCPU,
usedSlotsMetric: metrics.SQLRootStartUsedSlots,
coord: coord,
workKind: SQLStatementRootStartWork,
totalSlots: opts.SQLStatementRootStartWorkSlots,
cpuOverload: sqlNodeCPU,
usedSlotsMetric: metrics.SQLRootStartUsedSlots,
}
wqMetrics = makeWorkQueueMetrics(workKindString(SQLStatementRootStartWork), registry)
req = makeRequester(ambientCtx,
Expand Down Expand Up @@ -919,21 +910,15 @@ func (coord *GrantCoordinator) SafeFormat(s redact.SafePrinter, verb rune) {
case KVWork:
switch g := coord.granters[i].(type) {
case *slotGranter:
kvsa := coord.cpuLoadListener.(*kvSlotAdjuster)
s.Printf(
"%s%s: used: %d, high(moderate)-total: %d(%d) moderate-clamp: %d", curSep, workKindString(kind),
g.usedSlots, g.totalHighLoadSlots, g.totalModerateLoadSlots, kvsa.moderateSlotsClamp)
if g.usedSoftSlots > 0 {
s.Printf(" used-soft: %d", g.usedSoftSlots)
}
s.Printf("%s%s: used: %d, total: %d", curSep, workKindString(kind), g.usedSlots, g.totalSlots)
case *kvStoreTokenGranter:
s.Printf(" io-avail: %d, elastic-disk-bw-tokens-avail: %d", g.availableIOTokens,
g.elasticDiskBWTokensAvailable)
}
case SQLStatementLeafStartWork, SQLStatementRootStartWork:
if coord.granters[i] != nil {
g := coord.granters[i].(*slotGranter)
s.Printf("%s%s: used: %d, total: %d", curSep, workKindString(kind), g.usedSlots, g.totalHighLoadSlots)
s.Printf("%s%s: used: %d, total: %d", curSep, workKindString(kind), g.usedSlots, g.totalSlots)
}
case SQLKVResponseWork, SQLSQLResponseWork:
if coord.granters[i] != nil {
Expand All @@ -953,8 +938,6 @@ func (coord *GrantCoordinator) SafeFormat(s redact.SafePrinter, verb rune) {
type GrantCoordinatorMetrics struct {
KVTotalSlots *metric.Gauge
KVUsedSlots *metric.Gauge
KVTotalModerateSlots *metric.Gauge
KVUsedSoftSlots *metric.Gauge
KVSlotsExhaustedDuration *metric.Counter
KVCPULoadShortPeriodDuration *metric.Counter
KVCPULoadLongPeriodDuration *metric.Counter
Expand All @@ -970,12 +953,8 @@ func (GrantCoordinatorMetrics) MetricStruct() {}

func makeGrantCoordinatorMetrics() GrantCoordinatorMetrics {
m := GrantCoordinatorMetrics{
KVTotalSlots: metric.NewGauge(totalSlots),
KVUsedSlots: metric.NewGauge(addName(workKindString(KVWork), usedSlots)),
// TODO(sumeer): remove moderate load slots and soft slots code and
// metrics #88032.
KVTotalModerateSlots: metric.NewGauge(totalModerateSlots),
KVUsedSoftSlots: metric.NewGauge(usedSoftSlots),
KVTotalSlots: metric.NewGauge(totalSlots),
KVUsedSlots: metric.NewGauge(addName(workKindString(KVWork), usedSlots)),
KVSlotsExhaustedDuration: metric.NewCounter(kvSlotsExhaustedDuration),
KVCPULoadShortPeriodDuration: metric.NewCounter(kvCPULoadShortPeriodDuration),
KVCPULoadLongPeriodDuration: metric.NewCounter(kvCPULoadLongPeriodDuration),
Expand Down
Loading