fstests.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/4] dbench: few enhancements from mmtests
@ 2022-02-09 22:18 Luis Chamberlain
  2022-02-09 22:18 ` [PATCH 1/4] Allow reporting of workload execution times Luis Chamberlain
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: Luis Chamberlain @ 2022-02-09 22:18 UTC (permalink / raw)
  To: raymond.barbiero.dev; +Cc: fstests, jack, mgorman, dave, 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.

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(-)

-- 
2.34.1


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH 1/4] Allow reporting of workload execution times
  2022-02-09 22:18 [PATCH 0/4] dbench: few enhancements from mmtests Luis Chamberlain
@ 2022-02-09 22:18 ` Luis Chamberlain
  2022-02-09 22:18 ` [PATCH 2/4] Defer reporting of " Luis Chamberlain
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: Luis Chamberlain @ 2022-02-09 22:18 UTC (permalink / raw)
  To: raymond.barbiero.dev; +Cc: fstests, jack, mgorman, dave, Luis Chamberlain

From: Jan Kara <jack@suse.cz>

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.

Signed-off-by: Jan Kara <jack@suse.cz>
Signed-off-by: Luis Chamberlain <mcgrof@kernel.org>
---
 child.c  | 18 ++++++++++++++++++
 dbench.c |  3 +++
 dbench.h |  1 +
 3 files changed, 22 insertions(+)

diff --git a/child.c b/child.c
index aea8106..e4ae230 100644
--- a/child.c
+++ b/child.c
@@ -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;
 	}
diff --git a/dbench.c b/dbench.c
index 1369a38..178a175 100644
--- a/dbench.c
+++ b/dbench.c
@@ -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 },
diff --git a/dbench.h b/dbench.h
index 14a5a70..465cf3b 100644
--- a/dbench.h
+++ b/dbench.h
@@ -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;
 };
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH 2/4] Defer reporting of execution times
  2022-02-09 22:18 [PATCH 0/4] dbench: few enhancements from mmtests Luis Chamberlain
  2022-02-09 22:18 ` [PATCH 1/4] Allow reporting of workload execution times Luis Chamberlain
@ 2022-02-09 22:18 ` Luis Chamberlain
  2022-02-09 22:18 ` [PATCH 3/4] libnfs: Include stdint.h Luis Chamberlain
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: Luis Chamberlain @ 2022-02-09 22:18 UTC (permalink / raw)
  To: raymond.barbiero.dev; +Cc: fstests, jack, mgorman, dave, Luis Chamberlain

From: Mel Gorman <mgorman@techsingularity.net>

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.

Signed-off-by: Mel Gorman <mgorman@techsingularity.net>
Signed-off-by: Luis Chamberlain <mcgrof@kernel.org>
---
 child.c | 38 ++++++++++++++++++++++++++++++++++----
 1 file changed, 34 insertions(+), 4 deletions(-)

diff --git a/child.c b/child.c
index e4ae230..828295d 100644
--- a/child.c
+++ b/child.c
@@ -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);
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH 3/4] libnfs: Include stdint.h
  2022-02-09 22:18 [PATCH 0/4] dbench: few enhancements from mmtests Luis Chamberlain
  2022-02-09 22:18 ` [PATCH 1/4] Allow reporting of workload execution times Luis Chamberlain
  2022-02-09 22:18 ` [PATCH 2/4] Defer reporting of " Luis Chamberlain
@ 2022-02-09 22:18 ` Luis Chamberlain
  2022-02-09 22:18 ` [PATCH 4/4] Check if parent is alive once per loadfile processed Luis Chamberlain
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: Luis Chamberlain @ 2022-02-09 22:18 UTC (permalink / raw)
  To: raymond.barbiero.dev; +Cc: fstests, jack, mgorman, dave, Luis Chamberlain

From: Mel Gorman <mgorman@techsingularity.net>

Changes in kernel headers break build unless this is included.

Signed-off-by: Mel Gorman <mgorman@techsingularity.net>
Signed-off-by: Luis Chamberlain <mcgrof@kernel.org>
---
 libnfs.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/libnfs.c b/libnfs.c
index edbcd61..e853e47 100644
--- a/libnfs.c
+++ b/libnfs.c
@@ -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>
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH 4/4] Check if parent is alive once per loadfile processed
  2022-02-09 22:18 [PATCH 0/4] dbench: few enhancements from mmtests Luis Chamberlain
                   ` (2 preceding siblings ...)
  2022-02-09 22:18 ` [PATCH 3/4] libnfs: Include stdint.h Luis Chamberlain
@ 2022-02-09 22:18 ` Luis Chamberlain
  2022-02-10  9:44 ` [PATCH 0/4] dbench: few enhancements from mmtests Jan Kara
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: Luis Chamberlain @ 2022-02-09 22:18 UTC (permalink / raw)
  To: raymond.barbiero.dev; +Cc: fstests, jack, mgorman, dave, Luis Chamberlain

From: Mel Gorman <mgorman@techsingularity.net>

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.

Signed-off-by: Mel Gorman <mgorman@techsingularity.net>
Signed-off-by: Luis Chamberlain <mcgrof@kernel.org>
---
 child.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/child.c b/child.c
index 828295d..7abb238 100644
--- a/child.c
+++ b/child.c
@@ -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
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH 0/4] dbench: few enhancements from mmtests
  2022-02-09 22:18 [PATCH 0/4] dbench: few enhancements from mmtests Luis Chamberlain
                   ` (3 preceding siblings ...)
  2022-02-09 22:18 ` [PATCH 4/4] Check if parent is alive once per loadfile processed Luis Chamberlain
@ 2022-02-10  9:44 ` Jan Kara
  2022-02-10 10:16 ` Mel Gorman
  2022-02-10 13:04 ` Davidlohr Bueso
  6 siblings, 0 replies; 8+ messages in thread
From: Jan Kara @ 2022-02-10  9:44 UTC (permalink / raw)
  To: Luis Chamberlain; +Cc: raymond.barbiero.dev, fstests, jack, mgorman, dave

On Wed 09-02-22 14:18:45, Luis Chamberlain wrote:
> 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.

Cool that someone started maintaining dbench ;). Thanks!

								Honza
-- 
Jan Kara <jack@suse.com>
SUSE Labs, CR

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 0/4] dbench: few enhancements from mmtests
  2022-02-09 22:18 [PATCH 0/4] dbench: few enhancements from mmtests Luis Chamberlain
                   ` (4 preceding siblings ...)
  2022-02-10  9:44 ` [PATCH 0/4] dbench: few enhancements from mmtests Jan Kara
@ 2022-02-10 10:16 ` Mel Gorman
  2022-02-10 13:04 ` Davidlohr Bueso
  6 siblings, 0 replies; 8+ messages in thread
From: Mel Gorman @ 2022-02-10 10:16 UTC (permalink / raw)
  To: Luis Chamberlain; +Cc: raymond.barbiero.dev, fstests, jack, dave

On Wed, Feb 09, 2022 at 02:18:45PM -0800, Luis Chamberlain wrote:
> 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 :)
> 

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

-- 
Mel Gorman
SUSE Labs

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 0/4] dbench: few enhancements from mmtests
  2022-02-09 22:18 [PATCH 0/4] dbench: few enhancements from mmtests Luis Chamberlain
                   ` (5 preceding siblings ...)
  2022-02-10 10:16 ` Mel Gorman
@ 2022-02-10 13:04 ` Davidlohr Bueso
  6 siblings, 0 replies; 8+ messages in thread
From: Davidlohr Bueso @ 2022-02-10 13:04 UTC (permalink / raw)
  To: Luis Chamberlain; +Cc: raymond.barbiero.dev, fstests, jack, mgorman

On Wed, 09 Feb 2022, Luis Chamberlain wrote:
>[0] https://github.com/gormanm/mmtests.git
>[1] https://github.com/mcgrof/dbench.git

Just so that I'm clear, you forked dbench from sahlberg's repo, right?
(git://git.samba.org/sahlberg/dbench.git) That's the one we've been
using for mmtests but I'm not sure if there is also older repos
around like from tridge.

Thanks,
Davidlohr

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2022-02-10 13:12 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-02-09 22:18 [PATCH 0/4] dbench: few enhancements from mmtests Luis Chamberlain
2022-02-09 22:18 ` [PATCH 1/4] Allow reporting of workload execution times Luis Chamberlain
2022-02-09 22:18 ` [PATCH 2/4] Defer reporting of " Luis Chamberlain
2022-02-09 22:18 ` [PATCH 3/4] libnfs: Include stdint.h Luis Chamberlain
2022-02-09 22:18 ` [PATCH 4/4] Check if parent is alive once per loadfile processed Luis Chamberlain
2022-02-10  9:44 ` [PATCH 0/4] dbench: few enhancements from mmtests Jan Kara
2022-02-10 10:16 ` Mel Gorman
2022-02-10 13:04 ` Davidlohr Bueso

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).