Expensive fuser in progress_bar.sh

Dan Nicholson dbn.lists at gmail.com
Sun Jun 25 17:01:54 PDT 2006


I'm finding that the fuser call being made once every .12 seconds in
progress_bar.sh is actually very taxing on my processor. I'm sure you
hardly notice on a fast machine, but on my PIII 500, top shows fuser
spiking to 25% processor usage at times. This is more expensive than
just letting all the output go to the screen with tee. Stracing "fuser
-v ." shows that it is actually looking through every socket and pid
on the system.

I think if you want to be making 8 calls per second, you should try to
limit them to bash built-ins only.  One option would be to touch a
file at the beginning of the target script.  I don't know how this
translates to make, but in bash you could do something like this.

touch /tmp/pid.$$

And change write_or_exit() in progress_bar.sh to.

write_or_exit() {
    # make has been killed or failed or run to completion, leave
  if [ ! -f ${TARGET_PID_FILE} ] ; then
     echo -n "${CURSOR_ON}" && exit
    # Target build complete, leave.
  [[ -f ${TARGET} ]] && echo -n "${CURSOR_ON}" && exit
    # It is safe to write to the screen
  echo -n "$1"

where TARGET_PID_FILE is passed in as /tmp/pid.$$.  You'd have to rm
-f that file on trapped exits, but that wouldn't be that difficult.
Anyway, that's just one idea.


More information about the alfs-discuss mailing list