Skip to contentSkip to conversation

GFS2: glock statistics gathering (RFC)

Cluster-devel Steven Whitehouse 2 participants 5 messages Nov 4, 2011 – Nov 7, 2011 GFS2 file system

lore
Share & tools
lore
#0 lore raw

Hi,

This is a work-in-progress at the moment, though I hope that it is not too far from the final form. The intent here is to add some code to gather some important and useful stats to help track what is going on within the filesystem.

The stats are divided into two sets: those relating to the super block and those relating to an individual glock. The super block stats are done on a per cpu basis in order to try and reduce the overhead of gathering them. They are also further divided by glock type.

In the case of both the super block and glock statistics, the same information is gathered in each case. The super block statistics are used to provide default values for most of the glock statistics, so that newly created glocks should have, as far as possible a sensible starting point.

The statistics are divided into three pairs of mean and variance, plus two counters. The mean/variance pairs are smoothed exponential estimates and the algorithm used is one which will be very familiar to those used to calculation of round trip times in network code.

The three pairs of mean/variance measure the following things:

1. DLM lock time (non-blocking requests)
2. DLM lock time (blocking requests)
3. Inter-request time (again to the DLM)

A non-blocking request is one which will complete right away, whatever the state of the DLM lock in question. That currently means any requests when (a) the current state of the lock is exclusive (b) the requested state is either null or unlocked or (c) the "try lock" flag is set. A blocking request covers all the other lock requests.

There are two counters. The first is there primarily to show how many lock requests have been made, and thus how much data has gone into the mean/variance calculations. The other counter is counting queueing of holders at the top layer of the glock code. Hopefully that number will be a lot larger than the number of dlm lock requests issued.

So why gather these statistics? There are several reasons we'd like to get a better idea of these timings:

1. To be able to better set the glock "min hold time"
2. To spot performance issues more easily
3. To improve the algorithm for selecting resource groups for allocation (to base it on lock wait time, rather than blindly using a "try lock")

I'm hoping to settle on a suitable minimum set of statistics which can give us the maximum amount of information for the minimum amount of overhead, both in computational terms and storage terms.

The stats take up 64 bytes per glock. Thats quite a lot, but there is scope for reducing the size of the glock. One thing I spotted was the ascii name field, used only once the first time we get a DLM lock. The patch removes that, saving 32 bytes (by the time padding was included) per glock.

There is potential for a greater saving in the future, since some of the existing time based fields could be removed in favour of using the new stats. That will be left for future patches though.

So some questions to ponder:

- Is this adding too much overhead?
- Do we need so much detail?
- Is there anything that has been missed out?

Obviously one concern is accuracy. Until the filesystem has had a workload running on it for a while, the stats will not be a true representation of what is going on in the system. That is the reason for having the counters, so that we can see how much data has been included.

Due to the smoothing action of the updates, a step change in some input quantity being sampled will only fully be taken into account after 8 samples (or 4 for the variance) and this needs to be carefully considered when interpreting the results.

Knowing both the time it takes a lock request to complete and the average time between lock requests for a glock means we can compute the total percentage of the time for which the node is able to use a glock vs. time that the rest of the cluster has its share. That will be very useful when setting the lock min hold time.

The other point to remember is that all times are in nanoseconds. Great care has been taken to ensure that we measure exactly the quantities that we want, as accurately as possible. There are always inaccuracies in any measuring system, but I hope this is as accurate as we can reasonably make it.

Anyway, here it is... let me know what you think,

Steve.

fs/gfs2/glock.c +200 -8
index 88e8a23..267e748 100644
@@ -29,6 +29,7 @@
 #include <linux/rcupdate.h>
 #include <linux/rculist_bl.h>
 #include <linux/bit_spinlock.h>
+#include <linux/percpu.h>
 
 #include "gfs2.h"
 #include "incore.h"
@@ -537,6 +538,11 @@ __acquires(&gl->gl_spin)
 		do_error(gl, 0); /* Fail queued try locks */
 	}
 	gl->gl_req = target;
+	set_bit(GLF_BLOCKING, &gl->gl_flags);
+	if ((gl->gl_req == LM_ST_UNLOCKED) ||
+	    (gl->gl_state == LM_ST_EXCLUSIVE) ||
+	    (lck_flags & (LM_FLAG_TRY|LM_FLAG_TRY_1CB)))
+		clear_bit(GLF_BLOCKING, &gl->gl_flags);
 	spin_unlock(&gl->gl_spin);
 	if (glops->go_xmote_th)
 		glops->go_xmote_th(gl);
@@ -738,6 +744,7 @@ int gfs2_glock_get(struct gfs2_sbd *sdp, u64 number,
 		return -ENOMEM;
 
 	atomic_inc(&sdp->sd_glock_disposal);
+	gl->gl_sbd = sdp;
 	gl->gl_flags = 0;
 	gl->gl_name = name;
 	atomic_set(&gl->gl_ref, 1);
@@ -746,12 +753,17 @@ int gfs2_glock_get(struct gfs2_sbd *sdp, u64 number,
 	gl->gl_demote_state = LM_ST_EXCLUSIVE;
 	gl->gl_hash = hash;
 	gl->gl_ops = glops;
-	snprintf(gl->gl_strname, GDLM_STRNAME_BYTES, "%8x%16llx", name.ln_type, (unsigned long long)number);
+	gl->gl_dstamp = ktime_set(0, 0);
+	preempt_disable();
+	/* We use the global stats to estimate the initial per-glock stats */
+	gl->gl_stats = this_cpu_ptr(sdp->sd_lkstats)->lkstats[glops->go_type];
+	preempt_enable();
+	gl->gl_stats.stats[GFS2_LKS_DCOUNT] = 0;
+	gl->gl_stats.stats[GFS2_LKS_QCOUNT] = 0;
 	memset(&gl->gl_lksb, 0, sizeof(struct dlm_lksb));
 	gl->gl_lksb.sb_lvbptr = gl->gl_lvb;
 	gl->gl_tchange = jiffies;
 	gl->gl_object = NULL;
-	gl->gl_sbd = sdp;
 	gl->gl_hold_time = GL_GLOCK_DFT_HOLD;
 	INIT_DELAYED_WORK(&gl->gl_work, glock_work_func);
 	INIT_WORK(&gl->gl_delete, delete_work_func);
@@ -993,6 +1005,8 @@ fail:
 	}
 	set_bit(GLF_QUEUED, &gl->gl_flags);
 	trace_gfs2_glock_queue(gh, 1);
+	gfs2_glstats_inc(gl, GFS2_LKS_QCOUNT);
+	gfs2_sbstats_inc(gl, GFS2_LKS_QCOUNT);
 	if (likely(insert_pt == NULL)) {
 		list_add_tail(&gh->gh_list, &gl->gl_holders);
 		if (unlikely(gh->gh_flags & LM_FLAG_PRIORITY))
@@ -1652,6 +1666,8 @@ static const char *gflags2str(char *buf, const struct gfs2_glock *gl)
 		*p++ = 'L';
 	if (gl->gl_object)
 		*p++ = 'o';
+	if (test_bit(GLF_BLOCKING, gflags))
+		*p++ = 'b';
 	*p = 0;
 	return buf;
 }
@@ -1708,8 +1724,76 @@ out:
 	return error;
 }
 
+static int gfs2_glstats_seq_show(struct seq_file *seq, void *iter_ptr)
+{
+	struct gfs2_glock *gl = iter_ptr;
+
+	seq_printf(seq, "G: n:%u/%llx rtt:%lld/%lld rttb:%lld/%lld irt:%lld/%lld dcnt: %lld qcnt: %lld\n",
+		   gl->gl_name.ln_type,
+		   (unsigned long long)gl->gl_name.ln_number,
+		   (long long)gl->gl_stats.stats[GFS2_LKS_SRTT],
+		   (long long)gl->gl_stats.stats[GFS2_LKS_SRTTVAR],
+		   (long long)gl->gl_stats.stats[GFS2_LKS_SRTTB],
+		   (long long)gl->gl_stats.stats[GFS2_LKS_SRTTVARB],
+		   (long long)gl->gl_stats.stats[GFS2_LKS_SIRT],
+		   (long long)gl->gl_stats.stats[GFS2_LKS_SIRTVAR],
+		   (long long)gl->gl_stats.stats[GFS2_LKS_DCOUNT],
+		   (long long)gl->gl_stats.stats[GFS2_LKS_QCOUNT]);
+	return 0;
+}
+
+static const char *gfs2_gltype[] = {
+	"type",
+	"reserved",
+	"nondisk",
+	"inode",
+	"rgrp",
+	"meta",
+	"iopen",
+	"flock",
+	"plock",
+	"quota",
+	"journal",
+};
+
+static const char *gfs2_stype[] = {
+	[GFS2_LKS_SRTT]		= "srtt",
+	[GFS2_LKS_SRTTVAR]	= "srttvar",
+	[GFS2_LKS_SRTTB]	= "srttb",
+	[GFS2_LKS_SRTTVARB]	= "srttvarb",
+	[GFS2_LKS_SIRT]		= "sirt",
+	[GFS2_LKS_SIRTVAR]	= "sirtvar",
+	[GFS2_LKS_DCOUNT]	= "dlm",
+	[GFS2_LKS_QCOUNT]	= "queue",
+};
+
+static int gfs2_sbstats_seq_show(struct seq_file *seq, void *iter_ptr)
+{
+	struct gfs2_glock_iter *gi = seq->private;
+	struct gfs2_sbd *sdp = gi->sdp;
+	unsigned index = gi->hash >> 3;
+	unsigned subindex = gi->hash & 0x07;
+	s64 value;
+	int i;
+
+	if (index == 0 && subindex != 0)
+		return 0;
 
+	seq_printf(seq, "%-10s %8s:", gfs2_gltype[index],
+		   (index == 0) ? "cpu": gfs2_stype[subindex]);
 
+	for_each_possible_cpu(i) {
+                const struct gfs2_pcpu_lkstats *lkstats = per_cpu_ptr(sdp->sd_lkstats, i);
+		if (index == 0) {
+			value = i;
+		} else {
+			value = lkstats->lkstats[index - 1].stats[subindex];
+		}
+		seq_printf(seq, " %15lld", (long long)value);
+	}
+	seq_putc(seq, '\n');
+	return 0;
+}
 
 int __init gfs2_glock_init(void)
 {
@@ -1822,6 +1906,35 @@ static int gfs2_glock_seq_show(struct seq_file *seq, void *iter_ptr)
 	return dump_glock(seq, iter_ptr);
 }
 
+static void *gfs2_sbstats_seq_start(struct seq_file *seq, loff_t *pos)
+{
+	struct gfs2_glock_iter *gi = seq->private;
+
+	gi->hash = *pos;
+	if (*pos > 87)
+		return NULL;
+	preempt_disable();
+	return SEQ_START_TOKEN;
+}
+
+static void *gfs2_sbstats_seq_next(struct seq_file *seq, void *iter_ptr,
+				   loff_t *pos)
+{
+	struct gfs2_glock_iter *gi = seq->private;
+	(*pos)++;
+	gi->hash++;
+	if (gi->hash > 87) {
+		preempt_enable();
+		return NULL;
+	}
+	return SEQ_START_TOKEN;
+}
+
+static void gfs2_sbstats_seq_stop(struct seq_file *seq, void *iter_ptr)
+{
+	preempt_enable();
+}
+
 static const struct seq_operations gfs2_glock_seq_ops = {
 	.start = gfs2_glock_seq_start,
 	.next  = gfs2_glock_seq_next,
@@ -1829,7 +1942,21 @@ static const struct seq_operations gfs2_glock_seq_ops = {
 	.show  = gfs2_glock_seq_show,
 };
 
-static int gfs2_debugfs_open(struct inode *inode, struct file *file)
+static const struct seq_operations gfs2_glstats_seq_ops = {
+	.start = gfs2_glock_seq_start,
+	.next  = gfs2_glock_seq_next,
+	.stop  = gfs2_glock_seq_stop,
+	.show  = gfs2_glstats_seq_show,
+};
+
+static const struct seq_operations gfs2_sbstats_seq_ops = {
+	.start = gfs2_sbstats_seq_start,
+	.next  = gfs2_sbstats_seq_next,
+	.stop  = gfs2_sbstats_seq_stop,
+	.show  = gfs2_sbstats_seq_show,
+};
+
+static int gfs2_glocks_open(struct inode *inode, struct file *file)
 {
 	int ret = seq_open_private(file, &gfs2_glock_seq_ops,
 				   sizeof(struct gfs2_glock_iter));
@@ -1841,9 +1968,49 @@ static int gfs2_debugfs_open(struct inode *inode, struct file *file)
 	return ret;
 }
 
-static const struct file_operations gfs2_debug_fops = {
+static int gfs2_glstats_open(struct inode *inode, struct file *file)
+{
+	int ret = seq_open_private(file, &gfs2_glstats_seq_ops,
+				   sizeof(struct gfs2_glock_iter));
+	if (ret == 0) {
+		struct seq_file *seq = file->private_data;
+		struct gfs2_glock_iter *gi = seq->private;
+		gi->sdp = inode->i_private;
+	}
+	return ret;
+}
+
+static int gfs2_sbstats_open(struct inode *inode, struct file *file)
+{
+	int ret = seq_open_private(file, &gfs2_sbstats_seq_ops,
+				   sizeof(struct gfs2_glock_iter));
+	if (ret == 0) {
+		struct seq_file *seq = file->private_data;
+		struct gfs2_glock_iter *gi = seq->private;
+		gi->sdp = inode->i_private;
+	}
+	return ret;
+}
+
+static const struct file_operations gfs2_glocks_fops = {
+	.owner   = THIS_MODULE,
+	.open    = gfs2_glocks_open,
+	.read    = seq_read,
+	.llseek  = seq_lseek,
+	.release = seq_release_private,
+};
+
+static const struct file_operations gfs2_glstats_fops = {
 	.owner   = THIS_MODULE,
-	.open    = gfs2_debugfs_open,
+	.open    = gfs2_glstats_open,
+	.read    = seq_read,
+	.llseek  = seq_lseek,
+	.release = seq_release_private,
+};
+
+static const struct file_operations gfs2_sbstats_fops = {
+	.owner   = THIS_MODULE,
+	.open	 = gfs2_sbstats_open,
 	.read    = seq_read,
 	.llseek  = seq_lseek,
 	.release = seq_release_private,
@@ -1857,20 +2024,45 @@ int gfs2_create_debugfs_file(struct gfs2_sbd *sdp)
 	sdp->debugfs_dentry_glocks = debugfs_create_file("glocks",
 							 S_IFREG | S_IRUGO,
 							 sdp->debugfs_dir, sdp,
-							 &gfs2_debug_fops);
+							 &gfs2_glocks_fops);
 	if (!sdp->debugfs_dentry_glocks)
-		return -ENOMEM;
+		goto fail;
+
+	sdp->debugfs_dentry_glstats = debugfs_create_file("glstats",
+							S_IFREG | S_IRUGO,
+							sdp->debugfs_dir, sdp,
+							&gfs2_glstats_fops);
+	if (!sdp->debugfs_dentry_glstats)
+		goto fail;
+
+	sdp->debugfs_dentry_sbstats = debugfs_create_file("sbstats",
+							S_IFREG | S_IRUGO,
+							sdp->debugfs_dir, sdp,
+							&gfs2_sbstats_fops);
+	if (!sdp->debugfs_dentry_sbstats)
+		goto fail;
 
 	return 0;
+fail:
+	gfs2_delete_debugfs_file(sdp);
+	return -ENOMEM;
 }
 
 void gfs2_delete_debugfs_file(struct gfs2_sbd *sdp)
 {
-	if (sdp && sdp->debugfs_dir) {
+	if (sdp->debugfs_dir) {
 		if (sdp->debugfs_dentry_glocks) {
 			debugfs_remove(sdp->debugfs_dentry_glocks);
 			sdp->debugfs_dentry_glocks = NULL;
 		}
+		if (sdp->debugfs_dentry_glstats) {
+			debugfs_remove(sdp->debugfs_dentry_glstats);
+			sdp->debugfs_dentry_glstats = NULL;
+		}
+		if (sdp->debugfs_dentry_sbstats) {
+			debugfs_remove(sdp->debugfs_dentry_sbstats);
+			sdp->debugfs_dentry_sbstats = NULL;
+		}
 		debugfs_remove(sdp->debugfs_dir);
 		sdp->debugfs_dir = NULL;
 	}
fs/gfs2/incore.h +42 -5

96 lines not on this page · raw message

fs/gfs2/lock_dlm.c +118 -5

170 lines not on this page · raw message

fs/gfs2/ops_fstype.c +8 -0
index 4998194..c7c9c1b 100644
@@ -67,6 +67,12 @@ static struct gfs2_sbd *init_sbd(struct super_block *sb)
 
 	sb->s_fs_info = sdp;
 	sdp->sd_vfs = sb;
+	sdp->sd_lkstats = alloc_percpu(struct gfs2_pcpu_lkstats);
+	if (!sdp->sd_lkstats) {
+		kfree(sdp);
+		return NULL;
+	}
+
 	set_bit(SDF_NOJOURNALID, &sdp->sd_flags);
 	gfs2_tune_init(&sdp->sd_tune);
 
@@ -1212,6 +1218,7 @@ fail_sys:
 	gfs2_sys_fs_del(sdp);
 fail:
 	gfs2_delete_debugfs_file(sdp);
+	free_percpu(sdp->sd_lkstats);
 	kfree(sdp);
 	sb->s_fs_info = NULL;
 	return error;
@@ -1384,6 +1391,7 @@ static void gfs2_kill_sb(struct super_block *sb)
 	shrink_dcache_sb(sb);
 	kill_block_super(sb);
 	gfs2_delete_debugfs_file(sdp);
+	free_percpu(sdp->sd_lkstats);
 	kfree(sdp);
 }
 
fs/gfs2/trace_gfs2.h +59 -1

78 lines not on this page · raw message

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listman.redhat.com/archives/cluster-devel/attachments/20111104/8104c330/attachment.htm>

#1 lore raw
Quoted 4 lines · Steven Whitehouse

The three pairs of mean/variance measure the following things:

1. DLM lock time (non-blocking requests)

You don't need to track and save this value, because all results will be one of three values which can gather once:

short: the dir node and master node are local: 0 network round trip
medium: one is local, one is remote: 1 network round trip
long: both are remote: 2 network round trips

Once you've measured values for short/med/long, then you're done. The distribution will depend on the usage pattern.

Quoted 1 line

2. DLM lock time (blocking requests)

I think what you want to quantify is how much contention a given lock is under. A time measurement is probably not a great way to get that since it's a combination of: the value above, how long gfs2 takes to release the lock (itself a combination of things, including the the tunable itself), and how many nodes are competing for the lock (depends on workload).

Quoted 1 line

3. Inter-request time (again to the DLM)

Time between gfs2 requesting the same lock? That sounds like it might work ok for measuring contention.

Quoted 1 line

1. To be able to better set the glock "min hold time"

Less for a lock with high contention?

Quoted 1 line

2. To spot performance issues more easily

Apart from contention, I'm not sure there are many perf issues that dlm measurements would help with.

Quoted 3 lines

3. To improve the algorithm for selecting resource groups for allocation (to base it on lock wait time, rather than blindly using a "try lock")

Don't you grab an rg lock and keep it cached? How would lock times help?

Also, ocfs2 keeps quite a lot of locking stats you might look at.

Dave

#2 lore raw

Hi,

Quoted 9 lines · David Teigland
Quoted 4 lines · Steven Whitehouse

The three pairs of mean/variance measure the following things:

1. DLM lock time (non-blocking requests)

You don't need to track and save this value, because all results will be one of three values which can gather once:

Quoted 7 lines

short: the dir node and master node are local: 0 network round trip
medium: one is local, one is remote: 1 network round trip
long: both are remote: 2 network round trips

Once you've measured values for short/med/long, then you're done. The distribution will depend on the usage pattern.

The reason for tracking this is to be able to compare it with the blocking request value to (I hope) get a rough idea of the difference between the two, which may indicate contention on the lock. So this is really a "baseline" measurement.

Plus we do need to measure it, since it will vary according to a number of things, such as what hardware is in use.

Quoted 8 lines
Quoted 1 line

2. DLM lock time (blocking requests)

I think what you want to quantify is how much contention a given lock is under. A time measurement is probably not a great way to get that since it's a combination of: the value above, how long gfs2 takes to release the lock (itself a combination of things, including the the tunable itself), and how many nodes are competing for the lock (depends on workload).

Quoted 9 lines
Quoted 1 line

3. Inter-request time (again to the DLM)

Time between gfs2 requesting the same lock? That sounds like it might work ok for measuring contention.

Quoted 1 line

1. To be able to better set the glock "min hold time"

Less for a lock with high contention?

Generally we want more (i.e. to reduce the number of times the lock gets passed around, and increase the time each node holds it) as otherwise we make no progress, or very slow progress. This does penalise interactive loads but increases throughput dramatically on batch loads.

Also, the point is that if we know the average time that it takes to get a lock, and we know how many locks per second we are requesting, then we can figure out the total percentage of time we are waiting for locks in total. If there are N nodes in the cluster and the node is getting the lock for less than 1/N of the total time, then it could increase its minimum hold time.

That kind of thing is useful in order to ensure that we continue to make progress under all circumstances.

Quoted 5 lines
Quoted 1 line

2. To spot performance issues more easily

Apart from contention, I'm not sure there are many perf issues that dlm measurements would help with.

That is the #1 cause of reported performance issues, so top of our list to work on. The goal is to make it easier to track down the source of these kinds of problems.

Quoted 6 lines
Quoted 3 lines

3. To improve the algorithm for selecting resource groups for allocation (to base it on lock wait time, rather than blindly using a "try lock")

Don't you grab an rg lock and keep it cached? How would lock times help?

Its only cached while other nodes are not trying to use the same rgrp. The same issue applies to them as to inode glocks in terms of contention. When allocating we have a choice to use another rgrp if the contention is causing a problem (hence the need for some info to base that choice upon). Unfortunately with deallocation, there is no choice and we have to use the specific rgrp(s) however contended they might be.

Quoted 3 lines

Also, ocfs2 keeps quite a lot of locking stats you might look at.

Dave

That might be useful depending on what they are gathering,

Steve.

#3 lore raw
Quoted 19 lines · Steven Whitehouse

Hi,

Quoted 9 lines · David Teigland
Quoted 4 lines · Steven Whitehouse

The three pairs of mean/variance measure the following things:

1. DLM lock time (non-blocking requests)

You don't need to track and save this value, because all results will be one of three values which can gather once:

Quoted 7 lines

short: the dir node and master node are local: 0 network round trip
medium: one is local, one is remote: 1 network round trip
long: both are remote: 2 network round trips

Once you've measured values for short/med/long, then you're done. The distribution will depend on the usage pattern.

Quoted 7 lines

The reason for tracking this is to be able to compare it with the blocking request value to (I hope) get a rough idea of the difference between the two, which may indicate contention on the lock. So this is really a "baseline" measurement.

Plus we do need to measure it, since it will vary according to a number of things, such as what hardware is in use.

Right, but the baseline shouldn't change once you have it.

Quoted 8 lines
Quoted 5 lines
Quoted 1 line

2. To spot performance issues more easily

Apart from contention, I'm not sure there are many perf issues that dlm measurements would help with.

That is the #1 cause of reported performance issues, so top of our list to work on. The goal is to make it easier to track down the source of these kinds of problems.

I still think that time averages and computations sounds like a difficult and indirect way of measuring contention... but see how it works.

Dave

#4 lore raw

Hi,

Quoted 25 lines · David Teigland
Quoted 24 lines · Steven Whitehouse

Hi,

Quoted 9 lines · David Teigland
Quoted 4 lines · Steven Whitehouse

The three pairs of mean/variance measure the following things:

1. DLM lock time (non-blocking requests)

You don't need to track and save this value, because all results will be one of three values which can gather once:

Quoted 7 lines

short: the dir node and master node are local: 0 network round trip
medium: one is local, one is remote: 1 network round trip
long: both are remote: 2 network round trips

Once you've measured values for short/med/long, then you're done. The distribution will depend on the usage pattern.

The reason for tracking this is to be able to compare it with the blocking request value to (I hope) get a rough idea of the difference between the two, which may indicate contention on the lock. So this is really a "baseline" measurement.

Quoted 5 lines
Quoted 2 lines

Plus we do need to measure it, since it will vary according to a number of things, such as what hardware is in use.

Right, but the baseline shouldn't change once you have it.

Well, I'm not sure I agree with that. The conditions on the network might change, and the conditions on a (remote) lock master may change. We have no way within GFS2 to measure such things directly, so we need a proxy for them.

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 1 line

2. To spot performance issues more easily

Apart from contention, I'm not sure there are many perf issues that dlm measurements would help with.

Quoted 9 lines
Quoted 3 lines

That is the #1 cause of reported performance issues, so top of our list to work on. The goal is to make it easier to track down the source of these kinds of problems.

I still think that time averages and computations sounds like a difficult and indirect way of measuring contention... but see how it works.

Dave

It is, but what else do we have? There is no way to communicate between GFS2 nodes except via the DLM. Contention is really a state of all the nodes collectively, rather than any one node, which makes it tricky to measure. We could try something using the LVBs, but that is rather tricky if the nodes are using (largely) read locks and thus we can't write to the LVB from those nodes.

For a long time we've had the "min hold time" concept which was introduced to ensure that we continue to make progress, even when contention occurs. That has been based off a rather rough time since last state change estimate, with an adjustment for a corner case which was discovered recently. I'd like to put that calculation on a more scientific footing, and this seems to be the easiest way to do that.

I've had a look at what OCFS2 collects wrt locking stats. They have a cumulative total of wait time and a counter for the number of waits which have occurred. That will give a good collective estimate of time spent waiting, but it is not suitable for changing the dynamic behaviour of the filesystem as the time it takes to react to a change in the system characteristics will vary with time. In other words when just mounted, the statistic will be very sensitive to new data, but it will become less so as time goes on.

The exponential averages which I'm proposing in the patch are designed so that once they have gained enough information (say 12 samples or so) to reach a steady state, they will change in response to new data in the same way, however many lock requests have been made.

This is also why such things are used in the networking code. We don't want the response to change according to how much data has passed over the socket.

In addition, the patch also keeps track of the variance, so that we know how accurate the mean is. Something that is vitally important to avoid drawing incorrect conclusions from the data.

What I am concerned about is whether we could measure other quantities which would give us a better proxy for whats happening in the cluster as a whole, and at what point we start running the risk of the stats slowing things down more than the information they return will speed things up.

As a general rule, I don't want to collect stats just for the sake of it. We can use tracepoints to collect data for performance analysis later, the aim here is to collect data to directly influence the future operation of the filesystem in an automatic manner, and to be able to monitor that so we can check that it is really functioning correctly.

I've tried to ensure they are collected in the most efficient way possible (no divisions or multiplications, aside from bit shifts). All global stats in per-cpu structures.

Also, another difference from OCFS2, is that this patch will collect global stats, so we have a good starting point to initialise the per-glock stats from. Newly-created glocks should thus start with a good estimate as to their correct stats values, once the fs has been mounted for a little while,

Steve.