[PATCH] Add thinktime_blocks
authorJens Axboe <jens.axboe@oracle.com>
Wed, 3 Jan 2007 19:43:19 +0000 (20:43 +0100)
committerJens Axboe <jens.axboe@oracle.com>
Wed, 3 Jan 2007 19:43:19 +0000 (20:43 +0100)
Right now 'thinktime' waits after every IO. This may not be what you
need, sometimes you want to wait only after 'x' number of ios. This
options allows you to set the number of ios to complete, before waiting.

Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
HOWTO
fio.c
fio.h
init.c

diff --git a/HOWTO b/HOWTO
index 1918201..c9d29f2 100644 (file)
--- a/HOWTO
+++ b/HOWTO
@@ -319,7 +319,13 @@ prioclass=int      Set the io priority class. See man ionice(1).
 
 thinktime=int  Stall the job x microseconds after an io has completed before
                issuing the next. May be used to simulate processing being
-               done by an application.
+               done by an application. See thinktime_blocks.
+
+thinktime_blocks
+               Only valid if thinktime is set - control how many blocks
+               to issue, before waiting 'thinktime' usecs. If not set,
+               defaults to 1 which will make fio wait 'thinktime' usecs
+               after every block.
 
 rate=int       Cap the bandwidth used by this job to this number of KiB/sec.
 
diff --git a/fio.c b/fio.c
index f046b0c..e8181a1 100644 (file)
--- a/fio.c
+++ b/fio.c
@@ -447,8 +447,13 @@ static void do_io(struct thread_data *td)
                if (runtime_exceeded(td, &icd.time))
                        break;
 
-               if (td->thinktime)
-                       usec_sleep(td, td->thinktime);
+               if (td->thinktime) {
+                       unsigned long long b;
+
+                       b = td->io_blocks[0] + td->io_blocks[1];
+                       if (!(td->thinktime_blocks % b))
+                               usec_sleep(td, td->thinktime);
+               }
        }
 
        if (!td->error) {
diff --git a/fio.h b/fio.h
index 4bb1f6c..2f41eda 100644 (file)
--- a/fio.h
+++ b/fio.h
@@ -217,6 +217,7 @@ struct thread_data {
        unsigned int hugepage_size;
        unsigned int rw_min_bs;
        unsigned int thinktime;
+       unsigned int thinktime_blocks;
        unsigned int fsync_blocks;
        unsigned int start_delay;
        unsigned long timeout;
diff --git a/init.c b/init.c
index c450a4c..2075c0f 100644 (file)
--- a/init.c
+++ b/init.c
@@ -53,6 +53,7 @@
 #define DEF_WRITE_LAT_LOG      (0)
 #define DEF_NO_RAND_MAP                (0)
 #define DEF_HUGEPAGE_SIZE      FIO_HUGE_PAGE
+#define DEF_THINKTIME_BLOCKS   (1)
 
 #define td_var_offset(var)     ((size_t) &((struct thread_data *)0)->var)
 
@@ -227,6 +228,11 @@ static struct fio_option options[] = {
                .type   = FIO_OPT_INT,
                .off1   = td_var_offset(thinktime)
        },
+       {
+               .name   = "thinktime_blocks",
+               .type   = FIO_OPT_INT,
+               .off1   = td_var_offset(thinktime_blocks)
+       },
        {
                .name   = "rate",
                .type   = FIO_OPT_INT,
@@ -1080,6 +1086,7 @@ static int fill_def_thread(void)
        def_thread.write_lat_log = write_lat_log;
        def_thread.norandommap = DEF_NO_RAND_MAP;
        def_thread.hugepage_size = DEF_HUGEPAGE_SIZE;
+       def_thread.thinktime_blocks = DEF_THINKTIME_BLOCKS;
 #ifdef FIO_HAVE_DISK_UTIL
        def_thread.do_disk_util = 1;
 #endif