-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Run scheduler predicates in parallel #8729
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -17,6 +17,7 @@ limitations under the License. | |
| package predicate | ||
|
|
||
| import ( | ||
| "fmt" | ||
| "os" | ||
| "path/filepath" | ||
| "testing" | ||
|
|
@@ -363,6 +364,58 @@ func newTestPluginRunnerAndSnapshot(schedConfig *config.KubeSchedulerConfigurati | |
| if err != nil { | ||
| return nil, nil, err | ||
| } | ||
| snapshot := NewPredicateSnapshot(store.NewBasicSnapshotStore(), fwHandle, true) | ||
| return NewSchedulerPluginRunner(fwHandle, snapshot), snapshot, nil | ||
| snapshot := NewPredicateSnapshot(store.NewBasicSnapshotStore(), fwHandle, true, 1) | ||
| return NewSchedulerPluginRunner(fwHandle, snapshot, 1), snapshot, nil | ||
| } | ||
|
|
||
| func BenchmarkRunFiltersUntilPassingNode(b *testing.B) { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we want to add something like
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| pod := BuildTestPod("p", 100, 1000) | ||
| nodes := make([]*apiv1.Node, 0, 5001) | ||
| podsOnNodes := make(map[string][]*apiv1.Pod) | ||
|
|
||
| for i := 0; i < 5000; i++ { | ||
| nodeName := fmt.Sprintf("n-%d", i) | ||
| node := BuildTestNode(nodeName, 10, 1000) | ||
| nodes = append(nodes, node) | ||
| // Add 10 small pods to each node | ||
| pods := make([]*apiv1.Pod, 0, 10) | ||
| for j := 0; j < 10; j++ { | ||
| pods = append(pods, BuildTestPod(fmt.Sprintf("p-%d-%d", i, j), 1, 1)) | ||
| } | ||
| podsOnNodes[nodeName] = pods | ||
| } | ||
| // Last node is the only one that can fit the pod. | ||
| lastNodeName := fmt.Sprintf("n-%d", len(nodes)) | ||
| lastNode := BuildTestNode(lastNodeName, 1000, 1000) | ||
| nodes = append(nodes, lastNode) | ||
|
|
||
| pluginRunner, snapshot, err := newTestPluginRunnerAndSnapshot(nil) | ||
| assert.NoError(b, err) | ||
|
|
||
| for _, node := range nodes { | ||
| err := snapshot.AddNodeInfo(framework.NewTestNodeInfo(node, podsOnNodes[node.Name]...)) | ||
| assert.NoError(b, err) | ||
| } | ||
|
|
||
| testCases := []struct { | ||
| parallelism int | ||
| }{ | ||
| {parallelism: 1}, | ||
| {parallelism: 2}, | ||
| {parallelism: 4}, | ||
| {parallelism: 8}, | ||
| {parallelism: 16}, | ||
| } | ||
|
|
||
| for _, tc := range testCases { | ||
| b.Run(fmt.Sprintf("parallelism-%d", tc.parallelism), func(b *testing.B) { | ||
| pluginRunner.parallelism = tc.parallelism | ||
| b.ResetTimer() | ||
| for i := 0; i < b.N; i++ { | ||
| pluginRunner.lastIndex = 0 // Reset state for each run | ||
| _, _, err := pluginRunner.RunFiltersUntilPassingNode(pod, func(info *framework.NodeInfo) bool { return true }) | ||
| assert.NoError(b, err) | ||
| } | ||
| }) | ||
| } | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should we fail if someone passes in 0 (and/or should we enforce an upper boundary?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good idea - added validation for lower bound. For upper bound I don't see the need to add an artificial limit, so not checking it.