diff options
author | Thomas White <taw@physics.org> | 2015-08-31 13:52:35 +0200 |
---|---|---|
committer | Thomas White <taw@physics.org> | 2015-08-31 13:52:35 +0200 |
commit | ab098ce1ab9b67a196621d9e099743d0ad8510d4 (patch) | |
tree | 7870e5bfca03d2f1a5fcc5cb3c324608f7f377c7 | |
parent | 63a06127735849268fb6e1e6495c7537e8be5a0d (diff) |
partialator: Improve hash function and diagnostics
-rw-r--r-- | src/partialator.c | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/src/partialator.c b/src/partialator.c index 2e3c3477..5c67504b 100644 --- a/src/partialator.c +++ b/src/partialator.c @@ -66,7 +66,7 @@ struct csplit_hash_entry int *datasets; }; -#define CSPLIT_HASH_MAX (65536) +#define CSPLIT_HASH_MAX (65521) struct custom_split { @@ -84,8 +84,7 @@ static int csplit_hash(const char *id) int h = 0; for ( i=0; i<len; i++ ) { - h += id[i] * i; - h = h % CSPLIT_HASH_MAX; + h = (h*i +id[i]) % CSPLIT_HASH_MAX; } assert(h < CSPLIT_HASH_MAX); @@ -387,8 +386,15 @@ static struct custom_split *load_custom_split(const char *filename) fclose(fh); - STATUS("Hash table load factor = %.2f\n", - (double)csplit->n_events_total / CSPLIT_HASH_MAX); + int max = 0; + for ( i=0; i<CSPLIT_HASH_MAX; i++ ) { + if ( csplit->hashes[i].n_events > max ) { + max = csplit->hashes[i].n_events; + } + } + + STATUS("Hash table load factor = %.2f (max %i)\n", + (double)csplit->n_events_total / CSPLIT_HASH_MAX, max); return csplit; } |