Skip to contentSkip to conversation

dbench: few enhancements from mmtests

PATCH In review Luis Chamberlain 4 participants 8 messages Feb 9, 2022 – Feb 10, 2022

lore
Share & tools
lore
#0 lore raw

cover dbench: few enhancements from mmtests

mmtests [0] also uses dbench, and they actually carry 4 patch delta for years. These patches are useful and should not interfere with existing uses, so just merge these.

As noted before, I've put all this and a few of my own fixes into my own git tree [1] and I'll be extending dbench there as well as I see its not up to date and even debian has dropped packaging it as it doesn't compile anymore. The one on my tree compiles more than fine now. I'll send a few other fixes after this set.

Mel, feel free to drop those patches if you want to use my tree :)

For lack of a mailing list for dbench, I'm freeloading off of fstests as it uses dbench as well.

[0] https://github.com/gormanm/mmtests.git
[1] https://github.com/mcgrof/dbench.git

Jan Kara (1):
Allow reporting of workload execution times

Mel Gorman (3):
Defer reporting of execution times
libnfs: Include stdint.h
Check if parent is alive once per loadfile processed

 child.c  | 56 ++++++++++++++++++++++++++++++++++++++++++++++++++++----
 dbench.c |  3 +++
 dbench.h |  1 +
 libnfs.c |  1 +
 4 files changed, 57 insertions(+), 4 deletions(-)
Signature · 1 line
2.34.1
#1 lore raw

PATCH 1/4 Allow reporting of workload execution times

From: Jan Kara <[email protected]>

Add option --show-execution-time which reports time it took to each client to execute the given workload. This allows for better statistics to be done with dbench results.

---
 child.c  | 18 ++++++++++++++++++
 dbench.c |  3 +++
 dbench.h |  1 +
 3 files changed, 22 insertions(+)
child.c +18 -0
index aea8106..e4ae230 100644
@@ -326,6 +326,7 @@ void child_run(struct child_struct *child0, const char *loadfile)
 	int have_random = 0;
 	unsigned loop_count = 0;
 	z_off_t loop_start = 0;
+	struct timeval start;
 
 	gzf = gzopen(loadfile, "r");
 	if (gzf == NULL) {
@@ -349,6 +350,8 @@ again:
 		nb_time_reset(child);
 	}
 
+	gettimeofday(&start, NULL);
+
 	while (gzgets(gzf, line, sizeof(line)-1)) {
 		unsigned repeat_count = 1;
 
@@ -529,6 +532,21 @@ loop_again:
 		}
 	}
 
+	if (options.show_execute_time) {
+		struct timeval end;
+		unsigned int duration;
+
+		gettimeofday(&end, NULL);
+		duration = (end.tv_sec - start.tv_sec) * 1000 +
+			   (end.tv_usec - start.tv_usec) / 1000;
+		if (options.machine_readable)
+			printf("@E@%d@%u\n", child0->id, duration);
+		else {
+			printf("%4d completed in %u ms\n", child0->id,
+			       duration);
+		}
+	}
+
 	if (options.run_once) {
 		goto done;
 	}
dbench.c +3 -0
index 1369a38..178a175 100644
@@ -50,6 +50,7 @@ struct options options = {
 	.trunc_io            = 0,
 	.iscsi_initiatorname = "iqn.2011-09.org.samba.dbench:client",
 	.machine_readable    = 0,
+	.show_execute_time   = 0,
 };
 
 static struct timeval tv_start;
@@ -433,6 +434,8 @@ static void process_opts(int argc, const char **argv)
 		  "How many seconds of warmup to run", NULL },
 		{ "machine-readable", 0, POPT_ARG_NONE, &options.machine_readable, 0,
 		  "Print data in more machine-readable friendly format", NULL},
+		{ "show-execute-time", 0, POPT_ARG_NONE, &options.show_execute_time, 0,
+		  "Print time to execute passed workload", NULL},
 #ifdef HAVE_LIBSMBCLIENT
 		{ "smb-share",  0, POPT_ARG_STRING, &options.smb_share, 0, 
 		  "//SERVER/SHARE to use", NULL },
dbench.h +1 -0
index 14a5a70..465cf3b 100644
@@ -159,6 +159,7 @@ struct options {
 	const char *iscsi_device;
 	const char *iscsi_initiatorname;
 	int machine_readable;
+	int show_execute_time;
 	const char *smb_share;
 	const char *smb_user;
 };
Signature · 1 line
2.34.1
#2 lore raw

PATCH 2/4 Defer reporting of execution times

In reply to Luis Chamberlain

From: Mel Gorman <[email protected]>

If loadfiles are completed rapidly, there is a large amount of data sent to stddout and then recorded which generates IO in itself. This patch buffers durations and runtimes for a time. In some cases, it'll be buffered until the end of the benchmark.

---
 child.c | 38 ++++++++++++++++++++++++++++++++++----
 1 file changed, 34 insertions(+), 4 deletions(-)
child.c +34 -4
index e4ae230..828295d 100644
@@ -309,9 +309,19 @@ finished:
 	return 0;
 }
 
+void dump_samples(int id, unsigned int *duration, unsigned int *runtime, unsigned int nr_samples)
+{
+	unsigned int i;
+
+	for (i = 0; i < nr_samples; i++) {
+		printf("%4d completed in %u ms at time %u ms\n", id,
+		       duration[i], runtime[i]);
+	}
+}
 
 /* run a test that simulates an approximate netbench client load */
 #define MAX_PARM_LEN 1024
+#define MAX_SAMPLES 130672
 void child_run(struct child_struct *child0, const char *loadfile)
 {
 	int i;
@@ -326,7 +336,16 @@ void child_run(struct child_struct *child0, const char *loadfile)
 	int have_random = 0;
 	unsigned loop_count = 0;
 	z_off_t loop_start = 0;
-	struct timeval start;
+	struct timeval start, begin;
+	unsigned nr_samples = 0;
+
+	unsigned int *sample_duration = malloc(sizeof(unsigned int) * (MAX_SAMPLES + 1));
+	unsigned int *sample_runtime  = malloc(sizeof(unsigned int) * (MAX_SAMPLES + 1));
+
+	if (!sample_duration || !sample_runtime) {
+		printf("ENOMEM for samples\n");
+		exit(1);
+	}
 
 	gzf = gzopen(loadfile, "r");
 	if (gzf == NULL) {
@@ -345,6 +364,8 @@ void child_run(struct child_struct *child0, const char *loadfile)
 		memset(sparams[i], 0, MAX_PARM_LEN);
 	}
 
+	gettimeofday(&begin, NULL);
+
 again:
 	for (child=child0;child<child0+options.clients_per_process;child++) {
 		nb_time_reset(child);
@@ -534,16 +555,23 @@ loop_again:
 
 	if (options.show_execute_time) {
 		struct timeval end;
-		unsigned int duration;
+		unsigned int duration, runtime;
 
 		gettimeofday(&end, NULL);
 		duration = (end.tv_sec - start.tv_sec) * 1000 +
 			   (end.tv_usec - start.tv_usec) / 1000;
+		runtime = (end.tv_sec - begin.tv_sec) * 1000 +
+			   (end.tv_usec - begin.tv_usec) / 1000;
 		if (options.machine_readable)
 			printf("@E@%d@%u\n", child0->id, duration);
 		else {
-			printf("%4d completed in %u ms\n", child0->id,
-			       duration);
+			sample_duration[nr_samples] = duration;
+			sample_runtime[nr_samples] = runtime;
+			nr_samples++;
+			if (nr_samples == MAX_SAMPLES) {
+				dump_samples(child0->id, sample_duration, sample_runtime, nr_samples);
+				nr_samples = 0;
+			}
 		}
 	}
 
@@ -556,6 +584,8 @@ loop_again:
 
 done:
 	gzclose(gzf);
+	usleep(child0->id * 5000);
+	dump_samples(child0->id, sample_duration, sample_runtime, nr_samples);
 	for (child=child0;child<child0+options.clients_per_process;child++) {
 		child->cleanup = 1;
 		fflush(stdout);
Signature · 1 line
2.34.1
#3 lore raw

PATCH 3/4 libnfs: Include stdint.h

In reply to Luis Chamberlain

From: Mel Gorman <[email protected]>

Changes in kernel headers break build unless this is included.

---
 libnfs.c | 1 +
 1 file changed, 1 insertion(+)
libnfs.c +1 -0
index edbcd61..e853e47 100644
@@ -21,6 +21,7 @@
 #include "mount.h"
 #include "nfs.h"
 #include "libnfs.h"
+#include <stdint.h>
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <fcntl.h>
Signature · 1 line
2.34.1
#4 lore raw

PATCH 4/4 Check if parent is alive once per loadfile processed

In reply to Luis Chamberlain

From: Mel Gorman <[email protected]>

strace reports that a high percentage of time is spent calling kill() with 12,000,000 calls in 3 minutes. Check if the parent is alive once per load file processed. With later versions of apparmor, kill() is permission checked which is very expensive in itself and unnecessary. Instead use the ligher getppid() call and check against the cached value.

---
 child.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
child.c +4 -4
index 828295d..7abb238 100644
@@ -371,6 +371,10 @@ again:
 		nb_time_reset(child);
 	}
 
+	if (getppid() != parent) {
+		exit(1);
+	}
+
 	gettimeofday(&start, NULL);
 
 	while (gzgets(gzf, line, sizeof(line)-1)) {
@@ -384,10 +388,6 @@ again:
 
 		params = sparams;
 
-		if (kill(parent, 0) == -1) {
-			exit(1);
-		}
-
 loop_again:
 		/* if this is a "LOOP <xxx>" line, 
 		 * remember the current file position and move to the next line
Signature · 1 line
2.34.1
#5 lore raw
In reply to Luis Chamberlain
Quoted 10 lines · Luis Chamberlain

mmtests [0] also uses dbench, and they actually carry 4 patch delta for years. These patches are useful and should not interfere with existing uses, so just merge these.

As noted before, I've put all this and a few of my own fixes into my own git tree [1] and I'll be extending dbench there as well as I see its not up to date and even debian has dropped packaging it as it doesn't compile anymore. The one on my tree compiles more than fine now. I'll send a few other fixes after this set.

Quoted 4 lines

Mel, feel free to drop those patches if you want to use my tree :)

For lack of a mailing list for dbench, I'm freeloading off of fstests as it uses dbench as well.

Cool that someone started maintaining dbench ;). Thanks!

Honza

Signature · 2 lines
Jan Kara <[email protected]>
SUSE Labs, CR
#6 lore raw
In reply to Luis Chamberlain
Quoted 4 lines · Luis Chamberlain

mmtests [0] also uses dbench, and they actually carry 4 patch delta for years. These patches are useful and should not interfere with existing uses, so just merge these.

Quoted 8 lines

As noted before, I've put all this and a few of my own fixes into my own git tree [1] and I'll be extending dbench there as well as I see its not up to date and even debian has dropped packaging it as it doesn't compile anymore. The one on my tree compiles more than fine now. I'll send a few other fixes after this set.

Mel, feel free to drop those patches if you want to use my tree :)

Thanks Luis, I expect to migrate mmtests to use your tree relatively soon!

Signature · 2 lines
Mel Gorman
SUSE Labs