On Wed, Aug 24, 2005 at 03:10:02PM -0400, chas williams - CONTRACTOR wrote: > In message <[EMAIL PROTECTED]>,Troy Benjegerdes writes: > >avg.pl /var/cache/openafs | head > >72068 files > >1824410029 total bytes > >25315 avg bytes > > > >[EMAIL PROTECTED]:/afs/hozed.org$ fs getcache > >AFS using 10% of cache blocks (2061671 of 20000000 1k blocks) > > 2% of the cache files (9991 of 500000 files) > > i wouldnt expect that to match to closely. it counts files that > afs doesnt think are "in use". those file were are use at some > point. the script also ignores 0-length files when computing > the average.
Okay, i broke down and did some new stuff.. avg.pl /var/cache/openafs | head 91204 files src/venus/fs getcache -e AFS using 22% of cache blocks (4337734 of 20000000 1k blocks) 18% of the cache files (91202 of 500000 files) afs_cacheFiles: 500000 IFEverUsed: 9996 IFFree: 408798 IFDataMod: 0 IFFlag 0 IFDirtyPages: 0 IFAnyPages: 0 IFDiscarded: 0 DCentries: 9999 0 - 2K: 389 2k- 16k: 4179 4k- 64k: 924 8k- 256k: 1647 16k- 1M: 1297 32k- 4K: 859 64k- 16k: 428 128k- 64k: 134 256k- 256k: 51 512k- 1M: 17 1M: 74 The new version scans the afs_indexFlags array and counts how many entries have 'IFFree' set, and subtracts that from cacheFiles to get the usage. I can only easily (as far as I know) get the file size statistics for cache files that have current active dcache entries.. which is limited to 10000 files right now... is that a little small? The tuning parameters for the number of dcache entries seem rather arbitrary. I orginally had stats for '0-4k, 4k-16k', etc, which fit in the MAXGCSIZE variable quite nicely. I tried changing that to 32, but I think it's not worth bothering with How much value are the size statistics for what's in dcache anyway? Also, 'fs getcache -old' takes about 1ms of system time to run. Using 'fs getcache', which causes a scan of 500K indexFlags items takes about 5ms. And the 'fs getcache -e' version, which also scans the active dcache entries for sizes, takes 15ms.
Index: src/afs/afs_pioctl.c =================================================================== RCS file: /cvs/openafs/src/afs/afs_pioctl.c,v retrieving revision 1.102 diff -u -r1.102 afs_pioctl.c --- src/afs/afs_pioctl.c 28 Jul 2005 14:38:36 -0000 1.102 +++ src/afs/afs_pioctl.c 24 Aug 2005 21:02:48 -0000 @@ -2150,17 +2150,65 @@ return 0; } -#define MAXGCSTATS 16 +#define MAXGCSTATS 32 DECL_PIOCTL(PGetCacheSize) { afs_int32 results[MAXGCSTATS]; - + afs_int32 flags; + register struct dcache * tdc; + int i, size, statsize; + AFS_STATCNT(PGetCacheSize); + + if (sizeof(afs_int32) == ainSize){ + memcpy((char *)&flags, ain, sizeof(afs_int32)); + statsize = 32 * sizeof(afs_int32); + } else if (0 == ainSize){ + flags = 0; + statsize = 16 * sizeof(afs_int32); + } else { + return EINVAL; + } + memset((char *)results, 0, sizeof(results)); results[0] = afs_cacheBlocks; results[1] = afs_blocksUsed; - memcpy(aout, (char *)results, sizeof(results)); - *aoutSize = sizeof(results); + results[2] = afs_cacheFiles; + + if (1 == flags){ + for (i = 0; i < afs_cacheFiles; i++) { + if (afs_indexFlags[i] & IFFree) results[4]++; + } + } else if (2 == flags){ + for (i = 0; i < afs_cacheFiles; i++) { + if (afs_indexFlags[i] & IFEverUsed) results[3]++; + if (afs_indexFlags[i] & IFFree) results[4]++; + if (afs_indexFlags[i] & IFDataMod) results[5]++; + if (afs_indexFlags[i] & IFFlag) results[6]++; + if (afs_indexFlags[i] & IFDirtyPages) results[7]++; + if (afs_indexFlags[i] & IFAnyPages) results[8]++; + if (afs_indexFlags[i] & IFDiscarded) results[9]++; + + tdc = afs_indexTable[i]; + if (tdc){ + results[10]++; + size = tdc->validPos; + if ( 0 < size && size < (1<<11) ) results[11]++; + else if (size < (1<<12) ) results[12]++; + else if (size < (1<<13) ) results[13]++; + else if (size < (1<<14) ) results[14]++; + else if (size < (1<<15) ) results[15]++; + else if (size < (1<<16) ) results[16]++; + else if (size < (1<<17) ) results[17]++; + else if (size < (1<<18) ) results[18]++; + else if (size < (1<<19) ) results[19]++; + else if (size < (1<<20) ) results[20]++; + else if (size >= (1<<20)) results[21]++; + } + } + } + memcpy(aout, (char *)results, statsize); + *aoutSize = statsize; return 0; } Index: src/afsd/afsd.c =================================================================== RCS file: /cvs/openafs/src/afsd/afsd.c,v retrieving revision 1.55 diff -u -r1.55 afsd.c --- src/afsd/afsd.c 17 Aug 2005 16:16:50 -0000 1.55 +++ src/afsd/afsd.c 24 Aug 2005 21:02:48 -0000 @@ -1689,7 +1689,13 @@ if (cacheFiles < 100) fprintf(stderr, "%s: WARNING: cache probably too small!\n", rn); - + +#define MAXFILES 500000 + if (cacheFiles > MAXFILES){ + fprintf(stderr, "%s: WARNING: cacheFiles was %d\n", rn, cacheFiles); + fprintf(stderr, " limiting to %d\n", MAXFILES); + cacheFiles = MAXFILES; + } if (afsd_verbose) printf("%s: cacheFiles autotuned to %d\n", rn, cacheFiles); } @@ -2387,7 +2393,7 @@ syscall(AFS_SYSCALL, AFSCALL_CALL, param1, param2, param3, param4, param5, param6, param7); - if (afsd_verbose) + if (afsd_debug) printf("SScall(%d, %d, %d)=%d ", AFS_SYSCALL, AFSCALL_CALL, param1, error); return (error); Index: src/venus/fs.c =================================================================== RCS file: /cvs/openafs/src/venus/fs.c,v retrieving revision 1.28 diff -u -r1.28 fs.c --- src/venus/fs.c 24 Jun 2005 02:54:13 -0000 1.28 +++ src/venus/fs.c 24 Aug 2005 21:02:50 -0000 @@ -1208,7 +1208,7 @@ struct vcxstat2 stat; blob.out_size = sizeof(struct vcxstat2); blob.in_size = 0; - blob.out = &stat; + blob.out = (void *)&stat; code = pioctl(ti->data, VIOC_GETVCXSTATUS2, &blob, 1); if (code) { Die(errno, ti->data); @@ -2002,17 +2002,32 @@ return 0; } -#define MAXGCSIZE 16 +#define MAXGCSIZE 32 static int GetCacheParmsCmd(struct cmd_syndesc *as, char *arock) { - afs_int32 code; + afs_int32 code, filesUsed; struct ViceIoctl blob; afs_int32 parms[MAXGCSIZE]; + double percent; + afs_int32 flags = 0; + + if (as->parms[0].items){ /* -old */ + flags = 0; + } else if (as->parms[1].items){ /* -excessive */ + flags = 2; + } else { + flags = 1; + } memset(parms, '\0', sizeof parms); /* avoid Purify UMR error */ - blob.in = NULL; - blob.in_size = 0; + if (flags){ + blob.in = (char *)&flags; + blob.in_size = sizeof(afs_int32); + } else { /* be backward compatible */ + blob.in = NULL; + blob.in_size = 0; + } blob.out_size = sizeof(parms); blob.out = (char *)parms; code = pioctl(0, VIOCGETCACHEPARMS, &blob, 1); @@ -2020,11 +2035,46 @@ Die(errno, NULL); return 1; } - printf("AFS using %d of the cache's available %d 1K byte blocks.\n", - parms[1], parms[0]); + + if (!flags){ + printf("AFS using %d of the cache's available %d 1K byte blocks.\n", + parms[1], parms[0]); + return 0; + } + + percent = ((double)parms[1]/parms[0]) * 100; + printf("AFS using %5.0f%% of cache blocks (%d of %d 1k blocks)\n", + percent, parms[1], parms[0]); if (parms[1] > parms[0]) printf ("[Cache guideline temporarily deliberately exceeded; it will be adjusted down but you may wish to increase the cache size.]\n"); + + filesUsed = parms[2] - parms[4]; + percent = ((double)filesUsed/parms[2]) * 100; + printf(" %5.0f%% of the cache files (%d of %d files)\n", + percent, filesUsed, parms[2]); + if (flags == 2){ + printf(" afs_cacheFiles: %10d\n", parms[2], parms[10]); + printf(" IFEverUsed: %10d\n", parms[3], parms[11]); + printf(" IFFree: %10d\n", parms[4], parms[12]); + printf(" IFDataMod: %10d\n", parms[5], parms[13]); + printf(" IFFlag %10d\n", parms[6], parms[14]); + printf(" IFDirtyPages: %10d\n", parms[7], parms[15]); + printf(" IFAnyPages: %10d\n", parms[8]); + printf(" IFDiscarded: %10d\n", parms[9]); + printf(" DCentries: %10d\n", parms[10]); + printf(" 0 - 2K: %10d\n", parms[11]); + printf(" 2k- 16k: %10d\n", parms[12]); + printf(" 4k- 64k: %10d\n", parms[13]); + printf(" 8k- 256k: %10d\n", parms[14]); + printf(" 16k- 1M: %10d\n", parms[15]); + printf(" 32k- 4K: %10d\n", parms[16]); + printf(" 64k- 16k: %10d\n", parms[17]); + printf(" 128k- 64k: %10d\n", parms[18]); + printf(" 256k- 256k: %10d\n", parms[19]); + printf(" 512k- 1M: %10d\n", parms[20]); + printf(" 1M: %10d\n", parms[21]); + } return 0; } @@ -3317,6 +3367,8 @@ ts = cmd_CreateSyntax("getcacheparms", GetCacheParmsCmd, 0, "get cache usage info"); + cmd_AddParm(ts, "-old", CMD_FLAG, CMD_OPTIONAL, "Old one-line output"); + cmd_AddParm(ts, "-excessive", CMD_FLAG, CMD_OPTIONAL, "excessively verbose cache stats"); ts = cmd_CreateSyntax("listcells", ListCellsCmd, 0, "list configured cells");