topics that matter; ideas worth sharing

share a tip, submit a link, add something new

Get better results when you design your cache to match your applications and system

May 8, 2001, 11:30 AM —  Unix Insider — 


Q: I'm confused by all the different kinds of cache -- the
cache file system, directory name cache, name service cache, CPU cache. How
can I tell if the cache is working well and how big it should be?

--Tasha in Cashmere


A: Caches are used to store a small amount of information for repeated
fast access. Many types of cache occur throughout computer hardware and
software systems. We'll take a look at the common principles and look
at a few examples.


Caches work on two basic principles that should be quite familiar to
you from everyday life. The first is that if you spend a long time
going to get something and you think you may need it again soon, you
keep it nearby. For example, if you are working on your car, and need a
15mm spanner that you find in your toolbox, you then
crawl under the car and begin work. If you then
need a 10mm spanner, you don't put the 15mm back in the toolbox, you
leave it under the car. When you have finished, there is a cache of
tools in a pile under the car that make up your working set. If you
only allowed one tool at a time under the car, you would waste a lot of
time going back to the toolbox. However if the pile of tools gets too
large, you may decide to put away a few that you think you won't need
any more.


The second principle is that when you get something, you can save
time by getting a few extra things that you think you might need soon.
In the car example, you could grab a handful of spanners each time,
thus saving yourself a few trips. You find that the
pile under the car gets bigger much more quickly, some tools don't ever
get used, and it takes you longer to pick up and put down a handful of
tools on each trip to the toolbox.


The first principle is called "temporal locality" and depends on
reusing the same things over again. The second principle is called
"spacial locality" and depends on using things at the same time that
are located near each other. Caches only work well if there is good
locality in what you are doing.


Another example is the "cache" of groceries that you keep in your
house that save you a trip to the supermarket every time you want a
bite to eat. Let's say you are the
kind of person who hates shopping and lives off canned and frozen food
that you buy once a month. You have a very efficient cache with few
shopping trips, and you can spend all your spare time browsing the
Internet and reading articles like this.


Now let's say your mother comes to stay and tells you that you
need a diet of fresh fruit and salad instead. You can't buy in bulk as
it doesn't freeze or keep, therefore you'll need to visit the shops almost every
day. You now waste all your spare time shopping. You notice one day
that your local shop is now also on

I like it!
Post a comment
The content of this field is kept private and will not be shown publicly.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.
Resources
White Paper

Symantec Backup Exec 12 and Backup Exec System Recovery 8 deliver industry leading Windows data protection and system recovery. Download this whitepaper to find out the top reasons to upgrade and how to get continuous data protection and complete system recovery.

Webcast

Data and system loss — from a hard drive failure, malicious attack, natural disaster, or simple human error — can happen anytime. Don’t leave your business vulnerable. Make sure you have a secure recovery strategy in place. Symantec's latest backup and system recovery technology can efficiently restore critical applications, individual emails and documents and even restore your entire system in minutes in the event of a loss.

White Paper

Businesses face a growing challenge to ensure that the IT environment is properly protected. Backup Exec 12 integrates with other applications in the Symantec family of products, to complement your current data protection strategy, keep your data securely backed up and make it recoverable when you need it most.

Free stuff
Featured Sponsor

AISO founders envisioned a Web hosting company that was environmentally friendly. While the company employed energy-efficient innovations like solar panels, its infrastructure produced unacceptable power and cooling requirements. Find out how AISO leveraged AMD technology to overcome their challenge in this case study white paper.

In this whitepaper, Scalar explores the opportunity to change the landscape with respect to mission critical databases built around Oracle. Leveraging technologies such as Linux, high-end commodity processing power and Oracle RAC technology to architect, design, build and maintain database infrastructure that delivers maximum availability, reliability and performance at a fraction of traditional cost.

On a typical day, weather.com, the Web site for The Weather Channel in Atlanta, serves up between 15 million and 20 million page views. But in September 2004, when back-to-back hurricanes ransacked Florida, the peak traffic on one day more than tripled: over 70 million page views by more than 7 million unique visitors. Read the full success story now.

More Resources