diff options
-rw-r--r-- | debian/patches/ihash0001-libihash-keep-track-of-free-slots.patch | 85 | ||||
-rw-r--r-- | debian/patches/ihash0002-libdiskfs-nodecache-introspection-hack.patch | 35 | ||||
-rw-r--r-- | debian/patches/series | 2 |
3 files changed, 122 insertions, 0 deletions
diff --git a/debian/patches/ihash0001-libihash-keep-track-of-free-slots.patch b/debian/patches/ihash0001-libihash-keep-track-of-free-slots.patch new file mode 100644 index 00000000..60ba1f40 --- /dev/null +++ b/debian/patches/ihash0001-libihash-keep-track-of-free-slots.patch @@ -0,0 +1,85 @@ +From 2b9bd55356616b24b6f01e11280de2c9b09237e9 Mon Sep 17 00:00:00 2001 +From: Justus Winter <justus@gnupg.org> +Date: Thu, 28 Apr 2016 20:11:27 +0200 +Subject: [PATCH hurd 1/2] libihash: keep track of free slots + +* libihash/ihash.c (hurd_ihash_init): Init new field 'nr_free'. +(add_one): Decrement counter if a free slot is used. +(hurd_ihash_locp_add): Likewise. +(hurd_ihash_add): Reset counter on reallocation. +* libihash/ihash.h (struct hurd_ihash): New field 'nr_free'. +(hurd_ihash_get_effective_load): New function. +--- + libihash/ihash.c | 5 +++++ + libihash/ihash.h | 11 +++++++++++ + 2 files changed, 16 insertions(+) + +diff --git a/libihash/ihash.c b/libihash/ihash.c +index 4bc54fd..66175ca 100644 +--- a/libihash/ihash.c ++++ b/libihash/ihash.c +@@ -136,6 +136,7 @@ hurd_ihash_init (hurd_ihash_t ht, intptr_t locp_offs) + ht->cleanup = 0; + ht->fct_hash = NULL; + ht->fct_cmp = NULL; ++ ht->nr_free = 0; + } + + +@@ -251,6 +252,8 @@ add_one (hurd_ihash_t ht, hurd_ihash_key_t key, hurd_ihash_value_t value) + if (index_empty (ht, idx)) + { + ht->nr_items++; ++ if (ht->items[idx].value == _HURD_IHASH_EMPTY) ++ ht->nr_free--; + ht->items[idx].value = value; + ht->items[idx].key = key; + +@@ -295,6 +298,7 @@ hurd_ihash_locp_add (hurd_ihash_t ht, hurd_ihash_locp_t locp, + { + item->key = key; + ht->nr_items += 1; ++ ht->nr_free -= 1; + } + else + { +@@ -340,6 +344,7 @@ hurd_ihash_add (hurd_ihash_t ht, hurd_ihash_key_t key, hurd_ihash_value_t item) + ht->size = HURD_IHASH_MIN_SIZE; + else + ht->size <<= 1; ++ ht->nr_free = ht->size; + + /* calloc() will initialize all values to _HURD_IHASH_EMPTY implicitly. */ + ht->items = calloc (ht->size, sizeof (struct _hurd_ihash_item)); +diff --git a/libihash/ihash.h b/libihash/ihash.h +index 356f647..80679f1 100644 +--- a/libihash/ihash.h ++++ b/libihash/ihash.h +@@ -113,6 +113,9 @@ struct hurd_ihash + /* User-supplied functions for the generalized key interface. */ + hurd_ihash_fct_hash_t fct_hash; + hurd_ihash_fct_cmp_t fct_cmp; ++ ++ /* Number of free slots. */ ++ size_t nr_free; + }; + typedef struct hurd_ihash *hurd_ihash_t; + +@@ -225,6 +228,14 @@ hurd_ihash_get_load (hurd_ihash_t ht) + return d >= 0 ? ht->nr_items >> d : ht->nr_items << -d; + } + ++/* Similar, but counts tombstones as well. */ ++static inline unsigned int ++hurd_ihash_get_effective_load (hurd_ihash_t ht) ++{ ++ int d = __builtin_ctzl (ht->size) - 7; ++ return ++ d >= 0 ? (ht->size - ht->nr_free) >> d : (ht->size - ht->nr_free) << -d; ++} + + /* Add ITEM to the hash table HT under the key KEY. If there already + is an item under this key, call the cleanup function (if any) for +-- +2.1.4 + diff --git a/debian/patches/ihash0002-libdiskfs-nodecache-introspection-hack.patch b/debian/patches/ihash0002-libdiskfs-nodecache-introspection-hack.patch new file mode 100644 index 00000000..d9183bf3 --- /dev/null +++ b/debian/patches/ihash0002-libdiskfs-nodecache-introspection-hack.patch @@ -0,0 +1,35 @@ +From bcb0290ae544bcd535451dc4d16b66a5952f17bf Mon Sep 17 00:00:00 2001 +From: Justus Winter <justus@gnupg.org> +Date: Thu, 28 Apr 2016 20:16:30 +0200 +Subject: [PATCH hurd 2/2] libdiskfs: nodecache introspection hack + +--- + libdiskfs/node-cache.c | 12 ++++++++++++ + 1 file changed, 12 insertions(+) + +diff --git a/libdiskfs/node-cache.c b/libdiskfs/node-cache.c +index ee7e6fd..6c65682 100644 +--- a/libdiskfs/node-cache.c ++++ b/libdiskfs/node-cache.c +@@ -60,6 +60,18 @@ static struct hurd_ihash nodecache = + hash, compare); + static pthread_rwlock_t nodecache_lock = PTHREAD_RWLOCK_INITIALIZER; + ++char * ++nodecache_hack (void) ++{ ++ static char *dbg; ++ free (dbg); ++ if (asprintf (&dbg, "(nodehash load: %db%%, effective load: %db%%)", ++ hurd_ihash_get_load (&nodecache), ++ hurd_ihash_get_effective_load (&nodecache)) < 0) ++ dbg = NULL; ++ return dbg; ++} ++ + /* Fetch inode INUM, set *NPP to the node structure; + gain one user reference and lock the node. */ + error_t __attribute__ ((weak)) +-- +2.1.4 + diff --git a/debian/patches/series b/debian/patches/series index 56241515..eb31b3fe 100644 --- a/debian/patches/series +++ b/debian/patches/series @@ -50,3 +50,5 @@ startup0002-startup-implement-bits-of-the-fs-and-io-protocols.patch startup0003-startup-add-verbose-parameter.patch startup0004-startup-use-the-generated-default-server-implementat.patch startup0005-startup-write-all-messages-to-stderr.patch +ihash0001-libihash-keep-track-of-free-slots.patch +ihash0002-libdiskfs-nodecache-introspection-hack.patch |