[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[hurd] 06/87: libdiskfs: remove the statistics code from the name cache
From: |
Samuel Thibault |
Subject: |
[hurd] 06/87: libdiskfs: remove the statistics code from the name cache |
Date: |
Sun, 09 Nov 2014 11:04:59 +0000 |
This is an automated email from the git hooks/post-receive script.
sthibault pushed a commit to branch upstream
in repository hurd.
commit d0c565fc35e8dc3daa5fb6e9a514c34873e6b204
Author: Justus Winter <address@hidden>
Date: Wed May 28 16:48:04 2014 +0200
libdiskfs: remove the statistics code from the name cache
The current name cache lookup operation completes in O(n) time. This
means that making the cache too large would decrease the performance.
Therefore it was required to tune the size, hence the need for
statistics.
We will use a data structure with worst case constant lookup times in
the future, removing the need to fine tune the cache size.
* libdiskfs/name-cache.c: Remove the statistics code from the name
cache.
---
libdiskfs/name-cache.c | 66 +-------------------------------------------------
1 file changed, 1 insertion(+), 65 deletions(-)
diff --git a/libdiskfs/name-cache.c b/libdiskfs/name-cache.c
index a212a6d..25b5d0d 100644
--- a/libdiskfs/name-cache.c
+++ b/libdiskfs/name-cache.c
@@ -45,29 +45,12 @@ struct lookup_cache
/* Strlen of NAME. If this is zero, it's an unused entry. */
size_t name_len;
-
- /* XXX */
- int stati;
};
/* The contents of the cache in no particular order */
static struct cacheq lookup_cache = { sizeof (struct lookup_cache) };
static pthread_spinlock_t cache_lock = PTHREAD_SPINLOCK_INITIALIZER;
-
-/* Buffer to hold statistics */
-static struct stats
-{
- long pos_hits;
- long neg_hits;
- long miss;
- long fetch_errors;
-} statistics;
-
-#define PARTIAL_THRESH 100
-#define NPARTIALS MAXCACHE / PARTIAL_THRESH
-struct stats partial_stats [NPARTIALS];
-
/* If there's an entry for NAME, of length NAME_LEN, in directory DIR in the
cache, return its entry, otherwise 0. CACHE_LOCK must be held. */
@@ -85,10 +68,7 @@ find_cache (struct node *dir, const char *name, size_t
name_len)
if (c->name_len == name_len
&& c->dir_cache_id == dir->cache_id
&& c->name[0] == name[0] && strcmp (c->name, name) == 0)
- {
- c->stati = i / 100;
- return c;
- }
+ return c;
return 0;
}
@@ -152,46 +132,6 @@ diskfs_purge_lookup_cache (struct node *dp, struct node
*np)
pthread_spin_unlock (&cache_lock);
}
-/* Register a negative hit for an entry in the Nth stat class */
-void
-register_neg_hit (int n)
-{
- int i;
-
- statistics.neg_hits++;
-
- for (i = 0; i < n; i++)
- partial_stats[i].miss++;
- for (; i < NPARTIALS; i++)
- partial_stats[i].neg_hits++;
-}
-
-/* Register a positive hit for an entry in the Nth stat class */
-void
-register_pos_hit (int n)
-{
- int i;
-
- statistics.pos_hits++;
-
- for (i = 0; i < n; i++)
- partial_stats[i].miss++;
- for (; i < NPARTIALS; i++)
- partial_stats[i].pos_hits++;
-}
-
-/* Register a miss */
-void
-register_miss ()
-{
- int i;
-
- statistics.miss++;
- for (i = 0; i < NPARTIALS; i++)
- partial_stats[i].miss++;
-}
-
-
/* Scan the cache looking for NAME inside DIR. If we don't know
anything entry at all, then return 0. If the entry is confirmed to
@@ -214,14 +154,12 @@ diskfs_check_lookup_cache (struct node *dir, const char
*name)
if (id == 0)
/* A negative cache entry. */
{
- register_neg_hit (c->stati);
pthread_spin_unlock (&cache_lock);
return (struct node *)-1;
}
else if (id == dir->cache_id)
/* The cached node is the same as DIR. */
{
- register_pos_hit (c->stati);
pthread_spin_unlock (&cache_lock);
diskfs_nref (dir);
return dir;
@@ -232,7 +170,6 @@ diskfs_check_lookup_cache (struct node *dir, const char
*name)
struct node *np;
error_t err;
- register_pos_hit (c->stati);
pthread_spin_unlock (&cache_lock);
if (name[0] == '.' && name[1] == '.' && name[2] == '\0')
@@ -259,7 +196,6 @@ diskfs_check_lookup_cache (struct node *dir, const char
*name)
}
}
- register_miss ();
pthread_spin_unlock (&cache_lock);
return 0;
--
Alioth's /usr/local/bin/git-commit-notice on
/srv/git.debian.org/git/pkg-hurd/hurd.git
- [hurd] 77/87: pfinet: fix path in comment, (continued)
- [hurd] 77/87: pfinet: fix path in comment, Samuel Thibault, 2014/11/09
- [hurd] 76/87: libports: lock-less reference counting for port_info objects, Samuel Thibault, 2014/11/09
- [hurd] 81/87: Fix unlocking translator list, Samuel Thibault, 2014/11/09
- [hurd] 63/87: Update NEWS file, Samuel Thibault, 2014/11/09
- [hurd] 09/87: Merge branch 'master' of git.savannah.gnu.org:/srv/git/hurd/hurd, Samuel Thibault, 2014/11/09
- [hurd] 85/87: mach-defpager: use protected payloads for object lookups, Samuel Thibault, 2014/11/09
- [hurd] 87/87: Merge remote-tracking branch 'upstream/master' into upstream, Samuel Thibault, 2014/11/09
- [hurd] 12/87: build: Remove checks for 'getgrouplist' and 'uselocale'., Samuel Thibault, 2014/11/09
- [hurd] 10/87: libstore: provide function declaration until available upstream, Samuel Thibault, 2014/11/09
- [hurd] 01/87: Do not include the terminating zero in /proc/slabinfo, Samuel Thibault, 2014/11/09
- [hurd] 06/87: libdiskfs: remove the statistics code from the name cache,
Samuel Thibault <=
- [hurd] 84/87: Fix optional definitions in static binaries, Samuel Thibault, 2014/11/09
- [hurd] 03/87: libnetfs: add netfs_make_node_alloc to allocate fat nodes, Samuel Thibault, 2014/11/09
- [hurd] 72/87: libports: use a global hash table for the lookups, Samuel Thibault, 2014/11/09
- [hurd] 08/87: Disable linking when cross-compiling, Samuel Thibault, 2014/11/09
- [hurd] 04/87: trans/fakeroot: use fat nodes to simplify the node cache, Samuel Thibault, 2014/11/09
- [hurd] 11/87: Merge branch 'master' of git://git.sv.gnu.org/hurd/hurd, Samuel Thibault, 2014/11/09
- [hurd] 07/87: libdiskfs: use a hash table for the name cache, Samuel Thibault, 2014/11/09
- [hurd] 05/87: trans/fakeroot: use netfs_node_netnode instead of np->nn, Samuel Thibault, 2014/11/09
- [hurd] 86/87: libpager: use a fixed number of threads, Samuel Thibault, 2014/11/09
- [hurd] 02/87: libdiskfs: add diskfs_make_node_alloc to allocate fat nodes, Samuel Thibault, 2014/11/09