'periodic daily' memory usage

Dag-Erling Smørgrav des at des.no
Sun Jan 27 04:55:48 PST 2008


'periodic daily' runs my router out of swap every night, usually killing
named as a result.

A little sleuthing uncovered that the culprit is the 'sort -k 11'
command in /etc/periodic/security/100.checksetuid.  The easy solution
would be to disable that script, but for obvious reasons, I'd rather
not.

Most of the time, named has the largest RSS of all the processes running
on my router, by an order of magnitude. It's difficult to tell precisely
since ssh'ing in to run 'top -o res' skews the results (how are you
doing, mister Heisenberg?), but it's usually named followed by sshd and
zsh.

When 100.checksetuid is running, however, sort grows larger than even
named.

I tried modifying the script to feed considerably less data to sort,
(only fields 2 and 11 from each line), but it doesn't seem to affect
sort's memory usage.  I'm starting to wonder if perhaps GNU sort uses a
fixed-size buffer for each line of input, so reducing the length of the
lines makes no difference.

The solution I found that did work was to eliminate the loop over $MP
and use 'find -s $MP ...' instead, which eliminates the need for sort.
This reduces the memory requirement for 100.checksetuid by, oh, 80% or
so, and greatly simplifies the logic.

Note that 'find -s' and find | sort may not produce the same output, but
this only means you'll get an ugly diff the first time you run the new
script - it won't cause any trouble later.

An entirely different issue is why named uses so much memory...  does
anybody know of a way to specify how much memory named may use for its
cache?

DES
-- 
Dag-Erling Smørgrav - des at des.no

-------------- next part --------------
A non-text attachment was scrubbed...
Name: chksetuid.diff
Type: text/x-patch
Size: 1322 bytes
Desc: not available
Url : http://lists.freebsd.org/pipermail/freebsd-hackers/attachments/20080127/c32aba9c/chksetuid.bin


More information about the freebsd-hackers mailing list