bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH] reduce number of stat(2) calls by bash


From: John Fremlin
Subject: [PATCH] reduce number of stat(2) calls by bash
Date: 12 Feb 2001 18:15:10 +0000

I run a home rolled linux distribution built around epkg (encap). Each
package is installed in a separate directory and symlinks are made to
/bin, /lib, etc. when it is installed. When bash tries to complete a
command, it searches through /bin (using getdents(2) which is very
fast) then stats each entry twice (itself inefficient - one stat to
find out whether the filesystem object is executable, another to see
if it's a directory). The result is that it can take a noticeable time
to complete a name, because each stat of a symlink requires quite a
bit of IO. I profiled bash with strace and found that it was spending
nearly a second on my K6-2 300 in stat(2) when completing a single
command (starting from a flushed kernel cache obviously).

The following patch against bash 2.04 introduces a new shopt shell
option, called "stat_all_in_path" which is set by default. When it is
unset, bash will not try to stat entries in the PATH at all. This
results in noticably better interactive performance on my setup, at
the expense of correctness. I should be happy to document it, if it
were to be accepted into the main bash tree.

Attachment: bash-2.04-nostat.patch
Description: Text Data

-- 

        http://www.penguinpowered.com/~vii

reply via email to

[Prev in Thread] Current Thread [Next in Thread]