--- /dev/null
+Quick guide to installing/running dbench & co:
+
+1) Run 'make' in the source directory
+
+2) cd into the directory in which you wish to run the benchmark
+
+3) either copy client.txt into that directory, or specify it's path
+with -c
+
+4) run the appropriate benchmark program
+
client.txt and use it to produce the same load without having to buy a
huge lab. They can simulate any number of simultaneous clients.
+client.txt must either be in the working directory, or specified on
+the command line with the -c option.
+
dbench
------
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
+/* This file links against either fileio.c to do operations against a
+ local filesystem (making dbench), or sockio.c to issue SMB-like
+ command packets over a socket (making tbench).
+
+ So, the pattern of operations and the control structure is the same
+ for both benchmarks, but the operations performed are different.
+*/
+
#include "dbench.h"
int line_count=0;
+char *client_filename = "client.txt";
+
+
static int sigsegv(int sig)
{
char line[200];
exit(1);
}
+
+FILE * open_client_dump(void)
+{
+ FILE *f;
+
+ if ((f = fopen(client_filename, "rt")) != NULL)
+ return f;
+
+ fprintf(stderr,
+ "dbench: error opening %s: %s", client_filename,
+ strerror(errno));
+
+ return NULL;
+}
+
void child_run(int client)
{
int i;
sprintf(cname,"CLIENT%d", client);
- f = fopen("client.txt", "r");
+ f = open_client_dump();
if (!f) {
perror("client.txt");
/*
- dbench version 1
- Copyright (C) Andrew Tridgell 1999
+ dbench version 1.01
+
+ Copyright (C) by Andrew Tridgell <tridge@samba.org> 1999, 2001
+ Copyright (C) 2001 by Martin Pool <mbp@samba.org>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
+/* TODO: We could try allowing for different flavours of synchronous
+ operation: data sync and so on. Linux apparently doesn't make any
+ distinction, however, and for practical purposes it probably
+ doesn't matter. On NFSv4 it might be interesting, since the client
+ can choose what kind it wants for each OPEN operation. */
+
#include "dbench.h"
+int sync_ops = 0;
+
static void sigcont(void)
{
}
-/* this creates the specified number of child processes and runs fn() in all of them */
+/* this creates the specified number of child processes and runs fn()
+ in all of them */
static double create_procs(int nprocs, void (*fn)(int ))
{
int i, status;
synccount = 0;
+ if (nprocs < 1) {
+ fprintf(stderr,
+ "create %d procs? you must be kidding.\n",
+ nprocs);
+ return 1;
+ }
+
child_status = (volatile int *)shm_setup(sizeof(int)*nprocs);
if (!child_status) {
printf("Failed to setup shared memory\n");
}
+static void show_usage(void)
+{
+ printf("usage: dbench [OPTIONS] nprocs\n"
+ "options:\n"
+ " -c CLIENT.TXT set location of client.txt\n"
+ " -s synchronous mode (like NFS2)\n");
+ exit(1);
+}
+
- int main(int argc, char *argv[])
+int process_opts(int argc, char **argv,
+ int *nprocs)
{
+ int c;
+ extern char *client_filename;
+ extern int sync_ops;
extern char *server;
- int nprocs;
- double t;
- if (argc < 2) {
- printf("usage: dbench nprocs\n");
- exit(1);
- }
+ while ((c = getopt(argc, argv, "c:s")) != -1)
+ switch (c) {
+ case 'c':
+ client_filename = optarg;
+ break;
+ case 's':
+ sync_ops = 1;
+ break;
+ case '?':
+ if (isprint (optopt))
+ fprintf (stderr, "Unknown option `-%c'.\n", optopt);
+ else
+ fprintf (stderr,
+ "Unknown option character `\\x%x'.\n",
+ optopt);
+ return 0;
+ default:
+ abort ();
+ }
+
+ if (!argv[optind])
+ return 0;
+
+ *nprocs = atoi(argv[optind++]);
- nprocs = atoi(argv[1]);
+ if (argv[optind])
+ server = argv[optind++];
- if (argc > 2) {
- server = argv[2];
- }
+ return 1;
+}
+
+
+
+ int main(int argc, char *argv[])
+{
+ int nprocs;
+ double t;
+
+ if (!process_opts(argc, argv, &nprocs))
+ show_usage();
t = create_procs(nprocs, child_run);
sniff that was used to produce client.txt. That run used 2
clients and ran for 660 seconds to produce a result of
4MBit/sec. */
- printf("Throughput %g MB/sec (NB=%g MB/sec %g MBit/sec)\n",
- 132*nprocs/t, 0.5*0.5*nprocs*660/t, 2*nprocs*660/t);
+ printf("Throughput %g MB/sec (NB=%g MB/sec %g MBit/sec)%s\n",
+ 132*nprocs/t, 0.5*0.5*nprocs*660/t, 2*nprocs*660/t,
+ sync_ops ? " (sync mode)" : "");
return 0;
}
extern int line_count;
char *server = NULL;
+extern int sync_ops;
static struct {
int fd;
if (size == 0) flags |= O_TRUNC;
+ if (sync_ops)
+ flags |= O_SYNC;
+
fd = open(fname, flags, 0600);
if (fd == -1) {
printf("(%d) open %s failed for handle %d (%s)\n",
+/*
+ dbench version 1.01
+
+ Copyright (C) by Andrew Tridgell <tridge@samba.org> 1999, 2001
+ Copyright (C) 2001 by Martin Pool <mbp@samba.org>
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+*/
+
+/* Wrappers for system calls that catch errors. */
+
#include "dbench.h"
#define MAX_FILES 1000
/* This file is automatically generated with "make proto". DO NOT EDIT */
void child_run(int client);
+int process_opts(int argc, char **argv,
+ int *nprocs);
void nb_setup(int client);
void nb_unlink(char *fname);
void expand_file(int fd, int size);
void nb_rename(char *old, char *new);
void nb_stat(char *fname, int size);
void nb_create(char *fname, int size);
+void do_unlink(char *fname);
+void expand_file(int fd, int size);
+void do_open(char *fname, int handle, int size);
+void do_write(int handle, int size, int offset);
+void do_read(int handle, int size, int offset);
+void do_close(int handle);
+void do_mkdir(char *fname);
+void do_rmdir(char *fname);
+void do_rename(char *old, char *new);
+void do_stat(char *fname, int size);
+void do_create(char *fname, int size);
void nb_setup(int client);
void nb_unlink(char *fname);
void nb_open(char *fname, int handle, int size);
void set_socket_options(int fd, char *options);
int read_sock(int s, char *buf, int size);
int write_sock(int s, char *buf, int size);
+int main(int argc, char *argv[]);
void start_timer(void);
double end_timer(void);
void *shm_setup(int size);
shmid = shmget(IPC_PRIVATE, size, SHM_R | SHM_W);
if (shmid == -1) {
- printf("can't get shared memory\n");
+ printf("can't get private shared memory of %d bytes: %s\n",
+ size,
+ strerror(errno));
exit(1);
}
ret = (void *)shmat(shmid, 0, 0);