-
Notifications
You must be signed in to change notification settings - Fork 43
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
feat: Support dedicated CPU placement #19
Conversation
Codecov Report
@@ Coverage Diff @@
## main #19 +/- ##
==========================================
+ Coverage 26.79% 30.17% +3.38%
==========================================
Files 2 3 +1
Lines 780 845 +65
==========================================
+ Hits 209 255 +46
- Misses 526 545 +19
Partials 45 45
Help us with your feedback. Take ten seconds to tell us how you rate us. |
e1d27a2
to
43388c5
Compare
@@ -45,9 +46,17 @@ func main() { | |||
if vmConfig.Cmdline != nil { | |||
cloudHypervisorCmd = append(cloudHypervisorCmd, "--cmdline", fmt.Sprintf("'%s'", vmConfig.Cmdline.Args)) | |||
} | |||
cloudHypervisorCmd = append(cloudHypervisorCmd, "--cpus", fmt.Sprintf("boot=%d,topology=%d:%d:%d:%d", | |||
vcpuToPCPU := []string{} |
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.
Add a blank line above would be better
cmd/virt-prerunner/main.go
Outdated
for i := 0; i < numVCPUs; i++ { | ||
vmConfig.Cpus.Affinity = append(vmConfig.Cpus.Affinity, &cloudhypervisor.CpuAffinity{ | ||
Vcpu: i, | ||
HostCpus: []int{pcpus[i%numPCPUs]}, |
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 add a webhook validation for CPU resources? If the CPU resource is not guaranteed, it may not be a good idea to bind vCPUs here?
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.
It's optional for user to configure kubelet CPU manager policy to Static
and use Guaranteed
pod to get exclusive CPUs on the node, but user can get better performance by using Static
policy and Guaranteed
QOS. Without any configuration, we bind vCPU to avoid cache missing causing by CPU migration.
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.
If the VM pod is not in the Guaranteed group, it could see all PCPUs are available for binding? If so, the i%numPCPUs
part would always choose to bind the first several PCPUs?
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.
Right, maybe a random algorithm of binding vCPUs could be better. For example, binding vCPUs[0,1,2,3,4,5] to pCPUs[0,1,2,3] can be resolved as follows:
step1: Use each pCPU in a balanced manner. vCPU -> pCPU [0 -> 0, 1 -> 1, 2 -> 2, 3 -> 3]
step2: Bind the other vCPUs randomly. vCPU -> pCPU [4 -> one of 0-3, 5 -> one of 0-3]
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.
I'm still having a bad feeling about this. It's neither dedicated nor efficient to bind vCPUs to physical cores if they have unmatched numbers.
1ca5c9c
to
163e8ee
Compare
163e8ee
to
834faef
Compare
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.
LGTM
No description provided.