Solved Are there consequences for excessive and high load of virtual machine in regard to CPU cores?

Solved issue

CaffeineAddict

Well-Known Member
Joined
Jan 21, 2024
Messages
1,656
Reaction score
1,153
Credits
13,707
So far I've been using VM's only either for fun or for testing purposes.

But now I need to use it rather heavily such that the guest will consume significantly more CPU resources than host.
My CPU is quad core (no hyper threading), therefore only 4 cores available, out of these 4 I allocate 2 cores to VM guest.

Now since the guest will torture the CPU more than host this raises a question...
Those 2 cores allocated to VM will be under more pressure than host's 2 cores, so it follows that CPU lifetime will degrade according to those 2 cores since those 2 are more likely to die out before the host's 2. do you agree?

I don't plan to run VM 24h a day therefore second question is, when launching guest system, how does it choose 2 cores? randomly or always same physical cores?
if it's randomly that's good and solves the problem, if it always chooses same cores then that's the problem.

What I'd like to achieve is equal load on all 4 cores over time, considering that only 2 will be under pressure per guest boot.
 


@CaffeineAddict :-

Eurghh.....well, NO. It doesn't quite work like that..!

Even if an OS's 'scheduler' is instructed to allocate two of those four cores to a VM, the CPU's own internal 'scheduling' will constantly switch that load from one core to another while the VM is active.....specifically to even out wear'n'tear. CPUs do this sort of thing all the time.

You shouldn't actually need to do anything, because the CPU is designed - right from the drawing-board - to take all these varying work-loads into account.


Mike. ;)
 
Last edited:
Even if an OS's 'scheduler' is instructed to allocate two of those four cores to a VM, the CPU's own internal 'scheduling' will constantly switch that load from one core to another while the VM is active.....specifically to even out wear'n'tear. CPUs do this sort of thing all the time.
If I understand this applies to switching between those 2 cores allocated to guest, not all 4 right?
Or are you saying all 4 cores are treated the same?
 
Yup. All four cores are randomly 'loaded', ALL THE TIME. It still has to run the 'host' in the background, regardless of what the VM's doing.....right?

The CPU will take the 'scheduling' given it by the OS, then 'translate' that into activity that will even-out wear'n'tear for its own benefit. They're clever little buggers; there's an awful lot more goes on in the background with a CPU than most people truly understand.

Me, I don't know all the technical details, nor would I pretend to.....but having always been something of a tech 'hardware' afficionado, I've read enough about this kind of thing over the years to understand it in general terms. Enough to give an overview, at any rate.


Mike. :D
 
Yup. All four cores are randomly 'loaded', ALL THE TIME. It still has to run the 'host' in the background, regardless of what the VM's doing.
That's great, I get it but why is then there an option to allocate X cores to VM?
Now I'm wondering what this option does after all, it seems like I could allocate all 4 cores to VM and it would work fine? since the scheduler probably won't make host system unusable.

edit:
The CPU will take the 'scheduling' given it by the OS, then 'translate' that into activity that will even-out wear'n'tear for its own benefit. They're clever little buggers; there's an awful lot more goes on in the background with a CPU than most people truly understand.
Thanks for help, I did a bit of googling about this and must admit this is totally new to me, and yes, you're right, the VM does not lock down cores allocated to it but CPU scheduler will schedule up to X cores to VM as they become available, so all cores are equally and randomly used depending on which one of 4 is free to use.
 
Last edited:
So far I've been using VM's only either for fun or for testing purposes.

But now I need to use it rather heavily such that the guest will consume significantly more CPU resources than host.
My CPU is quad core (no hyper threading), therefore only 4 cores available, out of these 4 I allocate 2 cores to VM guest.

Now since the guest will torture the CPU more than host this raises a question...
Those 2 cores allocated to VM will be under more pressure than host's 2 cores, so it follows that CPU lifetime will degrade according to those 2 cores since those 2 are more likely to die out before the host's 2. do you agree?

I don't plan to run VM 24h a day therefore second question is, when launching guest system, how does it choose 2 cores? randomly or always same physical cores?
if it's randomly that's good and solves the problem, if it always chooses same cores then that's the problem.

What I'd like to achieve is equal load on all 4 cores over time, considering that only 2 will be under pressure per guest boot.
There are few programs that will enable some control over the cpu. The main package of tools is linux-cpupower which can control frequencies of the cpu so that higher more heat inducing frequencies can be reduced if that's an issue.

There's the cpulimit program which can limit a process's cpu usage. It doesn't have the precision of the tools in linux-cpupower because it imposes itself in terms of percentages as the measure of limitation.

There's the cpuset program which can evidently confine processes to a processor subset, but I can't say more since I have no experience with this one, but it might be relevant in the case you describe
 

Members online


Latest posts

Top