afs: Increase vcache and dcache hash table sizes

Now that we are using a real hash function, larger hash tables
will be more useful.

The vcache hash tables are statically sized, and this increase will
add about a megabyte to the kernel module's memory footprint.

Update the algorithm used to dynamically size the dcache hash tables,
keeping the old behavior for small numbers of dcaches, but growing
the hash table's size to keep the average chain length near two
for a range of dcache numbers.  Cap the dcache hash tables at 32k
entries to avoid excessive resource usage.

This involves code from opr, namely opr/ffs.h, which is acceptable
in the kernel module because that header is a standalone header
like jhash.h, with no dependencies on the system.

Change-Id: I7cdb3e993b1c2ad177a46ecc06bfa2be52e619e5
Reviewed-on: http://gerrit.openafs.org/11679
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Tested-by: Benjamin Kaduk <kaduk@mit.edu>
This commit is contained in:
Benjamin Kaduk 2015-01-15 11:54:30 -05:00
parent 9b0d5f274f
commit 8e97a6c936
2 changed files with 14 additions and 1 deletions

View File

@ -85,7 +85,7 @@ extern int afs_shuttingdown;
#define NSERVERS 16 /* hash table size for server table */
#define NVOLS 64 /* hash table size for volume table */
#define NFENTRIES 256 /* hash table size for disk volume table */
#define VCSIZEBITS 10 /* log of stat cache hash table size */
#define VCSIZEBITS 16 /* log of stat cache hash table size */
#define VCSIZE (opr_jhash_size(VCSIZEBITS))
#define CBRSIZE 512 /* call back returns hash table size */
#define PIGGYSIZE 1350 /* max piggyback size */

View File

@ -20,6 +20,8 @@
#include "afs/afs_cbqueue.h"
#include "afs/afs_osidnlc.h"
#include <opr/ffs.h>
/* Forward declarations. */
static void afs_GetDownD(int anumber, int *aneedSpace, afs_int32 buckethint);
static int afs_FreeDiscardedDCache(void);
@ -3249,6 +3251,7 @@ afs_dcacheInit(int afiles, int ablocks, int aDentries, int achunk, int aflags)
struct dcache *tdp;
int i;
int code;
int afs_dhashbits;
afs_freeDCList = NULLIDX;
afs_discardDCList = NULLIDX;
@ -3270,8 +3273,18 @@ afs_dcacheInit(int afiles, int ablocks, int aDentries, int achunk, int aflags)
if (!aDentries)
aDentries = DDSIZE;
/* afs_dhashsize defaults to 1024 */
if (aDentries > 512)
afs_dhashsize = 2048;
/* Try to keep the average chain length around two unless the table
* would be ridiculously big. */
if (aDentries > 4096) {
afs_dhashbits = opr_fls(aDentries) - 3;
/* Cap the hash tables to 32k entries. */
if (afs_dhashbits > 15)
afs_dhashbits = 15;
afs_dhashsize = opr_jhash_size(afs_dhashbits);
}
/* initialize hash tables */
afs_dvhashTbl = afs_osi_Alloc(afs_dhashsize * sizeof(afs_int32));
osi_Assert(afs_dvhashTbl != NULL);