Skip to content

Commit 90de2d0

Browse files
authored
Merge pull request #75 from binacs/dev/binacs/add-perf-optimizations
perf(system): migrate optimizations for high-water-level and unschedulable scenarios
2 parents 0a1ef60 + afabaab commit 90de2d0

31 files changed

Lines changed: 399 additions & 16 deletions

cmd/scheduler/app/options/options_test.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,11 @@ var (
3838
FLOAT64_3 = 3.0
3939
FLOAT64_10 = 10.0
4040

41-
INT32_0 = int32(0)
42-
INT32_10 = int32(10)
43-
INT32_20 = int32(20)
44-
INT32_40 = int32(40)
41+
INT32_0 = int32(0)
42+
INT32_10 = int32(10)
43+
INT32_20 = int32(20)
44+
INT32_40 = int32(40)
45+
INT32_1000 = int32(1000)
4546

4647
INT64_1 = int64(1)
4748
INT64_2 = int64(2)
@@ -204,6 +205,7 @@ func TestLoadFileV1beta1(t *testing.T) {
204205
},
205206
},
206207
},
208+
ExpectedThroughput: &INT32_1000,
207209
PercentageOfNodesToScore: &INT32_0,
208210
IncreasedPercentageOfNodesToScore: &INT32_0,
209211
DisablePreemption: &FALSE,

pkg/features/godel_features.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,12 @@ const (
8484
//
8585
// Allows to trigger resource reservation in Godel.
8686
ResourceReservation featuregate.Feature = "ResourceReservation"
87+
88+
// owner: @libing.binacs
89+
// alpha: for now
90+
//
91+
// support skipping filtering unchanged nodes.
92+
SkipFilteringUnchangedNodes featuregate.Feature = "SkipFilteringUnchangedNodes"
8793
)
8894

8995
func init() {
@@ -104,4 +110,5 @@ var defaultKubernetesFeatureGates = map[featuregate.Feature]featuregate.FeatureS
104110
EnableColocation: {Default: false, PreRelease: featuregate.Alpha},
105111
SupportRescheduling: {Default: false, PreRelease: featuregate.Alpha},
106112
ResourceReservation: {Default: false, PreRelease: featuregate.Alpha},
113+
SkipFilteringUnchangedNodes: {Default: false, PreRelease: featuregate.Alpha},
107114
}

pkg/framework/api/common_state.go

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ const (
3030
NodePartitionTypeStateKey = "NodePartitionType"
3131
PodLauncherStateKey = "PodLauncher"
3232
PodResourceTypeStateKey = "PodResourceType"
33+
PodSchedulingCtxKey = "PodSchedulingCtx"
3334
PodTraceStateKey = "PodTrace"
3435
NodeGroupStateKey = "NodeGroup"
3536
PotentialVictimsKey = "PotentialVictims"
@@ -45,6 +46,7 @@ const (
4546
NodePartitionTypeMissedErrorString = "failed to get NodePartitionType, supposed to be set in cycle state"
4647
PodLauncherMissedErrorString = "failed to get PodLauncher, supposed to be set in cycle state"
4748
PodResourceTypeMissingErrorString = "failed to get PodResourceType, supposed to be set in cycle state"
49+
PodSchedulingCtxMissingErrorString = "failed to get PodSchedulingCtx, supposed to be set in cycle state"
4850
PodTraceMissingErrorString = "failed to get PodTrace, supposed to be set in cycle state"
4951
NodeGroupMissedErrorString = "failed to get NodeGroup, supposed to be set in cycle state"
5052

@@ -91,6 +93,17 @@ func SetPodLauncherState(podLauncher podutil.PodLauncher, state *CycleState) err
9193
return podutil.PodLauncherUnsupportError
9294
}
9395

96+
func SetPodSchedulingCtxKey(schedulingCtx *PodSchedulingCtx, state *CycleState) error {
97+
if schedulingCtx == nil {
98+
schedulingCtx = &PodSchedulingCtx{}
99+
}
100+
data := &stateData{
101+
data: schedulingCtx,
102+
}
103+
state.Write(PodSchedulingCtxKey, data)
104+
return nil
105+
}
106+
94107
func SetPodTrace(podTrace tracing.SchedulingTrace, state *CycleState) error {
95108
data := &stateData{
96109
data: podTrace,
@@ -242,6 +255,17 @@ func GetPodLauncher(state *CycleState) (podutil.PodLauncher, error) {
242255
return "", PodLauncherMissedError
243256
}
244257

258+
var PodSchedulingCtxMissingError = fmt.Errorf(PodSchedulingCtxMissingErrorString)
259+
260+
func GetPodSchedulingCtx(state *CycleState) (*PodSchedulingCtx, error) {
261+
if data, err := state.Read(PodSchedulingCtxKey); err == nil {
262+
if s, ok := data.(*stateData); ok {
263+
return s.data.(*PodSchedulingCtx), nil
264+
}
265+
}
266+
return nil, PodSchedulingCtxMissingError
267+
}
268+
245269
var PodTraceMissingError = fmt.Errorf(PodTraceMissingErrorString)
246270

247271
func GetPodTrace(state *CycleState) (tracing.SchedulingTrace, error) {

pkg/framework/api/types.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,10 @@ type ClusterEvent struct {
9999
// RecorderFactory builds an EventRecorder for a given scheduler name.
100100
type RecorderFactory func(string) events.EventRecorder
101101

102+
type PodSchedulingCtx struct {
103+
NodeStoreGeneration int64
104+
}
105+
102106
// QueuedPodInfo is a Pod wrapper with additional information related to
103107
// the pod's status in the scheduling queue, such as the timestamp when
104108
// it's added to the queue.
@@ -121,6 +125,8 @@ type QueuedPodInfo struct {
121125
// takes more time.
122126
InitialPreemptAttemptTimestamp time.Time
123127

128+
SchedulingCtx *PodSchedulingCtx
129+
124130
// Fields below are only used by binder, need to move this out of QueuedPodInfo and put them into BinderQueuedPodInfo
125131
// TODO: (liumeng) implement BinderQueuedPodInfo ?
126132
// assumedPod

pkg/scheduler/apis/config/defaults.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,10 @@ func SetDefaults_GodelSchedulerConfiguration(obj *GodelSchedulerConfiguration) {
150150
// We got SubClusterName "" as default.
151151
obj.DefaultProfile = &GodelSchedulerProfile{}
152152
}
153+
if obj.DefaultProfile.ExpectedThroughput == nil {
154+
expectedThroughput := int32(DefaultExpectedThroughput)
155+
obj.DefaultProfile.ExpectedThroughput = &expectedThroughput
156+
}
153157
if obj.DefaultProfile.PercentageOfNodesToScore == nil {
154158
percentageOfNodesToScore := int32(DefaultPercentageOfNodesToScore)
155159
obj.DefaultProfile.PercentageOfNodesToScore = &percentageOfNodesToScore

pkg/scheduler/apis/config/types.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,8 @@ const (
6262
)
6363

6464
const (
65+
DefaultExpectedThroughput = 0
66+
6567
// DefaultPercentageOfNodesToScore defines the percentage of nodes of all nodes
6668
// that once found feasible, the scheduler stops looking for more nodes.
6769
// A value of 0 means adaptive, meaning the scheduler figures out a proper default.
@@ -203,6 +205,8 @@ type GodelSchedulerProfile struct {
203205
// for that preemption plugin.
204206
PreemptionPluginConfigs []PluginConfig
205207

208+
ExpectedThroughput *int32
209+
206210
// TODO: reserve temporarily(godel).
207211
// PercentageOfNodesToScore is the percentage of all nodes that once found feasible
208212
// for running a pod, the scheduler stops its search for more feasible nodes in

pkg/scheduler/apis/config/v1beta1/defaults.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,10 @@ func SetDefaults_GodelSchedulerConfiguration(obj *GodelSchedulerConfiguration) {
150150
// We got SubClusterName "" as default.
151151
obj.DefaultProfile = &GodelSchedulerProfile{}
152152
}
153+
if obj.DefaultProfile.ExpectedThroughput == nil {
154+
expectedThroughput := int32(config.DefaultExpectedThroughput)
155+
obj.DefaultProfile.ExpectedThroughput = &expectedThroughput
156+
}
153157
if obj.DefaultProfile.PercentageOfNodesToScore == nil {
154158
percentageOfNodesToScore := int32(config.DefaultPercentageOfNodesToScore)
155159
obj.DefaultProfile.PercentageOfNodesToScore = &percentageOfNodesToScore

pkg/scheduler/apis/config/v1beta1/types.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,8 @@ type GodelSchedulerProfile struct {
161161
// for that preemption plugin.
162162
PreemptionPluginConfigs []config.PluginConfig `json:"preemptionPluginConfigs,omitempty"`
163163

164+
ExpectedThroughput *int32 `json:"expectedThroughput,omitempty"`
165+
164166
// TODO: reserve temporarily(godel).
165167
// PercentageOfNodesToScore is the percentage of all nodes that once found feasible
166168
// for running a pod, the scheduler stops its search for more feasible nodes in

pkg/scheduler/apis/config/v1beta1/zz_generated.conversion.go

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/scheduler/apis/config/v1beta1/zz_generated.deepcopy.go

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)