[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 19182019f7020389e6e5e48391e8f2b6f58b5871..c9d29f299bd4109fcbcf3c504925986d28979c18 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 f046b0cd61e88d0571cedd63f03c681f16024083..e8181a1c317f6a8a7a595100f9beed12126e9e5f 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 4bb1f6c6d275a639e180ed3fcf53b2de32e1c4a5..2f41eda23742b0499c10441ac93c2082b8a5bb3c 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 c450a4c117001e0a3189e240df31d100001bf09f..2075c0ffbc83b7a25efd9419ec569dd3935a3c62 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