[OpenAFS] Re: Reducing cache scan time

Andrew Deason adeason@sinenomine.net
Thu, 27 Jan 2011 10:14:29 -0600


On Thu, 27 Jan 2011 10:50:39 -0500
"Edgecombe, Jason" <jwedgeco@uncc.edu> wrote:

> I hard-coded the chunk size for all of my machines because I thought
> the default was 16. 16 is what is mentioned for a disk scan in the
> afsd manpage. I hadn't heard about autotuning the chunksize before. A
> chunksize of 18 (256KB seemed like a good value when I configured my
> machines.

It used to be 16; it was changed to 18-20 awhile ago. I don't remember
when the man page was updated to reflect that, but
<http://docs.openafs.org/Reference/8/afsd.html> seems to have it
correct:

>> If not supplied, a default chunksize will be determined based on the
>> cache type and cache size, and will range from 13 (8KB) for memory
>> cache and 18 to 20 (256 KB to 1MB) for disk cache.

> If I increase the chunksize of let it default to 20, will that result
> in fewer cache files and a faster cache scan?

I think so, but I don't really remember the theory behind how the cache
files are auto tuned (the code comments suggest that we just assume
cache files get ~%67 full on average). Here's an abridged version of
what the code does to tune -files if you haven't specified a value:

cacheFiles = max(   1000,
                    cacheBlocks/32,
                    1.5 * (cacheBlocks / (2 ^ (chunkSize-10)))
	     )

Where ^ represents an exponent, not XOR.

> What is the algorithm for auto-tuning the chunksize, or where can I
> find it?

This one is simpler. If your cache is smaller than about 500M, it uses
18. If it's between 500M and 1G, we use 19. If it's larger than 1G, we
use 20.

> Is there a way to measure how effective the chunksize is on a live
> system?

You can look at the cache performance metrics, and see if your miss
ratios seem worse than before you changed it. You can get these with
afsmonitor or 'xstat_cm_test <client> -collID 2 [-onceonly]', and you
can calculate the miss ratios using the dcacheHits/Misses and
vcacheHits/Misses values.

-- 
Andrew Deason
adeason@sinenomine.net