Add -x accellerator option
authorLuis Useche <luis@cis.fiu.edu>
Mon, 5 May 2008 18:53:13 +0000 (20:53 +0200)
committerJens Axboe <jens.axboe@oracle.com>
Mon, 5 May 2008 18:53:13 +0000 (20:53 +0200)
This patch adds a new functionality to the btreplay tool, the -x option.
This parameter accelerate the replication by the factor specified. This
means that the stall time is divided by the number introduced.

Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
btreplay/btreplay.c
btreplay/doc/btreplay.tex

index 8e6b7dc952a005c4d682c4de42332eb88e4f8d42..23e13b8fc812b389ae8fa5986bbbaedd52ce2e21 100644 (file)
@@ -154,6 +154,7 @@ static LIST_HEAD(input_files);              // List of input files to handle
 static LIST_HEAD(map_devs);            // List of device maps
 static int nfiles = 0;                 // Number of files to handle
 static int no_stalls = 0;              // Boolean: Disable pre-stalls
+static unsigned acc_factor = 1;                // Int: Acceleration factor
 static int find_records = 0;           // Boolean: Find record files auto
 
 /*
@@ -1175,6 +1176,8 @@ static void stall(struct thr_info *tip, long long oclock)
        struct timespec req;
        long long dreal, tclock = gettime() - rgenesis;
 
+       oclock /= acc_factor;
+       
        if (verbose > 1)
                fprintf(tip->vfp, "   stall(%lld.%09lld, %lld.%09lld)\n",
                        du64_to_sec(oclock), du64_to_nsec(oclock),
@@ -1347,22 +1350,23 @@ static void *replay_sub(void *arg)
  */
 
 static char usage_str[] =                                              \
-        "\n"                                                           \
+        "\n"                                                           \
         "\t[ -c <cpus> : --cpus=<cpus>           ] Default: 1\n"        \
         "\t[ -d <dir>  : --input-directory=<dir> ] Default: .\n"        \
-       "\t[ -F        : --find-records          ] Default: Off\n"         \
+       "\t[ -F        : --find-records          ] Default: Off\n"      \
         "\t[ -h        : --help                  ] Default: Off\n"      \
         "\t[ -i <base> : --input-base=<base>     ] Default: replay\n"   \
         "\t[ -I <iters>: --iterations=<iters>    ] Default: 1\n"        \
         "\t[ -M <file> : --map-devs=<file>       ] Default: None\n"     \
         "\t[ -N        : --no-stalls             ] Default: Off\n"      \
+        "\t[ -x        : --acc-factor            ] Default: 1\n"       \
         "\t[ -v        : --verbose               ] Default: Off\n"      \
         "\t[ -V        : --version               ] Default: Off\n"      \
         "\t[ -W        : --write-enable          ] Default: Off\n"      \
         "\t<dev...>                                Default: None\n"     \
         "\n";
 
-#define S_OPTS "c:d:Fhi:I:M:Nt:vVW"
+#define S_OPTS "c:d:Fhi:I:M:Nx:t:vVW"
 static struct option l_opts[] = {
        {
                .name = "cpus",
@@ -1412,6 +1416,12 @@ static struct option l_opts[] = {
                .flag = NULL,
                .val = 'N'
        },
+       {
+               .name = "acc-factor",
+               .has_arg = required_argument,
+               .flag = NULL,
+               .val = 'x'
+       },
        {
                .name = "verbose",
                .has_arg = no_argument,
@@ -1445,6 +1455,7 @@ static struct option l_opts[] = {
 static void handle_args(int argc, char *argv[])
 {
        int c;
+       int r;
 
        while ((c = getopt_long(argc, argv, S_OPTS, l_opts, NULL)) != -1) {
                switch (c) {
@@ -1499,6 +1510,16 @@ static void handle_args(int argc, char *argv[])
                        no_stalls = 1;
                        break;
 
+               case 'x':
+                       r = sscanf(optarg,"%u",&acc_factor);
+                       if (r!=1) {
+                               fprintf(stderr,
+                                       "Invalid acceleration factor\n");
+                               exit(ERR_ARGS);
+                               /*NOTREACHED*/
+                       }
+                       break;
+
                case 'V':
                        fprintf(stderr, "btreplay -- version %s\n", 
                                my_btversion);
index beec7209b81642b6385dd85c4b9a0d3731e0b217..b4027ff3b922228198a0b2e8eb6ad2b24055bb71 100644 (file)
@@ -386,12 +386,13 @@ Usage: btreplay -- version 0.9.3
 
        [ -c <cpus> : --cpus=<cpus>           ] Default: 1
        [ -d <dir>  : --input-directory=<dir> ] Default: .
-       [ -F        : --find-records           ] Default: Off
+       [ -F        : --find-records          ] Default: Off
        [ -h        : --help                  ] Default: Off
        [ -i <base> : --input-base=<base>     ] Default: replay
        [ -I <iters>: --iterations=<iters>    ] Default: 1
        [ -M <file> : --map-devs=<file>       ] Default: None
        [ -N        : --no-stalls             ] Default: Off
+       [ -x <int>  : --acc-factor=<int>      ] Default: 1
        [ -v        : --verbose               ] Default: Off
        [ -V        : --version               ] Default: Off
        [ -W        : --write-enable          ] Default: Off
@@ -496,6 +497,16 @@ Pre-bunch Stalls}
 When specified on the command line, all pre-bunch stall indicators will be
 ignored. IOs will be replayed without inter-bunch delays.
 
+\subsubsection{\label{sec:o-x}\texttt{-x} or \texttt{--acc-factor}\\Accelaration
+Factor}
+
+  While the \texttt{--no-stalls} option allows the traces to be replayed
+  with no waiting time, this option specifies some acceleration factor
+  to be used. If the value of two is used, then the stall time is
+  divided by half resulting in a reduction of the execution time by
+  this factor. Note that if this number is too high, the results will
+  be equivalent of not having stall.
+
 \subsubsection{\label{sec:p-o-v}\texttt{-v} or
 \texttt{--verbose}\\Select Verbose Output}