Page 1 of 1

Virtualbox slow when using multiple CPU

Posted: 1. Mar 2012, 20:41
by elhefe1982
I am having strange problems with VirtualBox 4.1.8 on a server (x4450) with 4 x Xeon X7350's.

It is extremely slow when using multiple CPU's. I dont really notice this during startup but when for example compiling apache, it takes about an hour to complete. When changing the amount of CPU's to 1, it is 5x as fast.

The Host OS is CentOS 6.2 running VirtualBox, the guest OS is CentOS 6.2 with the GuestAdditions installed.

When compiling top also shows 0% idle (having 4 vcpu's assigned to the guest), when counting the top processes, it should have plenty of idle time left. When checking with top in the host OS, it shows about 280% cpu usage for the VBoxHeadless process during compiling. When idle, it does show a normal usage (2 or 3% average).

The Bios shows that virtualisation is enabled. These are the guest settings:

Code: Select all

Name:            uranus
Guest OS:        Red Hat (64 bit)
UUID:            0015a5f7-538b-4e82-93c0-e4997b01ed0f
Config file:     /home/vbox/VirtualBox VMs/uranus/uranus.vbox
Snapshot folder: /home/vbox/VirtualBox VMs/uranus/Snapshots
Log folder:      /home/vbox/VirtualBox VMs/uranus/Logs
Hardware UUID:   0015a5f7-538b-4e82-93c0-e4997b01ed0f
Memory size:     8192MB
Page Fusion:     off
VRAM size:       12MB
CPU exec cap:    100%
HPET:            off
Chipset:         piix3
Firmware:        BIOS
Number of CPUs:  4
Synthetic Cpu:   off
CPUID overrides: None
Boot menu mode:  message and menu
Boot Device (1): Floppy
Boot Device (2): DVD
Boot Device (3): HardDisk
Boot Device (4): Not Assigned
ACPI:            on
IOAPIC:          on
PAE:             on
Time offset:     0 ms
RTC:             UTC
Hardw. virt.ext: on
Hardw. virt.ext exclusive: on
Nested Paging:   on
Large Pages:     off
VT-x VPID:       on
State:           running (since 2012-03-01T18:20:49.414000000)
Monitor count:   1
3D Acceleration: off
2D Video Acceleration: off
Teleporter Enabled: off
Teleporter Port: 0
Teleporter Address:
Teleporter Password:
Storage Controller Name (0):            SATA Controller
Storage Controller Type (0):            IntelAhci
Storage Controller Instance Number (0): 0
Storage Controller Max Port Count (0):  30
Storage Controller Port Count (0):      30
Storage Controller Bootable (0):        on
Storage Controller Name (1):            IDE Controller
Storage Controller Type (1):            PIIX4
Storage Controller Instance Number (1): 0
Storage Controller Max Port Count (1):  2
Storage Controller Port Count (1):      2
Storage Controller Bootable (1):        on
SATA Controller (0, 0): /home/vbox/VirtualBox VMs/uranus/uranus.vdi (UUID: c8f18a2e-6353-4c41-99b9-2266fbac6164)
IDE Controller (1, 0): /home/vbox/iso/VBoxGuestAdditions.iso (UUID: 6e10591d-ed2b-43c5-b5b4-3218523d9cbc)
NIC 1:           MAC: 080027AB60BB, Attachment: Bridged Interface 'eth0', Cable connected: on, Trace: off (file: none), Type: 82540EM, Reported speed: 0 Mbps, Boot priority: 0, Promisc Policy: deny
NIC 2:           MAC: 0800271DE881, Attachment: Bridged Interface 'eth1', Cable connected: on, Trace: off (file: none), Type: 82540EM, Reported speed: 0 Mbps, Boot priority: 0, Promisc Policy: deny
NIC 3:           disabled
NIC 4:           disabled
NIC 5:           disabled
NIC 6:           disabled
NIC 7:           disabled
NIC 8:           disabled
Pointing Device: PS/2 Mouse
Keyboard Device: PS/2 Keyboard
UART 1:          disabled
UART 2:          disabled
Audio:           disabled
Clipboard Mode:  Bidirectional
VRDE:            enabled (Address 0.0.0.0, Ports 3389-4000, MultiConn: off, ReuseSingleConn: off, Authentication type: null)
Video redirection: disabled
VRDE property: TCP/Ports  = "3389-4000"
VRDE property: TCP/Address = <not set>
VRDE property: VideoChannel/Enabled = <not set>
VRDE property: VideoChannel/Quality = <not set>
VRDE property: VideoChannel/DownscaleProtection = <not set>
VRDE property: Client/DisableDisplay = <not set>
VRDE property: Client/DisableInput = <not set>
VRDE property: Client/DisableAudio = <not set>
VRDE property: Client/DisableUSB = <not set>
VRDE property: Client/DisableClipboard = <not set>
VRDE property: Client/DisableUpstreamAudio = <not set>
VRDE property: H3DRedirect/Enabled = <not set>
VRDE property: Security/Method = <not set>
VRDE property: Security/ServerCertificate = <not set>
VRDE property: Security/ServerPrivateKey = <not set>
VRDE property: Security/CACertificate = <not set>
USB:             disabled

USB Device Filters:

<none>

Shared folders:  <none>

Guest:

Configured memory balloon size:      0 MB

Running kernel:  2.6.32-220.4.2.el6.x86_64 #1 SMP Tue Feb 14 04:00:16 GMT 2012 x86_64 x86_64 x86_64 GNU/Linux
[ mod edit: please use code blocks around lengthy code/logs/infotexts etc. ].

Re: Virtualbox slow when using multiple CPU

Posted: 1. Mar 2012, 21:01
by mpack
It's a well known phenomenon. Depending on the nature of the guest application, managing multiple cpus/cores can incur an overhead easily more than enough to override any performance gains. Additional CPUs don't help if the app can't use them effectively, and not all apps can.

Re: Virtualbox slow when using multiple CPU

Posted: 1. Mar 2012, 21:08
by elhefe1982
mpack wrote:It's a well known phenomenon. Depending on the nature of the guest application, managing multiple cpus/cores can incur an overhead easily more than enough to override any performance gains. Additional CPUs don't help if the app can't use them effectively, and not all apps can.
Well I'm not running any special apps, just compiling apache, php etc. Seems to be taking forever, if compiling on the host OS (outside virtualbox), everything go's very fast.

Re: Virtualbox slow when using multiple CPU

Posted: 2. Mar 2012, 01:31
by Perryg
There will be a difference between metal and virtual in compile time. I know that setting 2 processors is usually the best for me and sometimes 1 works better. It also depends on how you configure you compile. j1, j2, MPMs, Etc. See the Docs for your product.

Re: Virtualbox slow when using multiple CPU

Posted: 2. Mar 2012, 12:36
by mpack
elhefe1982 wrote:Well I'm not running any special apps
Apps have to be written specifically to take advantage of multiple cores/CPUs. If they aren't then they won't. Most single function apps have limited use for multiple cores: the task is inherently sequential (B can't be done until A is done), and so have no use for parallel cores. Those apps will go no faster when assigned 16 cores than they go with one. In the case of a compiler the various phases could I suppose run in parallel, as could multiple compiler instances, but it'd have to be awfully complex, and it would complicate error reporting. I have my doubts programmers would want that (I wouldn't: error reporting and code quality is key, not compile time - within reason).

Re: Virtualbox slow when using multiple CPU

Posted: 2. Mar 2012, 14:00
by elhefe1982
Unfortunatly its just too slow for a production environment. I just switched to xen and it compiled apache between 5 to 7 times faster.

I am still running virtualbox on another server with Xeon X5675, this machine doesn't have any performance issues when compiling.

Re: Virtualbox slow when using multiple CPU

Posted: 2. Mar 2012, 14:03
by mpack
elhefe1982 wrote:Unfortunatly its just too slow for a production environment.
Well, you latched onto the cores issue for some reason, but you are a bit vague on other details. For example, compiling to and from a GA shared folder would be a bad idea. GA shared folders are made for convenience, not speed. If you want speed you would use a network shared folder and VirtIO-net network drivers in the guest.

Re: Virtualbox slow when using multiple CPU

Posted: 2. Mar 2012, 14:52
by elhefe1982
mpack wrote: Well, you latched onto the cores issue for some reason, but you are a bit vague on other details. For example, compiling to and from a GA shared folder would be a bad idea. GA shared folders are made for convenience, not speed. If you want speed you would use a network shared folder and VirtIO-net network drivers in the guest.
I am not sure what other details are of interest. I am not using any shared folders, installed the guestOS from a mounted ISO. Afterwords downloaded the software locally on the virtual and did everything from there (downloaded apache tar, extract, compile etc.). Using GCC4.4.6 and Make3.8.1 (also with -j 4 and without).

Re: Virtualbox slow when using multiple CPU

Posted: 2. Mar 2012, 15:12
by mpack
What kind of host drive are the virtual disk images located on? Obviously that can also have an impact: VirtualBox can't transfer data faster than the host delivers it.

I would not expect network and hdd performance to be severly harmed by running in a VM, nor would I expect a big difference across VM platforms: I would expect the latencies built into that kind of hardware to count for more than minor implementation details. So if an odd performance gap is seen, I doubt the reason is as simple as "VirtualBox is crap".

Re: Virtualbox slow when using multiple CPU

Posted: 2. Mar 2012, 21:11
by elhefe1982
mpack wrote: "VirtualBox is crap".
I am definetly not saying VirtualBox is crap. I am extremely happy with my other virtualbox installation, the combination together with phpvirtualbox is very nice. I was just dissapointed that I didn't get it to work very well this time and was hoping anybody would have some idea of what could be wrong. The reason I tried Xen was because I wanted to see if that would have the same problem.

The disk images are installed on the local harddrive, 6 x 146g 2.5 SAS configured in RAID6 using HW raid (Sun StorageTek Controller with battery cache). I think the problem is somehow related to my specific hardware icm virtualbox.

Re: Virtualbox slow when using multiple CPU

Posted: 30. Mar 2012, 21:33
by elhefe1982
Did some further testing. I already experience the problem when booting a centos guest os. With 1 cpu, its amazing fast, the more cpu's the slower it boots. When using more than 4 cpu's, it gets so slow and linux hangs during boot.

I just tried booting from the CentOS 6.2 x64 cd in a guest OS using 12 CPU's and I noticed the messages in the attached screenshot, could they have something to do with the issues I am experiencing?

Re: Virtualbox slow when using multiple CPU

Posted: 30. Mar 2012, 23:33
by elhefe1982
There is a line above the screenshot which might be intresting: unsupported p6 CPU model 15 no PMU driver, software events only.

Re: Virtualbox slow when using multiple CPU

Posted: 31. May 2012, 13:12
by lolomin
Hi,

I'm just experiencing the same situation with some Sun Solaris servers as host (some are 4 CPUs, others 8CPUs), everytime I enabled more than cpu for each virtualbox guest, the guest OS (Linux Debian Squeeze 6.0.5) is extremely slow, If I enable only one CPU then it seems to work normal.

This is pretty annoying in the sense that we cannot make usage of all the power of the host machine I think.

Another thing I saw is that when running multiple CPUs then the time on the guest is completely broken :

The output of date at time T :
root@galera3:~# date
Thu May 31 13:02:59 CEST 2012

The output of date at time T + almost 10 secs :
root@galera3:~# date
Thu May 31 13:02:59 CEST 2012

Yes this is not an error in my copy/paste, this is the same time, it seems the time is very very slow down.

I've also did this test :
root@galera3:~# date && sleep 10 && date
Thu May 31 13:04:08 CEST 2012
Thu May 31 13:04:18 CEST 2012

There was really almost 21 seconds that REALLY passed between the first display date command and the second one and not 10 like it should.
This time/date problem is not occuring when running only one CPU affected to the virtual machine.

I really don't know what is the problem there with Multiple CPUs and VirtualBox but if anyone have a clue or some informations on how to investigate, I'm available and ready to debug this.

Thks,
Regards.

Laurent

Re: Virtualbox slow when using multiple CPU

Posted: 3. Jun 2012, 17:47
by martyscholes
lolomin wrote:Hi,

I'm just experiencing the same situation with some Sun Solaris servers as host (some are 4 CPUs, others 8CPUs), everytime I enabled more than cpu for each virtualbox guest, the guest OS (Linux Debian Squeeze 6.0.5) is extremely slow, If I enable only one CPU then it seems to work normal.
I noticed something similar on Solaris host which has four sockets, each dual core. We have found that things get weird if we allocate more than two cores to a guest. I am wondering if it has something to do with a guest using more than one socket. Maybe hypertransport issues, cache concurrency issues? We never did figure it out, but when we upgrade to quad-core processors it will be interesting to see what happens.