-
Notifications
You must be signed in to change notification settings - Fork 43
Debate what the default number of VCPUs should be #335
Comments
IMHO runtime should define vCPUs default number if we consider virtcontainers as a library. |
@dvoytik I agree, I think runtimes should have their own idea of a default vCPUs if they have a 'good notion' of what that should be. We should probably treat the |
I agree with both of you. The runtime has to be able to decide what he wants, and this is already an available configuration option, thus nothing to do for that part. const (
minVCPUs = 2
maxVCPUs = 8
)
defaultVCPUs := systemNumProc / 2
if defaultVCPUs < minVCPUs {
defaultVCPUs = minVCPUs
} else if defaultVCPUs > maxVCPUs {
defaultVCPUs = maxVCPUs
} |
Given we have clearcontainers/runtime#297 (thanks @dvoytik ;-), so I believe we have the facility to over-ride the defaults... I like the above proposed code snippet.
|
@grahamwhaley godoc sounds good to me. There is no maintenance, everything is generated automatically here https://godoc.org/github.com/containers/virtcontainers. |
@sboeuf @grahamwhaley we can choose a sane number as the default. This can be 2. However the runtime should set the number of vCPUs == number of system physical CPUs to approximate runc behavior. If the user wants to constrain the same, we should honor it once we support the cpu and cpu set options. |
@mcastelino just to make sure I understand properly, you're suggesting only a minimal value, but no maximal value, right ? |
@sboeuf yes. The library should not bound the maximal value. The runtime should be able to choose any number. Also is there a reason to bound the minimal value? Yes to boot up will be slow if the value is set to 1. But but setting it to 2, when the value requested is 1, also does not quite make sense. Specially if the user is more concerned about constraining the program. One of the advantages clear containers has over a namespaced container is the ability to actually control the visibility of the CPUs (and for that matter memory) For example in the case of runc
Will yield more than 2 cpu's. With clear containers we have the ability to limit to explicitly the number of cpus specified in --cpu. This allows a certain class of applications that look at such information to decide the number of threads to spawn and other characteristics to run in clear container, to run unmodified from their original design from a VM world. |
@mcastelino well the thing is that as long as we get this value (number of CPUs) from the runtime, we will use it. |
@sboeuf that helps. So what does the runtime send to the library today when docker/kubernetes leave the --cpu unspecified. If they do not send anything, the right behavior of virtcontainer should be IMO
or
or
seems arbitrary. |
Currently we set the default number of VCPUs to be 1:
https://github.com/containers/virtcontainers/blob/master/hypervisor.go#L36
This is one obvious and safe default, but from some testing (under https://github.com/clearcontainers/runtime), it seems that running up the VM (qemu/KVM) with only one VCPU causes some performance issues (startup takes twice as long for instance). (side note - this happened as the Clear Containers
cc-runtime
failed to find a valid config file upon startup during some debug, so took the default value for number of VCPUs from virtcontainers....).Thus, we should debate if this needs changing or not. Obvious options are:
The text was updated successfully, but these errors were encountered: