-
Notifications
You must be signed in to change notification settings - Fork 337
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
descheduler: optimize sortfn implementation #1711
Conversation
Signed-off-by: baowj <[email protected]>
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## main #1711 +/- ##
==========================================
+ Coverage 65.91% 65.96% +0.05%
==========================================
Files 385 386 +1
Lines 41639 41918 +279
==========================================
+ Hits 27447 27652 +205
- Misses 12155 12224 +69
- Partials 2037 2042 +5
Flags with carried forward coverage won't be shown. Click here to find out more.
☔ View full report in Codecov by Sentry. |
Signed-off-by: baowj <[email protected]>
…riority. Signed-off-by: baowj <[email protected]>
…igratingNum. Signed-off-by: baowj <[email protected]>
Signed-off-by: baowj <[email protected]>
// SortFn stably sorts PodMigrationJobs slice based on a certain strategy. Users | ||
// can implement different SortFn according to their needs. | ||
type SortFn func(jobs []*v1alpha1.PodMigrationJob, podOfJob map[*v1alpha1.PodMigrationJob]*corev1.Pod) []*v1alpha1.PodMigrationJob | ||
type SortFn func(jobs []*v1alpha1.PodMigrationJob, podOfJob map[*v1alpha1.PodMigrationJob]*corev1.Pod) CompareFn |
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.
为什么一个SortFn 的函数的返回值是一个CompareFn? SortFn对输入的对象排序,按理说是不需要返回值的,更不要说返回一个CompareFn。
是不是可以理解为之前的SortFn都应该转为CompareFn?
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.
是的,之前的sortfn会输出每个job的排序优先级的map,然后返回的comparefn会依据该map进行排序,这样sort函数就只用调用一次
return job.Status.Phase == v1alpha1.PodMigrationJobRunning || | ||
(job.Status.Phase == v1alpha1.PodMigrationJobPending && f.checkJobPassedArbitration(job.UID)) | ||
}), | ||
SortJobsByPod([]sorter.CompareFn{ |
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.
这个实现和之前相比较,没有必要的。就算是需要,我想也可以再构造一个sorter传入也OK?
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.
嗯嗯,我改成从New中以参数传入
Signed-off-by: baowj <[email protected]>
/milestone v1.4 |
Ⅰ. Describe what this PR does
optimize sortfn implementation.
Ⅱ. Does this pull request fix one issue?
fixes #1644
Ⅲ. Describe how to verify it
Ⅳ. Special notes for reviews
V. Checklist
make test