# high cpu usage on FreeBSD



## chessguy64 (Jun 11, 2022)

So on FreeBSD with about 5-7 firefox tabs up, a youtube video playing, and a linux VM running, I see all my cpu cores at 35%, 50%, sometimes it even jumps up to 92%. On Windows with the same things running, (except using chrome instead of firefox) my cpu usage is very low, most of the time under 15%, 7%.... What's the reason for this? Does FreeBSD not have as good resource management vs Windows in general, or does it not manage resources for popular apps like virtualbox and firefox very well? I figured FreeBSD would perform better with less resources used, but it uses more of the CPU. I'm using btop++ to monitor.


----------



## Deleted member 70435 (Jun 11, 2022)

what hardware resources have you made available to, applications and the FreeBSD kernel and applications


----------



## Alain De Vos (Jun 11, 2022)

You better use bhyve for better performance instead of virtualbox.
The output of "htop P" can be interesting.
What is eating most CPU. Firefox or Virtualbox  ?


----------



## drhowarddrfine (Jun 11, 2022)

It depends on what the browser is doing. It's also possible FreeBSD IS doing resource management in the background. Stuff that Windows doesn't do and you have to do it on your own like disk defrag. But this is just grabbing at things in the air and, without studying it ourselves, there's no way of knowing what's happening on your system and especially whatever Windows is doing.


----------



## ralphbsz (Jun 11, 2022)

chessguy64 said:


> ... I see all my cpu cores at 35%, 50%, sometimes it even jumps up to 92%. On Windows with the same things running, ... most of the time under 15%, 7% ...


Defining CPU states and measuring whether a CPU is idle is not trivial, and it wouldn't surprise me if different OSes define CPU usage differently. Although that should not lead to a factor of 3 or 4 between different measurements.



> (except using chrome instead of firefox)


That could be the smoking gun: perhaps you are comparing apples and oranges.



> 5-7 firefox tabs up, a youtube video playing, and a linux VM running


Break the measurement down, and measure each application separately. Educated guess: The bulk of the difference comes from one of them. Probably either the browser that's used, or youtube video rendering.


----------



## grahamperrin@ (Jun 12, 2022)

chessguy64 said:


> … about 5-7 firefox tabs up, a youtube video playing, … I'm using btop++ …



Three Firefox windows, 888 tabs (not all loaded), numerous extensions, _without_ playing a video, the hungriest process uses less than 6% of one of four CPUs (measured by htop):


----------



## chessguy64 (Jun 12, 2022)

Vadim Alexandrov said:


> what hardware resources have you made available to, applications and the FreeBSD kernel and applications



What do you mean? I'm under a regular user account in the wheel group. Doesn't it use all the hardware resources available by default?


----------



## _al (Jun 12, 2022)

If you have an Alder Lake processor, Window 11, and Intel Thread Director technology is in use, then Windows may show a better load balance of processors, with the same performance.

https://www.anandtech.com/show/16881/a-deep-dive-into-intels-alder-lake-microarchitectures/2


----------



## chessguy64 (Jun 12, 2022)

drhowarddrfine said:


> Stuff that Windows doesn't do and you have to do it on your own like disk defrag.



how?


----------



## kpedersen (Jun 12, 2022)

chessguy64 said:


> I figured FreeBSD would perform better with less resources used, but it uses more of the CPU. I'm using btop++ to monitor.


Does the standard `top` tool agree with what `btop++` is putting out?

It could be that Windows is misreporting things. Or it could be that Gtk / Qt is heavier than Win32 API for UI related things (which it is!).


----------



## grahamperrin@ (Jun 12, 2022)

chessguy64 said:


> … firefox …



*about:config*

Is `fission.autostart` `true` or `false`?



grahamperrin@ said:


> … _without_ playing a video, the hungriest process uses less than 6% of one of four CPUs …



I can easily trigger higher usage, by browsing sites that are sometimes (for me) relatively demanding:





chessguy64 said:


> … I have an Athlon 64 X2 dual core 6000+ CPU. …



Is this (also) the computer where you find high CPU usage?

Knowing more about the hardware, and software, will help. Can you share the result of a hardware probe?

`pkg install sysutils/hw-probe sysutils/pciutils sysutils/usbutils`
`hw-probe -all -upload`
Thanks


----------



## chessguy64 (Jun 12, 2022)

kpedersen said:


> Does the standard `top` tool agree with what `btop++` is putting out?



Yes, btop++ matches htop output. Well, +/- a few %. Good point about gtk/qt being heavier than win32 API.



grahamperrin@ said:


> Is `fission.autostart` `true` or `false`?



fission.autostart is false. 

Yes, it's the same computer. Here is my HW probe:

https://bsd-hardware.info/?probe=bef9700756

Currently I have 10 firefox tabs up on websites with photo images and text, one tab is playing a YouTube music video with sound, one tab is Discord, 2 urxvt terminals loaded that are idle, btop++, htop, virtualbox with one Linux VM (1GB RAM allocated) loaded and idle, and CPU usage on each core is between 35%-41%.

I know that compiling a custom kernel will make my system boot a little faster (which I don't care about really), but will it actually increase performance / speed / loading of applications on the system itself? Other than process priority management through htop and building a custom kernel, is there any other ways to tune performance with regard to CPU / RAM ? (and possibly GPU?) Thank you.


----------



## Phishfry (Jun 12, 2022)

chessguy64 said:


> I know that compiling a custom kernel will make my system boot a little faster (which I don't care about really), but will it actually increase performance / speed / loading of applications on the system itself?


No I don't think so. A more valid reason might be minimal disk space/embedded install or security reasons.
A good example is the floppy kernconf entry. 95% of users don't need this but what do you really save by removal?
You want faster application load speeds then buy a faster disk.


----------



## grahamperrin@ (Jun 12, 2022)

`tunefs -p /dev/ada0p2`
`tunefs -p /dev/ada0p4`
`tunefs -p /dev/ada0p5`
`tunefs -p /dev/ada0p6`
`cat /etc/fstab`


----------



## smithi (Jun 13, 2022)

chessguy64 said:


> Yes, it's the same computer. Here is my HW probe:
> 
> https://bsd-hardware.info/?probe=bef9700756
> 
> Currently I have 10 firefox tabs up on websites with photo images and text, one tab is playing a YouTube music video with sound, one tab is Discord, 2 urxvt terminals loaded that are idle, btop++, htop, virtualbox with one Linux VM (1GB RAM allocated) loaded and idle, and CPU usage on each core is between 35%-41%


Given that it's a 2008 2-core 3GHz box, with roughly equivalent performance to an Intel 2.5GHz Core2Duo, viz:

https://www.cpubenchmark.net/cpu.php?cpu=AMD+Athlon+64+X2+Dual+Core+6000+&id=88

I think it's probably doing ok; a tad less loaded than I'd expect from my old Thinkpad X200 with 2.4GHz Core2Duo, with that much going on.

`# systat -vm`
might help with the overview .. works for me anyway.


----------



## smithi (Jun 13, 2022)

Something else: is this with CPU running at full speed all the time, or are you running powerd(8)?

If the latter, you would expect to see CPU % usage higher, but of a lower base speed; monitor `# sysctl dev.cpu.0.freq`


----------

