Re: [List] memory allocation / performance tuning question

From: Frank Leonhardt <freebsd-doc_at_fjl.co.uk>
Date: Mon, 10 Nov 2025 18:32:01 UTC
On 10/11/2025 14:58, Tomek CEDRO wrote:
> Hello world :-)
>
> I have switched to a new machine recently (iCoreUltra9 96GB RAM 128GB
> SWAP) with 14.3-RELEASE-p5 AMD64. But, just as on the older machine, I
> still can see the issue that first run of bigger applications is a bit
> slower and then application works relatively slow as compared to
> killing the application and running again I can see improvement in
> performance.
>
> For instance right now starting vbox told me it cannot allocate
> memory, while only 28GB RAM and 300MB of swap is in use. I have
> unpaused vm and it went smooth ahead.
>
> I suspect this may have something to do with memory allocation
> settings? Maybe some other settings?
>
> Is there a way to tune things ups?
>
> Any hints welcome :-)
> Tomek

I have one theory. The first time you run virtualbox the first it 
loadskernel modules (vbox*). Perhaps they’re trying to allocate large 
contiguous or wired memory regions for doing virtualbox stuff and 
triggering a bit of a fragmentation clear-up (and allocation errors). If 
you quit virtualbox the modules will remain resident in kernel memory so 
the second time around all is present and it doesn't have to shuffle 
stuff around. I think it also creates stuff in /dev that might lead to a 
some kind of virtual race condition. Also, if you're using the ZFS ARC, 
the first time around stuff won't be cached but it might be on the 
second attempt.

You could test this crazy theory by using kldload to bring in the 
modules one at a time (vboxdrv and vboxnet, and possibly vboxnetflt 
vboxnetadp), wait for things to settle and then run virtualbox.

Beware - I'm not a virtualbox expert but I've seen stuff like this with 
virtualisation all over the place - which is why I stick to jails :-) If 
you're luck an actual expert may be along later.

Regards, Frank.