Lime Technology - unRAID Server Community
September 07, 2010, 04:18:10 AM *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
 
   Home   Help Search Login Register  
Pages: 1 ... 4 5 [6] 7 8
  Print  
Author Topic: cache_dirs - an attempt to keep directory entries in RAM to prevent disk spin-up  (Read 5458 times)
queeg
Hero Member
*****
Posts: 737


Red Dwarf back-up computer


View Profile
« Reply #75 on: May 09, 2010, 10:10:02 AM »

What about -prune option?  Would that work to exclude sub dirs?

EDIT: 
Here's an example that I just figured out.  It prints everything except the packages directory.
find /boot/config \( -name packages -prune \) -o -name "*" -print

And one that prints everything except subdirs ending in "old" or the packages directory.
find /boot \( -name "*old" -prune -o -name packages -prune \) -o -name "*" -print

Cool.  I'll try to integrate this into it.
« Last Edit: May 09, 2010, 10:46:56 AM by queeg » Logged

unRAID 4.5.6 on Asus M4A78L-M, 2GB DDR2800, 3-1.5TB 7200.11, 2GB Lexar Firefly,  (Monoprice 3581) eSata Sil3132, (Monoprice 2530) Sata Sil3132
Joe L.
Hero Member
*****
Posts: 7981


View Profile
« Reply #76 on: May 09, 2010, 03:36:35 PM »

Actually, the ability to add arguments is built in with the "-a" option.

An example:
cache_dirs  -a '-noleaf -name Steam -prune -o -print'

Or, if you have more than one directory to exclude:
cache_dirs -a '-noleaf \( -name Steam -prune -o -name data -prune \) -o -print'

Your example would be
cache_dirs -a '-noleaf \( -name "*old" -prune -o -name packages -prune \) -o -print'

No need to hack at cache_dirs at all.  It was designed to be flexible.  When using the -a option you need to use the -noleaf at the beginning of the -a option argument, and -print at the end to get correct syntax.  The entire -a option argument is enclosed in single quotes as in -a '-noleaf ....... -print'   Individual shell wild-cards "*" can be enclosed in double quotes as in the "*old" example above.

Not too difficult...

Joe L.
Logged

queeg
Hero Member
*****
Posts: 737


Red Dwarf back-up computer


View Profile
« Reply #77 on: May 09, 2010, 04:47:31 PM »

Actually, the ability to add arguments is built in with the "-a" option.

An example:
cache_dirs  -a '-noleaf -name Steam -prune -o -print'

Or, if you have more than one directory to exclude:
cache_dirs -a '-noleaf \( -name Steam -prune -o -name data -prune \) -o -print'

Your example would be
cache_dirs -a '-noleaf \( -name "*old" -prune -o -name packages -prune \) -o -print'

No need to hack at cache_dirs at all.  It was designed to be flexible.  When using the -a option you need to use the -noleaf at the beginning of the -a option argument, and -print at the end to get correct syntax.  The entire -a option argument is enclosed in single quotes as in -a '-noleaf ....... -print'   Individual shell wild-cards "*" can be enclosed in double quotes as in the "*old" example above.

Not too difficult...

Joe L.

That sounds easier.  I had added a new -x parameter but trying to put it into all the find's get me tangled up.
This is what I'm going to use.
/boot/cache_dirs -w -u -d 3 -a '-noleaf \( -name "ftproot" -prune -o -name "lost+found" -prune -o -name "iTunes" -prune \) -o -print'
Logged

unRAID 4.5.6 on Asus M4A78L-M, 2GB DDR2800, 3-1.5TB 7200.11, 2GB Lexar Firefly,  (Monoprice 3581) eSata Sil3132, (Monoprice 2530) Sata Sil3132
queeg
Hero Member
*****
Posts: 737


Red Dwarf back-up computer


View Profile
« Reply #78 on: May 10, 2010, 10:30:51 AM »

It doesn't seem to be working.  The drive spins up going down the first directory leve.

/boot/cache_dirs -w -u -d 3 -a '-noleaf \( -name "ftproot" -prune -o -name "lost+found" -prune -o -name "iTunes" -prune \) -o -print'
Logged

unRAID 4.5.6 on Asus M4A78L-M, 2GB DDR2800, 3-1.5TB 7200.11, 2GB Lexar Firefly,  (Monoprice 3581) eSata Sil3132, (Monoprice 2530) Sata Sil3132
BRiT
Hero Member
*****
Posts: 1089


View Profile WWW
« Reply #79 on: May 10, 2010, 10:42:41 AM »

The first time the script runs, the drive has to be spun up to get the directory listings.

If you mean the drive spuns up after the script is running and the drive has idled out to sping down, how are you browsing the files? If you're using Windows Explorer, make sure it's not trying to read the content of the files to display thumbnails.
Logged
queeg
Hero Member
*****
Posts: 737


Red Dwarf back-up computer


View Profile
« Reply #80 on: May 10, 2010, 10:48:58 AM »

What I meant to say was I spun up the drives, ran the cache_dirs command, allowed the drives to spin down (actually just came back 7 hours later) and from windows I explored the directories while also watching the drives on the unRAID menu.  After browsing down past the first directory the drive spun up.  So I don't think cache_dirs with those parameters is working.
Logged

unRAID 4.5.6 on Asus M4A78L-M, 2GB DDR2800, 3-1.5TB 7200.11, 2GB Lexar Firefly,  (Monoprice 3581) eSata Sil3132, (Monoprice 2530) Sata Sil3132
Joe L.
Hero Member
*****
Posts: 7981


View Profile
« Reply #81 on: May 10, 2010, 11:04:11 AM »

What I meant to say was I spun up the drives, ran the cache_dirs command, allowed the drives to spin down (actually just came back 7 hours later) and from windows I explored the directories while also watching the drives on the unRAID menu.  After browsing down past the first directory the drive spun up.  So I don't think cache_dirs with those parameters is working.
As already said, it depends on what you are browsing... If you have thumbnail views enabled, windows is looking at file contents, not just directory listings.
Logged

queeg
Hero Member
*****
Posts: 737


Red Dwarf back-up computer


View Profile
« Reply #82 on: May 10, 2010, 11:13:13 AM »

The (Win7) explorer is set to Titles which is the default I think.  

Edit:  Tiles (not Titles)
« Last Edit: May 10, 2010, 11:24:14 AM by queeg » Logged

unRAID 4.5.6 on Asus M4A78L-M, 2GB DDR2800, 3-1.5TB 7200.11, 2GB Lexar Firefly,  (Monoprice 3581) eSata Sil3132, (Monoprice 2530) Sata Sil3132
Joe L.
Hero Member
*****
Posts: 7981


View Profile
« Reply #83 on: May 10, 2010, 11:36:45 AM »

The (Win7) explorer is set to Titles which is the default I think.  

Edit:  Tiles (not Titles)
Yes, "tiles" will show you small images of jpg files, and images of documents.  It will be examining file content, not just directory data.  cache_dirs is not opening every file to read them...   

Solution, change the view you are using to a file listing mode.

Joe L.
Logged

queeg
Hero Member
*****
Posts: 737


Red Dwarf back-up computer


View Profile
« Reply #84 on: May 10, 2010, 11:43:31 AM »

A little testing and here is what I see.  It seems that even though explorer defaults to Tile it actually does request file info unless you manually set it to Tile.


Open explorer
browse top level folder: works
browse any subdir: spins up drive.


Open explorer
Change view from Tiles to List
browse top level folder: works
browse any subdir: works
change view from List back to Tiles
browse other subdirs:  continues to work.

In any case, cache_dirs is working correctly with the added -a parameter so I'm happy and thanks Joe.

« Last Edit: May 10, 2010, 11:46:24 AM by queeg » Logged

unRAID 4.5.6 on Asus M4A78L-M, 2GB DDR2800, 3-1.5TB 7200.11, 2GB Lexar Firefly,  (Monoprice 3581) eSata Sil3132, (Monoprice 2530) Sata Sil3132
Joe L.
Hero Member
*****
Posts: 7981


View Profile
« Reply #85 on: May 10, 2010, 11:57:52 AM »

A little testing and here is what I see.  It seems that even though explorer defaults to Tile it actually does request file info unless you manually set it to Tile.


Open explorer
browse top level folder: works
browse any subdir: spins up drive.


Open explorer
Change view from Tiles to List
browse top level folder: works
browse any subdir: works
change view from List back to Tiles
browse other subdirs:  continues to work.

In any case, cache_dirs is working correctly with the added -a parameter so I'm happy and thanks Joe.
Don't be fooled by your test.  Once a "file" is read, it is in the cache until it is replaced by something else needing the cache.

To perform your test properly, you'll need to empty the cache between tests.

To do that, type this in between each test:
sync; echo 3 > /proc/sys/vm/drop_caches
Logged

paperclip
Newbie
*
Posts: 35


View Profile
« Reply #86 on: May 29, 2010, 06:08:20 PM »

Joe L., thanks for your great script.

I do have a questions about the -d (max depth) parameter. Does the numbering start at 0 or 1?

So if I had a "Music" share with the following structure:
Music/The Eagles/Hotel California/Track01.mp3

What would be the appropriate max depth value?

Does it even matter? I mean, if my folder structure didn't have a max depth exceeding 3, but I set cache_dirs to look 5 folders deep, would there be a performance hit?

Thanks.
Logged
Joe L.
Hero Member
*****
Posts: 7981


View Profile
« Reply #87 on: May 29, 2010, 06:53:14 PM »

Joe L., thanks for your great script.

I do have a questions about the -d (max depth) parameter. Does the numbering start at 0 or 1?

So if I had a "Music" share with the following structure:
Music/The Eagles/Hotel California/Track01.mp3

What would be the appropriate max depth value?
The argument is passed to the "find" command.  Its manual page says
Quote
    -maxdepth levels
         Descend at most levels (a non-negative integer) levels of direc-
         tories below the command line arguments.    `-maxdepth  0'  means
         only  apply the tests and actions to the command line arguments.

You can experiment by changing the number and testing with this sample "find" command and see what it prints:
find /mnt/disk*/Music -maxdepth 1

The depth is relative to the starting path, so a maxdepth of 0 would only cache the /mnt/disk*/Music folders and nothing in them or below them.
To cache the hierarchy you described you would need at least a depth of 3.
Quote
Does it even matter? I mean, if my folder structure didn't have a max depth exceeding 3, but I set cache_dirs to look 5 folders deep, would there be a performance hit?

Thanks.
Since you have no really deep hierarchies, there is no reason to specify any -d option.  There is no penalty of using 5, or using the default of 999.

Edit: fixed directory name in example
« Last Edit: May 30, 2010, 03:36:06 AM by Joe L. » Logged

paperclip
Newbie
*
Posts: 35


View Profile
« Reply #88 on: May 29, 2010, 07:14:55 PM »

You can experiment by changing the number and testing with this sample "find" command and see what it prints:
find /mnt/disk*/Mp3 -maxdepth 1

The depth is relative to the starting path, so a maxdepth of 0 would only cache the /mnt/disk*/Music folders and nothing in them or below them.
To cache the hierarchy you described you would need at least a depth of 3.

Since you have no really deep hierarchies, there is no reason to specify any -d option.  There is no penalty of using the default of 999.

Joe L., thanks for this information.
Logged
starcat
Hero Member
*****
Posts: 635


View Profile
« Reply #89 on: June 02, 2010, 06:30:38 AM »

Now, if your "browsing" of the directory is writing to them (MAC OS writes ._DS files) or opening files to show thumbnail views (windows will do this) then yes, the disks will spin up, since the file contents are not cached.

Writing of .DS_Store files on network shares can be prevented by running these:
defaults write /Library/Preferences/com.apple.desktopservices DSDontWriteNetworkStores true
defaults write com.apple.desktopservices DSDontWriteNetworkStores true

see this for details:
http://www.macosxhints.com/article.php?story=20051130083652119
« Last Edit: June 06, 2010, 01:55:20 PM by starcat » Logged

unRAID 4.5.4 on Supermicro X7SBE with SIM1U+, 2x KVR800D2E5/2G, E6550, 2x AOC-SAT2-MV8, Norco 4220, 750HX, 15x ST31500341AS, Lexar Firefly 2GB
Using Time Machine with unRAID http://lime-technology.com/forum/index.php?topic=5184.msg56380#msg56380
Pages: 1 ... 4 5 [6] 7 8
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.10 | SMF © 2006-2009, Simple Machines LLC Valid XHTML 1.0! Valid CSS!