Subject: Re: cc1 sleeping
To: None <netbsd-users@netbsd.org>
From: Brian C. Grayson <bgrayson@hal.ece.utexas.edu>
List: netbsd-users
Date: 07/03/1999 13:30:11
On Sat, Jul 03, 1999 at 01:39:56PM +0200, Boris Kimmina wrote:
> 
> Compiling a linux-kernel on the same physical machine (Cyrix-486DLC40
> with poor 8 megs of RAM) usually took less than 2 hours so I'm really
> surprised to see that the new built hasn't finished yet - after one
> whole week of constantly flashing the hd led!
> 
> When I telnet to that box an do a 'top' I get something like this:
> 
> load averages:  1.96,  1.70,  1.52    12:08:34
> 18 processes:  1 running, 17 sleeping
> 
> Memory: 1136K Act 744K Inact 104K Wired 584K Free 9320K Swap 12M Swap free 
> 
>   PID USERNAME PRI NICE   SIZE   RES STATE   TIME   WCPU    CPU COMMAND
> 12140 root      -5  -20  4252K  348K sleep   5:28  1.81%  1.81% cc1
> 12184 kimmina   31    0   220K  536K run     0:00  4.79%  1.42% top
> 12181 kimmina   18    0   496K  176K sleep   0:02  0.19%  0.15% tcsh
>   119 root       2    0    96K  116K sleep   5:49  0.00%  0.00% syslogd
>   160 root      18    0    16K   76K sleep   5:33  0.00%  0.00% update
>   162 root      10    0   268K    4K sleep   4:07  0.00%  0.00% <cron>
> 10865 root      10  -20  4696K    4K sleep   0:31  0.00%  0.00% <make>
>   178 root      18    0   508K    4K sleep   0:03  0.00%  0.00% <tcsh>
> 12137 root      10  -20   348K    4K sleep   0:00  0.00%  0.00% <sh>
>     1 root      10    0   252K    4K sleep   0:00  0.00%  0.00% <init>
> 12138 root      10  -20   128K    4K sleep   0:00  0.00%  0.00% <cc>

  Things that strike me offhand:

  0.  How much memory do your boot messages say you have?
    (dmesg | grep "mem.*=").  If we add up the pieces here,
    1136K+744K+104K+584K = 2568K, which means that the kernel (and
    any buffer space it is using) is chewing up 5.5M -- that's too
    large.  It should be around 2-3M.  It could be that NetBSD
    didn't recognize the full 8M, or that you're using one of the
    install-kernels that has the entire contents of / inside it,
    or something like that.

  1.  You need more RAM -- cc1 is trying to use 4252K of memory
    (sort of), but the 348K that it is using, plus the 584K free,
    are nowhere near enough, so it'll "page" a lot and take forever.
    Popping just another 4M in there should do wonders for your
    compile speed....

  2.  'make' is using up a lot of virtual memory -- 4.7M.  It could be
    that its memory usage could be tightened up a bit.  It
    doesn't help that cc1 and make are fighting for every last
    bit of memory, because every time cc1 starts up, it kicks
    make out to swap, which means make has to reload once the cc1
    exits.

  If you still have Linux on this machine, it might be
interesting to look at top during a kernel build, and see if
the GNU make uses significantly less memory.  Linux uses .o's
scattered throughout the source tree, which means it does
recursive makes, so each make process probably doesn't get too
large.  NetBSD does all of the .o's for a kernel in a single
directory, which has many advantages, but one disadvantage is
that the single make process now needs to keep track of a whole
lot of info!

  One alternative to speed up your compiles a bit would be to do
"make -n > buildme" followed by "sh -e buildme", followed by a
"make" to make sure everything got built okay.  In this manner,
make will figure out everything that needs to be done, save all
that information, and exit (giving you 4M back).  Then, sh and
the compiles will happen, and since sh is small, you'll have 3-4M
more of RAM/swap/vm-in-general for the compiles.

  Brian