2

I'm suffering from heavy performance issues using VirtualBox and VM with lots of RAM, more detailed explained in this and that other question already. From what I've tested so far, there's a direct relationship to the amount of memory assigned to a VM: Problem occurs with 48 GB of RAM and doesn't with either only 6 GB or enabling the setting largepages of the VM.

That is interesting, because that setting doesn't seem to be enabled by default on Linux, the docs only tell about ~5 % improvement, not that it's necessary at all for decent performance at some RAM size, and additionally there are circumstances in which largepages is ignored by VirtualBox altogether.

00:00:42.866663 PGMR3PhysAllocateLargePage: allocating large pages takes too long (last attempt 103 ms; nr of timeouts 11); DISABLE

https://www.virtualbox.org/attachment/ticket/16518/VBox_16518_5112.log#L1154

Therefore I tried to dig through what that function actually changes in memory management of VirtualBox and came to the conclusion that it seems to implement a mechanism comparable to "huge pages" of the OS on it's own. That means in my opinion it doesn't allocate "huge pages" of any kind, neither transparent nor hugetlb*, but only gets 4 kB pages from the OS, combines those in a chunk of 2 MB and uses that as one logical page internally.

Regarding my performance problems that would mean that any difference in (memory management) performance could only come from within VirtualBox itself, not from any optimization in the host-OS. OTOH, if VirtualBox would implement an approach similar to "huge pages", it might explain why performance benefits can be seen in my case at all, like with other software using "huge pages" from the OS e.g. via madvise or whatever. If --largepages really makes such a huge difference like it seems in my case, one could even argue it's a bug in VirtualBox not requiring that setting for some amount of RAM in VMs.

So, is my assumption correct that VirtualBox only uses plain 4 kB pages from the OS instead of special huge ones?

VBox/VMM/VMMR0/PGMR0.cpp:

248     int rc = GMMR0AllocateLargePage(pGVM, pVM, idCpu, _2M,
249                                     &pVM->pgm.s.aLargeHandyPage[0].idPage,
250                                     &pVM->pgm.s.aLargeHandyPage[0].HCPhysGCPhys);

VBox/VMM/VMMR0/GMMR0.cpp:

3081            RTR0MEMOBJ hMemObj;
3082            rc = RTR0MemObjAllocPhysEx(&hMemObj, GMM_CHUNK_SIZE, NIL_RTHCPHYS, GMM_CHUNK_SIZE);
3083            if (RT_SUCCESS(rc))

VBox/Runtime/r0drv/linux/memobj-r0drv-linux.c:

323 # ifdef VBOX_USE_INSERT_PAGE
324         paPages = alloc_pages(fFlagsLnx | __GFP_COMP | __GFP_NOWARN, rtR0MemObjLinuxOrder(cPages));
325 # else
326         paPages = alloc_pages(fFlagsLnx | __GFP_NOWARN, rtR0MemObjLinuxOrder(cPages));
327 # endif
Thorsten Schöning
  • 3,501
  • 2
  • 25
  • 46

1 Answers1

0

Looking through sources of VirtualBox as of 2019-November I come to conclusion that VirtualBox has no large pages support in any host OS but Solaris: memobj-r0drv-solaris.c is the only such example.

poige
  • 1,562
  • 15
  • 12