In some cases cache-busting behavior can be fixed by changing
the system to work in a different way that bypasses the normal cache
fetch. These alternative methods usually require extra hardware or
software support in a computer system. Without getting into a specific
kind of cache, there are some generic terms and measurements that
parameterize caches. When the cache is used to hold some kind of
information, a read from the cache is very different from writing new
information so we'll take a look at cache reads first, then look at
Cache reads that succeed
There are many kinds of information that can be cached: the value of a
memory location, the location of a file, or the network address of
another system. When the information is needed, the system first looks
for it in the cache. This requires that each item in the cache has a
unique name or tag that is associated with the information.
When a cache lookup occurs, the first thing that happens is a search
to match the name you gave it with one of the tags. If
the search succeeds the associated data is returned, and this is called
a read hit. This is the best case situation, as it is both quick and
successful. The two measures of interest are the read-hit rate and the
read-hit cost. The read-hit rate is the number of read hits that occur
per second, and the read-hit cost is the time it takes to search the cache
and return the data.
For a CPU's primary data cache, an address is used as the tag.
Millions of read hits occur each second, and the cost is known as the
load-use delay, a constant small number of CPU clock cycles. When the
CPU issues a load instruction to move data from memory to a register,
it has to wait a few cycles before it can use the register. A good
compiler will try to optimize code by moving load instructions forward,
and filling in the load-use delay with other work. It is hard to
measure (and understand) what is going on in the CPU cache.
For the directory name lookup cache (DNLC) an open system call
causes a pathname string to be looked up, e.g. "export," to find its
inode. The rate at which this occurs is reported by
namei/s, and it can reach a few thousand on a busy file
server. The read-hit cost is relatively low and only consumes CPU
time. An efficient hashed search is used so the size of the search is
not an issue.
The name service cache is implemented as a multithreaded daemon
nscd). It caches password and group information
for users, and the hosts IP address information for systems.