From: Jack Lange Date: Tue, 14 Apr 2009 23:26:25 +0000 (-0500) Subject: removed floating poing operations from hashtable, load factors are now precomputed X-Git-Url: http://v3vee.org/palacios/gitweb/gitweb.cgi?p=palacios.git;a=commitdiff_plain;h=0dc6c1ec345d5c48e348b7e6532e5dcec00fa2ff removed floating poing operations from hashtable, load factors are now precomputed --- diff --git a/palacios/include/palacios/vmm_string.h b/palacios/include/palacios/vmm_string.h index 975a3d1..607130d 100644 --- a/palacios/include/palacios/vmm_string.h +++ b/palacios/include/palacios/vmm_string.h @@ -56,10 +56,6 @@ char *strrchr(const char *s, int c); char *strpbrk(const char *s, const char *accept); -double v3_ceil(double x); - - - #endif // !__V3VEE__ #endif /* STRING_H */ diff --git a/palacios/src/palacios/vmm_hashtable.c b/palacios/src/palacios/vmm_hashtable.c index fe74dc7..ce0bee2 100644 --- a/palacios/src/palacios/vmm_hashtable.c +++ b/palacios/src/palacios/vmm_hashtable.c @@ -187,9 +187,19 @@ static const uint_t primes[] = { 805306457, 1610612741 }; +// this assumes that the max load factor is .65 +static const uint_t load_factors[] = { + 35, 64, 126, 253, + 500, 1003, 2002, 3999, + 7988, 15986, 31953, 63907, + 127799, 255607, 511182, 1022365, + 2044731, 4089455, 8178897, 16357798, + 32715575, 65431158, 130862298, 261724573, + 523449198, 1046898282 }; + const uint_t prime_table_length = sizeof(primes) / sizeof(primes[0]); -const float max_load_factor = 0.65; + /*****************************************************************************/ struct hashtable * create_hashtable(uint_t min_size, @@ -233,7 +243,7 @@ struct hashtable * create_hashtable(uint_t min_size, htable->entry_count = 0; htable->hash_fn = hash_fn; htable->eq_fn = eq_fn; - htable->load_limit = (uint_t) v3_ceil((double)(size * max_load_factor)); + htable->load_limit = load_factors[prime_index]; return htable; } @@ -317,7 +327,7 @@ static int hashtable_expand(struct hashtable * htable) { htable->table_length = new_size; - htable->load_limit = (uint_t) v3_ceil(new_size * max_load_factor); + htable->load_limit = load_factors[htable->prime_index]; return -1; } diff --git a/palacios/src/palacios/vmm_string.c b/palacios/src/palacios/vmm_string.c index 77cee82..efe5a7d 100644 --- a/palacios/src/palacios/vmm_string.c +++ b/palacios/src/palacios/vmm_string.c @@ -60,17 +60,6 @@ #include - -static float e = 0.00000001; - -double v3_ceil(double x) { - if ((double)(x - (int)x) == 0) { - return (int)x; - } - return (int)(x + e) + 1; -} - - #if NEED_MEMSET void* memset(void* s, int c, size_t n) {