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

move prefilter out of predicates to improve performance #2580

Merged
merged 1 commit into from
Nov 29, 2022

Conversation

elinx
Copy link

@elinx elinx commented Nov 28, 2022

  • when porting kube-scheduler plugins, the current implementation put PreFilter together with Filter into PredicateFn, the PredicateFn process each pod-node pair like the following pseudo code:
    for pod in pods:
      for nodes in nodes:
        predicateFn(pod, node) # prefilters & filters
  • it's functioning well while PreFilter only needs the pod object(no node required), we don't need to put it in the innermost loop. So a promotion of PreFilter to the outer loop is made in this pr for performance's sake, as a plugin like inter-pod-afftinity is very time-consuming to prepare the pod interconnections in PreFilter. After this pr:
    for pod in pods:
      prePredicateFn(pod) # prefilters
      for nodes in nodes:
        predicateFn(pod, node) # filters
  • Implementation notes:
    • Is it right to put stat in OnSessionOpen as previously put into the PredicateFn?
      yes, it's correct, just as the type of stat suggested CycleState its lifecycle should be in the whole scheduling cycle, and the kube-scheduler creates it in the ScheduleOnce function
      	  func (sched *Scheduler) scheduleOne(ctx context.Context) {
      	  	// ...
      	  	state := framework.NewCycleState()
      	    	scheduleResult, err := 
      	    		sched.Algorithm.Schedule(schedulingCycleCtx, prof, state, pod)
      	      // ...
      	  }
    • is it thread-safe to separate write(in PreFilter) and read (in Filter)?
      yes, the underlining data structure is a thread-safe map for CycleState to access data

resolves #2583

@volcano-sh-bot volcano-sh-bot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Nov 28, 2022
@elinx elinx force-pushed the bugfix-prefilter branch 4 times, most recently from a9304a9 to 8a95161 Compare November 28, 2022 06:43
Signed-off-by: xilinxing <xilinxing@huawei.com>
Copy link
Contributor

@Thor-wl Thor-wl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the optimization. It looks OK for me generally.

@volcano-sh-bot volcano-sh-bot added the lgtm Indicates that a PR is ready to be merged. label Nov 29, 2022
@volcano-sh-bot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: Thor-wl

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@volcano-sh-bot volcano-sh-bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Nov 29, 2022
@volcano-sh-bot volcano-sh-bot merged commit 7157ada into volcano-sh:master Nov 29, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. lgtm Indicates that a PR is ready to be merged. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

scheduling performance drop with a large amount of pods existing
3 participants