[OpenAFS-devel] PATCH: limit afsd auto-tuning to 500000 files

chas williams - CONTRACTOR chas@cmf.nrl.navy.mil
Wed, 24 Aug 2005 10:29:51 -0400


This is a multipart MIME message.

--==_Exmh_1124893765_34490
Content-Type: text/plain; charset=us-ascii

In message <0C7A8268185C89ECC160E57C@sirius.fac.cs.cmu.edu>,Jeffrey Hutzelman w
rites:
>Well, right now we use two numbers.  One is a constant; the other is a 
>function of the chunk size.  It sounds like you're arguing for eliminating 
>the constant, or at least limiting its effect as the cache size grows very 
>large.  Fine, but without data, how do we decide where to draw the line? 

if it difficult to work without the data but you can make some
reasonable guesses based on the typical machine size.  for instance,
-files 500000 would probably need more memory than a typical 1GB
machine could provide.  its much safer to err on the side of caution when
it comes to consuming kernel memory (for the same reason someone should
get around to getting to making the memcache safer instead of letting
people shoot themselves in the foot).

attached is a small perl script that takes an directory as the first
argument.  run this on a your local cache.  for instance:

# avg.pl /usr/vice/cache
# !avg
avg.pl /usr/vice/cache
1222 files
3330850 total bytes
2725 avg bytes

< 1k 52 4%
< 2k 7 4%
< 3k 1147 98%
< 5k 2 98%
< 7k 1 98%
< 9k 3 99%
< 11k 2 99%
< 19k 2 99%
< 21k 2 99%
< 25k 1 99%
< 41k 1 99%
< 47k 1 99%

(yes, my cache looks funny since i was running a benchmark inside afs.)
you could also run it on a sample dir to check the file distribution.
for instance, if you were going to build the 2.6 kernel sources in
afs, the file distribution looks something like:

28374 files
1566439944 total bytes
55206 avg bytes

< 1k 7536 26%
< 2k 2477 35%
< 3k 1837 41%
< 4k 1411 46%
< 5k 1101 50%
< 6k 844 53%
< 7k 691 56%
< 8k 572 58%
< 9k 509 59%
< 10k 1181 63%
< 11k 635 66%
< 12k 643 68%
< 13k 565 70%
< 14k 708 72%
< 15k 709 75%

this should give you some idea for manual tuning.  

>With a small cache and a large chunk size, we need that constant to ensure 
>we have enough files.

it would be unwise to let the autotuning pick such a configuration.
however, we cant prevent users from manually tuning.


--==_Exmh_1124893765_34490
Content-Type: application/x-perl ; name="avg.pl"
Content-Description: avg.pl
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename="avg.pl"

IyEvdXNyL2Jpbi9wZXJsCgokQklOU0laRSA9IDEwMjQ7CgokbmZpbGVzID0gMDsKJGxhcmdl
c3RfYmluID0gMDsKCiRmaWxlc3lzdGVtID0gc2hpZnQgQEFSR1Y7CgomZmluZCgkZmlsZXN5
c3RlbSk7ICMgc2V0cyBnbG9iYWwgQEZJTEVTCgpmb3JlYWNoICRfIChARklMRVMpIHsKCSgk
bXRpbWUsICRzaXplLCAkZmlsZSkgPSBzcGxpdDsKCglpZiAoJHNpemUgPT0gMCkgewoJCW5l
eHQ7Cgl9CgoJKyskbmZpbGVzOwoJJHRvdGFsICs9ICRzaXplOwoKCSRiaW4gPSBpbnQoJHNp
emUgLyAkQklOU0laRSk7CglpZiAoJGJpbiA+ICRsYXJnZXN0X2JpbikgewoJCSRsYXJnZXN0
X2JpbiA9ICRiaW47Cgl9CgkrKyRoaXN0b1skYmluXTsKfQoKcHJpbnRmICIlZCBmaWxlc1xu
IiwgJG5maWxlczsKcHJpbnRmICIlZCB0b3RhbCBieXRlc1xuIiwgJHRvdGFsOwpwcmludGYg
IiVkIGF2ZyBieXRlc1xuXG4iLCAkdG90YWwvJG5maWxlczsKCiRzdW0gPSAwOwoKZm9yKCRp
ID0gMDsgJGkgPCAkbGFyZ2VzdF9iaW47ICsrJGkpIHsKCSRzdW0gKz0gJGhpc3RvWyRpXTsK
CWlmICgkaGlzdG9bJGldICE9IDApIHsKCQlwcmludGYgIjwgJWRrICVkICVkJSVcbiIsCgkJ
CSgoJGkrMSkgKiAkQklOU0laRSkgLyAxMDI0LCAkaGlzdG9bJGldLCAkc3VtICogMTAwIC8g
JG5maWxlczsKCX0KfQoKZXhpdDsKCiMgbG9vayBtYSwgbm8gaGFuZHMuCgpzdWIKZmluZAp7
Cglsb2NhbCgkcGF0aCkgPSBAXzsKCWxvY2FsKCpESVIsICRfKTsKCgkjREVCVUcjc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