Share your knowledge at the LQ Wiki.
Go Back > Forums > Linux Forums > Linux - Software > Linux - Kernel
User Name
Linux - Kernel This forum is for all discussion relating to the Linux kernel.


  Search this Thread
Old 10-19-2006, 12:03 AM   #1
Registered: Sep 2004
Distribution: Debian Testing / Unstable
Posts: 171
Blog Entries: 1

Rep: Reputation: 30
Does the kernel cache directory info? ('find' command runs quicker after first use)

I've noticed during testing of bash scripts which use the 'find' command that after the first usage of all subsequent uses are much faster and I don't hear the disk arm moving about (I've got a noisy old
machine). This is a good thing. Is it due to filesystem and/or kernel
caching of the disk contents in RAM? If so, which file(s) might I see
the caching code in? (I've got the kernel source for 2.6.8).

Thanks in advance! :-D
Old 10-19-2006, 12:27 PM   #2
Registered: Apr 2005
Location: chained to my console.
Distribution: LFS 6.1
Posts: 143

Rep: Reputation: 18
whilst i'm not sure where the code itself is kept, yes, linux keeps *lots* cached.

use top to look at your ram usage stats, it shows how much of your ram is used as cache (i have a gig of ram, right now i'm using about 300 megs for the stuff i am running and using about 700megs as cache). your hard-drive will also have a few megabytes of cache built in. linux is awesome at using your free ram as cache, its a *very* cool thing, i tend to hammer my drives with various databases and the read cache makes things happen so much quicker. its also very good at releasing cache, so whilst my system is using 700megs of ram as cache, if i need it to run my software, it just releases it to whatever needs it.
Old 10-26-2006, 12:31 AM   #3
Registered: Sep 2004
Distribution: Debian Testing / Unstable
Posts: 171
Blog Entries: 1

Original Poster
Rep: Reputation: 30
Thanks for the reply! Good way to see the effects of the disk cache in action is to
do a recursive grep for 'cache' in the kernel source, starting in subdirectory 'fs' (filesystem): grep -r cache * | less. I hear the disk chugging for about 5 seconds then look at the results. Then I issue the same command and it takes about 1 second!

Likely suspects ( :-P ) for maintaining the disk cache are:

/fs/bio.c (block I/O?)

There are others, including the modules in /fs/ext3. Yes, good stuff indeed!


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Stupid do I find my posts quicker? M$ISBS LQ Suggestions & Feedback 5 04-06-2006 10:25 AM
date command counts time quicker than hwclock (RTC) carl0ski Linux - Software 2 12-29-2005 05:32 AM
I have a cache directory, I am not sure if that is squid's cache directory Niceman2005 Linux - Software 1 11-26-2004 02:46 AM
Emacs: Can't find the Info directory node mister_math Linux - Software 0 03-14-2003 10:30 AM > Forums > Linux Forums > Linux - Software > Linux - Kernel

All times are GMT -5. The time now is 12:41 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration