[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[hurd] 30/31: libihash: rehash if effective load exceeds the threshold
From: |
Samuel Thibault |
Subject: |
[hurd] 30/31: libihash: rehash if effective load exceeds the threshold |
Date: |
Mon, 02 May 2016 23:48:33 +0000 |
This is an automated email from the git hooks/post-receive script.
sthibault pushed a commit to branch upstream
in repository hurd.
commit 9d29cfbf9fd8a0e26a3410194d1a060114973ad2
Author: Justus Winter <address@hidden>
Date: Thu Apr 28 21:12:58 2016 +0200
libihash: rehash if effective load exceeds the threshold
Previously, if a hash table was not growing anymore but entries were
regularly replaced, the tombstones would accumulate slowing down
lookups and insertions. A possible solution is to rehash the table if
the effective load exceeds the configured threshold. The effective
load also takes tombstones into account.
* libihash/ihash.c (hurd_ihash_locp_add): Use the effective load.
(hurd_ihash_add): Likewise. Use the load to decide whether we want to
enlarge the table, otherwise we merely rehash.
---
libihash/ihash.c | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/libihash/ihash.c b/libihash/ihash.c
index 800f492..ae1cf12 100644
--- a/libihash/ihash.c
+++ b/libihash/ihash.c
@@ -289,7 +289,7 @@ hurd_ihash_locp_add (hurd_ihash_t ht, hurd_ihash_locp_t
locp,
|| item == NULL
|| item->value == _HURD_IHASH_DELETED
|| ! compare (ht, item->key, key)
- || hurd_ihash_get_load (ht) > ht->max_load)
+ || hurd_ihash_get_effective_load (ht) > ht->max_load)
return hurd_ihash_add (ht, key, value);
if (item->value == _HURD_IHASH_EMPTY)
@@ -331,17 +331,19 @@ hurd_ihash_add (hurd_ihash_t ht, hurd_ihash_key_t key,
hurd_ihash_value_t item)
if (ht->size)
{
/* Only fill the hash table up to its maximum load factor. */
- if (hurd_ihash_get_load (ht) <= ht->max_load)
+ if (hurd_ihash_get_effective_load (ht) <= ht->max_load)
add_one:
if (add_one (ht, key, item))
return 0;
}
- /* The hash table is too small, and we have to increase it. */
+ /* If the load exceeds the configured maximal load, then the hash
+ table is too small, and we have to increase it. Otherwise we
+ merely rehash the table to get rid of the tombstones. */
ht->nr_items = 0;
if (ht->size == 0)
ht->size = HURD_IHASH_MIN_SIZE;
- else
+ else if (hurd_ihash_get_load (&old_ht) > ht->max_load)
ht->size <<= 1;
ht->nr_free = ht->size;
--
Alioth's /usr/local/bin/git-commit-notice on
/srv/git.debian.org/git/pkg-hurd/hurd.git
- [hurd] 23/31: startup: implement bits of the fs and io protocols, (continued)
- [hurd] 23/31: startup: implement bits of the fs and io protocols, Samuel Thibault, 2016/05/02
- [hurd] 11/31: libfshelp: pass cookie to the callback function, Samuel Thibault, 2016/05/02
- [hurd] 13/31: Merge branch 'master' of git.savannah.gnu.org:/srv/git/hurd/hurd, Samuel Thibault, 2016/05/02
- [hurd] 20/31: libshouldbeinlibc: add assert(3) variant that prints backtraces, Samuel Thibault, 2016/05/02
- [hurd] 07/31: utils/settrans: get an authenticated root node in chroot mode, Samuel Thibault, 2016/05/02
- [hurd] 06/31: isofs: make superblock detection more robust, Samuel Thibault, 2016/05/02
- [hurd] 08/31: utils/settrans: add option to specify the underlying node, Samuel Thibault, 2016/05/02
- [hurd] 31/31: Fix build, Samuel Thibault, 2016/05/02
- [hurd] 29/31: libihash: keep track of free slots, Samuel Thibault, 2016/05/02
- [hurd] 10/31: mach-defpager: fix error handling, Samuel Thibault, 2016/05/02
- [hurd] 30/31: libihash: rehash if effective load exceeds the threshold,
Samuel Thibault <=
- [hurd] 26/31: startup: write all messages to stderr, Samuel Thibault, 2016/05/02
- [hurd] 27/31: Fix root operations on trivfs-translated nodes, Samuel Thibault, 2016/05/02
- [hurd] 16/31: libtrivfs: fix notion of privileged user, Samuel Thibault, 2016/05/02
- [hurd] 28/31: libihash: fix index computation, Samuel Thibault, 2016/05/02
- [hurd] 24/31: startup: add verbose parameter, Samuel Thibault, 2016/05/02
- [hurd] 25/31: startup: use the generated default server implementations, Samuel Thibault, 2016/05/02
- [hurd] 01/31: netfs: Remove global reference count lock., Samuel Thibault, 2016/05/03
- [hurd] 04/31: Use posix types for mig definitions., Samuel Thibault, 2016/05/03