4 ms·
Linux 6.8 Landing A Tantalizing Optimization For Common $PATH-Based Searches
- NoZebra120vClip 3y agoIt's sort of staggering if you consider how inefficient Unix has been, where every shell script involves several dozen $PATH-based invocations. If you call a given program, say 20 times in a script, and it's located at the third element in $PATH, then that's 40 failed calls to execve(2) that could've been avoided by some sort of caching.
- sgbeal 3y ago> located at the third element in $PATH, then that's 40 failed calls to execve(2) that could've been avoided by some sort of caching. Bash caches path lookups and has a command to clear them (i forget its name and am on a tablet, so can't readily check... Maybe "hash" or "rehash"?).
- lifthrasiir 3y agoYes, `hash -r`. You can also use `shopt -s checkhash` to automate this.
- fowl2 3y ago(this has not been merged yet, Linus has thoughts[1]) [1] https://lore.kernel.org/lkml/CAHk-=wj1vvUhNd_+s8Cuvh-wO2iT7bN-vFfxhVXNOsGGGigDZg@mail.gmail.com/ https://lore.kernel.org/lkml/CAHk-=wj1vvUhNd_+s8Cuvh-wO2iT7b...