Processors vs Execution Cap

This is for discussing general topics about how to use VirtualBox.
Post Reply
LPChip
Posts: 18
Joined: 30. Apr 2019, 22:17

Processors vs Execution Cap

Post by LPChip »

I'm wondering, is there any reason why one would choose one of the following scenarios above the other?

- Set the Processors to use to 1 of 8 processors and the execution cap to 100%
- Set the Processors to use to 2 of 8 processors and the execution cap to 50%
- Set the Processors to use to 4 of 8 processors and the execution cap to 25%

And repeat the above for 4 different VM's.

So in essence, each VM would use the same amount of processor time with the biggest difference that a VM would have 1, 2 or 4 cores, but each core is reduced in speeds. In theory the 3rd option would give me more speed because with 4 cores, the guest could run 4 tasks concurrently, even at lower speeds.

Is this actually something I should do, or should I always go for the 1st solution? 4 of the processors are obviously reserved for the host itself, which is what Oracle VirtualBox would show when you try to assign them anyway.

I haven't actually tried to set this up, but I'm playing with this idea (but with different numbers) and knowing how this works will make the decision making a lot easier.

Any help or insight is greatly appreciated. :)
LPChip
Posts: 18
Joined: 30. Apr 2019, 22:17

Re: Processors vs Execution Cap

Post by LPChip »

I guess no one knows the answer... Pity.
scottgus1
Site Moderator
Posts: 20965
Joined: 30. Dec 2009, 20:14
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Windows, Linux

Re: Processors vs Execution Cap

Post by scottgus1 »

No results of your own experimentation are posted. Bigger pity.
mpack
Site Moderator
Posts: 39156
Joined: 4. Sep 2008, 17:09
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Mostly XP

Re: Processors vs Execution Cap

Post by mpack »

Core count is not solely concerned with performance when running flat out, it also about ease of context switching. If you use actual cores running at 100%, with VT-x/AMD-v enabled, then that would be ideal.
LPChip
Posts: 18
Joined: 30. Apr 2019, 22:17

Re: Processors vs Execution Cap

Post by LPChip »

mpack wrote:Core count is not solely concerned with performance when running flat out, it also about ease of context switching. If you use actual cores running at 100%, with VT-x/AMD-v enabled, then that would be ideal.
That is what I am doing now actually, although I do have a bit of overhead.
scottgus1
Site Moderator
Posts: 20965
Joined: 30. Dec 2009, 20:14
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Windows, Linux

Re: Processors vs Execution Cap

Post by scottgus1 »

I remember reading a few posts by Mpack that when Virtualbox has to use 2 or more processors to run a guest's programs, it sometimes (all the time?) has to schedule the use of the processors (the "context switching" Mpack mentioned above). Two processors running a program will have context switching, and so have more instructions to carry out than one processor running the program. So my probably-wrong-because-I-haven't-experimented thought is that two processors on 50% cap will take longer on a task than 1 processor on 100%. And the task being run has to be designed for multi-processor running, so a single-thread task will take even longer to complete on a less-than-100%-cap processor.
LPChip
Posts: 18
Joined: 30. Apr 2019, 22:17

Re: Processors vs Execution Cap

Post by LPChip »

I see... But given that I assign an entire VM (aka Operating system) more than one processors and not more programs, wouldn't that mean that more cpu's can do multitasking better?

Lets say, I assign 2 cpu's, and I run 2 programs at the same time that aren't multi-core capable, wouldn't that still mean I get benefit from that?

But I see that more processor power as you mentioned can be a problem on its own.
scottgus1
Site Moderator
Posts: 20965
Joined: 30. Dec 2009, 20:14
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Windows, Linux

Re: Processors vs Execution Cap

Post by scottgus1 »

Yes, you do get the benefit of multiple processors when running more than one program on a guest that is designed to handle multiple processors. There's just the context switching thing that takes a slice out of the pie. How big a slice I don't know. Only some timed pi-to-the-kazillionth-digit processing or something like that could tell.

I wouldn't use execution cap unless I had to overprovision my host by running guests with a total processor count than there were processors in my host. Virtualbox only uses the physical number of cores the host has, not the hyperthreads. But I have run a four-physical-core I7 and had three running guests totaling 5 processors on it happily. Safety would dictate I only have three total cores used in the guests, but it was OK because I wasn't using each guest solidly at the same time and the guests and the host didn't all at once go full throttle down the trench to keep the fighters off their tails. (If the guests all went full-bore my host would have died, so I wasn't following standard practice.) If I knew I was going to be doing solid number crunching in all guests with 100% processor usage, and had to run more guest processors than there were in the host, then I'd cap the guest execution.
LPChip
Posts: 18
Joined: 30. Apr 2019, 22:17

Re: Processors vs Execution Cap

Post by LPChip »

Are you sure about that?

I have an I3 5010U as processor in my server, which is a dual core CPU with 4 threads, all combined, and VirtualBox sees all 4 CPU's similarly to how the taskmanager sees them.

Identically, my AMD Ryzen 5 2600X has 6 cores and 12 threads total, and VirtualBox also saw all 12 threads and allowed me to assign CPU's to 8 of them.
mpack
Site Moderator
Posts: 39156
Joined: 4. Sep 2008, 17:09
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Mostly XP

Re: Processors vs Execution Cap

Post by mpack »

LPChip wrote: I have an I3 5010U as processor in my server, which is a dual core CPU with 4 threads, all combined, and VirtualBox sees all 4 CPU's similarly to how the taskmanager sees them.
It reports up to 4 vCPUs because that is how many the host OS reports. In no way does that indicate that you can ignore the green / red color coding in the vCPU settings dialog, nor can you ignore reality: you know the host needs actual cores too.

Tutorial: CPU Cores versus threads.
LPChip
Posts: 18
Joined: 30. Apr 2019, 22:17

Re: Processors vs Execution Cap

Post by LPChip »

I see...

Weird how this works, but okay... I am currently running 3 VM's on my server with 2 CPU's. VirtualBox gives me green for 1 or 2 CPU's. I run a Domain Controller with 1 CPU, 100%, a remote desktop server with 2 CPU's, 100% and a linux VM with 1 CPU, 100%.

(the 100% is the execution cap btw).

I have to add that the CPU's will not max out at any point in time, so it may be a good idea to set the execution cap to 80% or 90% and get no performance decrease but have a safety margin in place.

So far, this config runs smoothly without any problems, even though in theory I am overprovisioning by a whole CPU and use all CPU's if all are busy. Yet it somehow works without a problem.

Now, I have to add, I am the only person who actually connects to it and uses it. The DC does also functions as a file print server, but I have no performance issues whatsoever. Now, I had the same config with Windows as a host running Hyper-V, and I had lots of throttling issues there, so I know what to look for. So that's why I wonder if this is still true nowadays. I understand this is far from best practice, but I just don't have better hardware at the moment, and it works. Now, I could easily merge all to one server, but that sounds like an even worse thing to do.

Also, I have had a moment where the other servers were turned off, and only the remote desktop server was running with 2 CPU's, which is not good either I guess, and got the exact same performance.

But then again, all I do is web browsing and email. Nothing that requires lots of CPU power anyway.
scottgus1
Site Moderator
Posts: 20965
Joined: 30. Dec 2009, 20:14
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Windows, Linux

Re: Processors vs Execution Cap

Post by scottgus1 »

I haven't tried to intentionally overprovision a host then then full-throttle all the guests to see what would happen. I suspect a BSOD or some other non-friendly shutdown would occur. Your host is, like mine was, overprovisioned, but the guests haven't all opened up at the same time, so the host hasn't starved. If the guests ever do open up all at once, then you may have problems. Just a risk assessment. I would theorize that execution cap is there to be sure the production servers Oracle's paying customers have won't crash if overprovisioned.

A little test to see how execution cap interferes could be to get a transcoding program like Handbrake and process a known video file with the cap on and off and see what happens to the time to complete. Or a math program that takes some time to do Pi to a kazillion digits, or something.
LPChip
Posts: 18
Joined: 30. Apr 2019, 22:17

Re: Processors vs Execution Cap

Post by LPChip »

Its nice how you can set the executioncap at real-time. So I changed the execution cap of my Remote Desktop server from 100% to 80%. With process monitor open which gives me nice graphs and stressing the cpu a little to where it felt a bit sluggish, I went back to the process monitor and saw 2 threats max out to 80% usage.

But I doubt I will see a BSOD if I stress out everything. I just think things will slow down to a crawl instead.
mpack
Site Moderator
Posts: 39156
Joined: 4. Sep 2008, 17:09
Primary OS: MS Windows 10
VBox Version: PUEL
Guest OSses: Mostly XP

Re: Processors vs Execution Cap

Post by mpack »

If either host or guest is starved for CPU then they might start missing interrupts, or at least have unacceptably high latencies. Then BSOD's are indeed a real possibility.
Post Reply