VMware Communities
ralish
Enthusiast
Enthusiast

Limit CPU Usage

Hi,

I'm interested to know if there is some way to limit the CPU usage of an individual VM, preferably at the MHz level, but a percentage level could probably work as well, though be less portable between machines. I'm pretty sure ESX has something along these lines through the use of resource pools, but is there anything similar for VMware Workstation?

I'm interested in doing this to diagnose a blue screen on a legacy NT 3.1 VM. It occurs randomly, either during initial boot-up or early logon (before Program Manager appears). However, if it makes it this far, which it does probably 50% of the time, then it'll work fine for the rest of that session 95% of the time. This makes me wonder if it's a race condition of some sort. Keeping in mind this is a 1993 era OS designed when Pentium's were cutting edge, I wonder if there is some buggy code in the kernel that the 2.66GHz core the VM is running on is exposing. Slowing down execution of the VM down significantly, for example, to a 100Mhz level, would I think be very interesting.

So, I'm just wondering if there is anything in VMware Workstation that could achieve this? Obviously, a program in the VM is highly unlikely to work, as it'd need to be a kernel driver that works on NT 3.1, and it'd need to initialise VERY early on during boot-up.

A program at the host level could work, though I'm ideally looking for something at the virtualisor level. This is a Vista x64 system. I've had a look on both fronts but come up with nothing.

I'm aware of priority levels and CPU affinity, as well as VM priorities for focus/un-focused, but on a system this fast, they simply won't slow the VM down to the extent I require. I've also tried disabling acceleration, but to no result.

Thanks!

Reply
0 Kudos
6 Replies
admin
Immortal
Immortal

Even ESX's CPU limiter isn't going to do what you want here. The only real way to limit CPU usage for an application (or a VM for that matter) is to give it smaller chunks of time to run in and/or schedule it less often. While it is scheduled though, it'll run through its instructions as quickly as the CPU will allow.

There are some things that early windows operating systems do that will cause problems even on physical boxes if they're too fast. Things like calibrating timing loops and such are highly sensitive to the physical speed of the processor in relation to some external timer like the ACPI timer.

What guest operating system type have you selected for the guest.

Reply
0 Kudos
ralish
Enthusiast
Enthusiast

The guest operating system is set to "Other"; perhaps I should try with it set to "Windows NT"?

You mention timing loops, and I was just going through a boot.ini options reference for a different and very interesting problem with another legacy OS (which I'll probably make a seperate post for soon!). I notice this option:

/TIMERES=

Sets the resolution of the system timer

on the standard x86 multiprocessor HAL (Halmps.dll). The argument is a

number interpreted in hundreds of nanoseconds, but the rate is set to

the closest resolution the HAL supports that isn't larger than the one

requested. The HAL supports the following resolutions: Hundreds of

nanoseconds Milliseconds (ms) 9766 0.98 19532 2.00 39063 3.90 78125

7.80 The default resolution is 7.8 ms. The system timer resolution

affects the resolution of waitable timers. Example: /TIMERES=21000

would set the timer to a resolution of 2.0 ms.

Source: http://technet.microsoft.com/en-us/sysinternals/bb963892.aspx

Would this be useful? I have no idea how to use it though, so if you have any suggestions about applicable values if it is relevant, I'd be interested.

(Not to sidetrack away from my original request, which possibly has other useful applications outside of my problem)

Reply
0 Kudos
ralish
Enthusiast
Enthusiast

I can confirm that it crashes just the same when using "Windows NT" as the guest OS.

Reply
0 Kudos
admin
Immortal
Immortal

Before you attempt anything, I'd strongly suggest that you take a snapshot of the VM in case something goes south. It might be worthwhile copying the entire VM folder to a backup as well.

You could try adjusting the timer resolution. Changing the setting will require getting all the way into windows and editing the boot.ini which is in the root directory of the guest c: drive, in modern windows systems its hidden so you may need to adjust the folder view to see it.

You'll need to add the boot switch to one of the lines in the "operating systems" ini section and then save the file and power off the VM, I don't think a reset will do it. I'd start with the /TIMERES=21000 the article mentions and see if that works and then go down from there if it doesn't. It's also entirely possible that this will have no effect at all on NT 3.51 or that this isn't actually the cause of the problem.

You might also try with the Windows 95 guest type and see if that helps.

Reply
0 Kudos
birdie
Expert
Expert

I have to bump this topic, because I'm also interested in controlling CPU usage of a virtual machine.

In my case I'm using VM to run old games and some of them work like crazy on modern CPUs. On Linux I've found a CPU limit application, unfortunately when I apply e.g. 50% percentage of throttling to a vmx process, the sound stutters and mouse becomes sluggish in a VM, so it's not a solution.

BTW, all Microsoft virtualization server products allow controlling the precise percentage of CPU dedicated to a certain VM, it would be nice to see/have this feature in desktop VMWare products.

Reply
0 Kudos
thro
Enthusiast
Enthusiast

Also bumping this.  Would be nice to be able to limit a VM's resource consumption for various reasons:

- run old software at acceptable frame-rate (e.g., old dos games).

- work around timing bugs in old platforms/software (i.e., stability problems with software that doesn't work due to excessive modern CPU speed)

- simulating the experience a user will get when a VM is under resource constraints for lab purposes.  We can limit network throughput - would also be nice to be able to restrict disk IO throughput for this purpose as well.

I use/administer: vSphere 6.0 (ESXi) | Workstation 12.5 | Vmware Server 2.0 | Vmware Fusion 12.5 | Windows | FreeBSD | Redhat EL
Reply
0 Kudos