# Why is CPU not used?



## markosolo (Aug 19, 2011)

Hi,

I primarily use FreeBSD because I find it much quicker than the Linux counterparts and I enjoy the feel of it in general, however lately I have become a little frustrated at the way it simply doesn't do *anything* sometimes. I'll explain myself a little better - sometimes in the middle of a build, the build pauses and sits there, its not downloading anything, or performing any other activities - I open a second session and look at top and see I'm using 0.0% CPU across the board, no IO wait, etc. Same thing happens when updating ports, and there is other occasions as well, where the system appears simply to have taken a break from doing work, or where a build takes FOREVER when load is less than 0.10.

We have more than adequate hardware, and we have this so that it can be used to get things done quicker, not so we can have better load values. Is there any way I can make FreeBSD perform more aggressively? Or is there something I am missing here?

P.S. This occurs on all of my machines... Maybe its the kernel though? Perhaps something I have changed?


----------



## wblock@ (Aug 19, 2011)

Swapping, maybe.  It would help if you described the system.  How much RAM?  Running X?  What have you changed from default?  Running powerd?


----------



## markosolo (Aug 19, 2011)

Ok its a standard base install, no X, each of them have over 1GB of RAM and 8 CPU's. Most have between 2 and 4 GB of RAM, and there is no swapping going on.

Only thing that's change really is custom kernel(removed excess drivers) and running securelevel 2.


----------



## xibo (Aug 21, 2011)

What are the ports you re trying to build? With only 2 GB memory I would guess you'll have hard times building QtWekbit...
Also, do you experience that with GENERIC kernel, too?


----------



## wblock@ (Aug 21, 2011)

The other test would be to run with the default securelevel and see if it's different.


----------



## NewGuy (Aug 21, 2011)

*CPU idle*

I see this a lot too. Usually no swap is in use, memory isn't full and the CPU will just be sitting idle. Usually it happens on my machines when downloading/installing packages, rather than ports. But sometimes it happens with port builds too.

It's almost like the build forgets what's it's doing and just pauses. And it doesn't seem to matter how big the port is. Sometimes it happens with small ports that have virtually no dependencies and other times it happens on large ports. It also happens on both bare bones installs and full X-with-desktop installs.


----------



## xibo (Aug 21, 2011)

Well a low load while downloading is only obvious: the cpu is idle while waiting for data to arrive at the network interface.
During the build proccess of FreeBSD, make will issue a recursive removal at some point which will cause little load due to having to wait for the storage medium, especially if you're building via NFS or other slow seeking storage.
Some ports, especially ones for bloaty software like the aforementioned qt-*, kde, Firefox, java, ... might cause a lot of page faults, but then you would normaly see swap usage. Or they might do just silly things, like trying to empirically determine the timeout interval of a tcp connect, or (although this takes a lot of load) check whether strlen works in linear time, empirically of cause ....


----------



## NewGuy (Aug 21, 2011)

*stall*

Yes, low CPU usage while downloading makes sense, but having the build process indefinitely stall halfway through a compile does not. For that matter I've often wondered why no one has patched the pkg_ tools to drop and resume download connections that have stalled. The pkg_add command stalls on my fairly frequently.


----------



## xibo (Aug 22, 2011)

pkg_add uses fetchGetFTP of libfetch which does not handle recovery measures by itself. Automatic retries are implemented in fetch(1), rather that in it's backend library.
Automatic resume is not supported by FTP. It's done with the REST instructions in many implementations, but a ftp server is not required to implement it (libfetch can use it, but pkg_add won't do so).

You can use wget(and many others) from ports to download the individual packages with resume by hand.


----------

