From: Jens Axboe Date: Wed, 3 Jan 2007 19:43:19 +0000 (+0100) Subject: [PATCH] Add thinktime_blocks X-Git-Tag: fio-1.11~8 X-Git-Url: https://git.kernel.dk/?p=fio.git;a=commitdiff_plain;h=9c1f7434526606fc8a4296190a2dea5de2651266 [PATCH] Add thinktime_blocks 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 --- diff --git a/HOWTO b/HOWTO index 19182019..c9d29f29 100644 --- 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 f046b0cd..e8181a1c 100644 --- 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 4bb1f6c6..2f41eda2 100644 --- 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 c450a4c1..2075c0ff 100644 --- 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