Introduce negative (ENOENT) caching for NFS. Before this, an attempt to
authorMatthew Dillon <dillon@dragonflybsd.org>
Thu, 8 Apr 2004 22:32:14 +0000 (22:32 +0000)
committerMatthew Dillon <dillon@dragonflybsd.org>
Thu, 8 Apr 2004 22:32:14 +0000 (22:32 +0000)
commit4d17b298967e846b4e0bae20ff34e63baf89a642
tree85fce7c6b4b242c4be6fd110a17b4c11c1fa53a1
parent1345c2b63950f5819661943ad965b87d1ed2b9c5
Introduce negative (ENOENT) caching for NFS.  Before this, an attempt to
lookup a non-existant path would ALWAYS result in packet traffic.  That is,
NFS was only attribute-caching successful lookups, not failed lookups,
and was not making use of the VFS cache facility virtually at all.  This new
features complements the existing attribute cachign feature.

Add a sysctl, vfs.nfs.neg_cache_timeout, which controls the timeout for
negatively cached lookups.  The default is 3 seconds.  You can set this
sysctl to 0 to recover the old non-negative-caching behavior.

This makes a HUGE difference for programs which search nfs directories, such
as compilers (the header file search path), make, and a few other utilities.
NFS packet traffic can be reduced upwards of 90%.  For example, with /usr/src
mounted via NFS, building libc a second time without negative caching
generates 66000 packets of NFS traffic in each direction, building libc
a second time with negative caching enabled generates 9500 packets worth
of NFS traffic, in EACH DIRECTION.  While it is true that negative lookups
are cached on the NFS server, the huge reduction in network traffic and
equivalent reduction in synchronous read latencies result in radically
reduced overheads across the board for operations which generate a lot of
negative hits.

A buildworld test with the default 3 second negative caching timeout went
from 2265 seconds to 1900 seconds.
sys/vfs/nfs/nfs_vnops.c