* [patch 4/9] fio: provide an option for a startdelay range
@ 2014-02-20 13:20 ehrhardt
2014-02-20 17:03 ` Jens Axboe
0 siblings, 1 reply; 3+ messages in thread
From: ehrhardt @ 2014-02-20 13:20 UTC (permalink / raw)
To: fio; +Cc: oberpar, Christian Ehrhardt
*Resend with hopefully non mangled patches*
References: <20140220131958.965092001@linux.vnet.ibm.com>
Content-Disposition: inline; filename=startdelay-range.diff
From: Christian Ehrhardt <ehrhardt@linux.vnet.ibm.com>
This patch allows the specification of start delay as range.
With a range each thread will chose an individual startdelay out of the range.
That solves an issue of startdelay being the same for each numjob clone and
that way spreads all kind of activities e.g. that all clones with mixed r/w
jobs switch r/w at the same time.
Also all kind of other "thundering herd" issues can be softened by some
time spread due to this option.
Signed-off-by: Christian Ehrhardt <ehrhardt@linux.vnet.ibm.com>
---
[diffstat]
fio.1 | 8 ++++++--
fio.h | 5 +++++
init.c | 25 +++++++++++++++++++++++++
options.c | 1 +
4 files changed, 37 insertions(+), 2 deletions(-)
[diff]
--- a/fio.1
+++ b/fio.1
@@ -846,8 +846,12 @@ needed to be specified. For \fBprefer\fR
allowed. For \fBbind\fR and \fBinterleave\fR, \fBnodelist\fR allows
comma delimited list of numbers, A-B ranges, or 'all'.
.TP
-.BI startdelay \fR=\fPint
-Delay start of job for the specified number of seconds.
+.BI startdelay \fR=\fPirange
+Delay start of job for the specified number of seconds. Supports all time
+suffixes to allow specification of hours, minutes, seconds and
+milliseconds - seconds are the default if a unit is ommited.
+Can be given as a range which causes each thread to choose randomly out of the
+range.
.TP
.BI runtime \fR=\fPint
Terminate processing after the specified number of seconds.
--- a/fio.h
+++ b/fio.h
@@ -85,6 +85,7 @@ enum {
FIO_RAND_SEQ_RAND_READ_OFF,
FIO_RAND_SEQ_RAND_WRITE_OFF,
FIO_RAND_SEQ_RAND_TRIM_OFF,
+ FIO_RAND_START_DELAY,
FIO_RAND_NR_OFFS,
};
@@ -164,6 +165,10 @@ struct thread_data {
os_random_state_t trim_state;
struct frand_state __trim_state;
};
+ union {
+ os_random_state_t delay_state;
+ struct frand_state __delay_state;
+ };
struct frand_state buf_state;
--- a/init.c
+++ b/init.c
@@ -412,6 +412,26 @@ static int fixed_block_size(struct threa
o->min_bs[DDIR_READ] == o->min_bs[DDIR_TRIM];
}
+
+static unsigned long long get_rand_start_delay(struct thread_data *td)
+{
+ unsigned long long delayrange;
+ unsigned long r;
+
+ delayrange = td->o.start_delay_high - td->o.start_delay;
+
+ if (td->o.use_os_rand) {
+ r = os_random_long(&td->delay_state);
+ delayrange = (unsigned long long) ((double) delayrange * (r / (OS_RAND_MAX + 1.0)));
+ } else {
+ r = __rand(&td->__delay_state);
+ delayrange = (unsigned long long) ((double) delayrange * (r / (FRAND_MAX + 1.0)));
+ }
+
+ delayrange += td->o.start_delay;
+ return delayrange;
+}
+
/*
* Lazy way of fixing up options that depend on each other. We could also
* define option callback handlers, but this is easier.
@@ -496,6 +516,9 @@ static int fixup_options(struct thread_d
if (!o->file_size_high)
o->file_size_high = o->file_size_low;
+ if (o->start_delay_high)
+ o->start_delay = get_rand_start_delay(td);
+
if (o->norandommap && o->verify != VERIFY_NONE
&& !fixed_block_size(o)) {
log_err("fio: norandommap given for variable block sizes, "
@@ -711,6 +734,7 @@ static void td_fill_rand_seeds_os(struct
os_random_seed(td->rand_seeds[FIO_RAND_FILE_SIZE_OFF], &td->file_size_state);
os_random_seed(td->rand_seeds[FIO_RAND_TRIM_OFF], &td->trim_state);
+ os_random_seed(td->rand_seeds[FIO_RAND_START_DELAY], &td->delay_state);
if (!td_random(td))
return;
@@ -736,6 +760,7 @@ static void td_fill_rand_seeds_internal(
init_rand_seed(&td->__file_size_state, td->rand_seeds[FIO_RAND_FILE_SIZE_OFF]);
init_rand_seed(&td->__trim_state, td->rand_seeds[FIO_RAND_TRIM_OFF]);
+ init_rand_seed(&td->__delay_state, td->rand_seeds[FIO_RAND_START_DELAY]);
if (!td_random(td))
return;
--- a/options.c
+++ b/options.c
@@ -2018,6 +2018,7 @@ struct fio_option fio_options[FIO_MAX_OP
.lname = "Start delay",
.type = FIO_OPT_STR_VAL_TIME,
.off1 = td_var_offset(start_delay),
+ .off2 = td_var_offset(start_delay_high),
.help = "Only start job when this period has passed",
.def = "0",
.category = FIO_OPT_C_GENERAL,
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [patch 4/9] fio: provide an option for a startdelay range
2014-02-20 13:20 [patch 4/9] fio: provide an option for a startdelay range ehrhardt
@ 2014-02-20 17:03 ` Jens Axboe
0 siblings, 0 replies; 3+ messages in thread
From: Jens Axboe @ 2014-02-20 17:03 UTC (permalink / raw)
To: ehrhardt; +Cc: fio, oberpar
On Thu, Feb 20 2014, ehrhardt@linux.vnet.ibm.com wrote:
> *Resend with hopefully non mangled patches*
> References: <20140220131958.965092001@linux.vnet.ibm.com>
> Content-Disposition: inline; filename=startdelay-range.diff
>
> From: Christian Ehrhardt <ehrhardt@linux.vnet.ibm.com>
>
> This patch allows the specification of start delay as range.
> With a range each thread will chose an individual startdelay out of the range.
>
> That solves an issue of startdelay being the same for each numjob clone and
> that way spreads all kind of activities e.g. that all clones with mixed r/w
> jobs switch r/w at the same time.
> Also all kind of other "thundering herd" issues can be softened by some
> time spread due to this option.
>
> Signed-off-by: Christian Ehrhardt <ehrhardt@linux.vnet.ibm.com>
You forgot the options part for thread_options.h.
--
Jens Axboe
^ permalink raw reply [flat|nested] 3+ messages in thread
[parent not found: <20140219143639.168501090@linux.vnet.ibm.com>]
* [patch 4/9] fio: provide an option for a startdelay range
[not found] <20140219143639.168501090@linux.vnet.ibm.com>
@ 2014-02-19 15:12 ` Christian Ehrhardt
0 siblings, 0 replies; 3+ messages in thread
From: Christian Ehrhardt @ 2014-02-19 15:12 UTC (permalink / raw)
To: fio; +Cc: oberpar, Christian Ehrhardt
From: Christian Ehrhardt <ehrhardt@linux.vnet.ibm.com>
This patch allows the specification of start delay as range.
With a range each thread will chose an individual startdelay out of the
range.
That solves an issue of startdelay being the same for each numjob clone and
that way spreads all kind of activities e.g. that all clones with mixed r/w
jobs switch r/w at the same time.
Also all kind of other "thundering herd" issues can be softened by some
time spread due to this option.
Signed-off-by: Christian Ehrhardt <ehrhardt@linux.vnet.ibm.com>
---
[diffstat]
fio.1 | 8 ++++++--
fio.h | 5 +++++
init.c | 25 +++++++++++++++++++++++++
options.c | 1 +
4 files changed, 37 insertions(+), 2 deletions(-)
[diff]
--- a/fio.1
+++ b/fio.1
@@ -846,8 +846,12 @@ needed to be specified. For \fBprefer\fR
allowed. For \fBbind\fR and \fBinterleave\fR, \fBnodelist\fR allows
comma delimited list of numbers, A-B ranges, or 'all'.
.TP
-.BI startdelay \fR=\fPint
-Delay start of job for the specified number of seconds.
+.BI startdelay \fR=\fPirange
+Delay start of job for the specified number of seconds. Supports all time
+suffixes to allow specification of hours, minutes, seconds and
+milliseconds - seconds are the default if a unit is ommited.
+Can be given as a range which causes each thread to choose randomly out
of the
+range.
.TP
.BI runtime \fR=\fPint
Terminate processing after the specified number of seconds.
--- a/fio.h
+++ b/fio.h
@@ -85,6 +85,7 @@ enum {
FIO_RAND_SEQ_RAND_READ_OFF,
FIO_RAND_SEQ_RAND_WRITE_OFF,
FIO_RAND_SEQ_RAND_TRIM_OFF,
+ FIO_RAND_START_DELAY,
FIO_RAND_NR_OFFS,
};
@@ -164,6 +165,10 @@ struct thread_data {
os_random_state_t trim_state;
struct frand_state __trim_state;
};
+ union {
+ os_random_state_t delay_state;
+ struct frand_state __delay_state;
+ };
struct frand_state buf_state;
--- a/init.c
+++ b/init.c
@@ -412,6 +412,26 @@ static int fixed_block_size(struct threa
o->min_bs[DDIR_READ] == o->min_bs[DDIR_TRIM];
}
+
+static unsigned long long get_rand_start_delay(struct thread_data *td)
+{
+ unsigned long long delayrange;
+ unsigned long r;
+
+ delayrange = td->o.start_delay_high - td->o.start_delay;
+
+ if (td->o.use_os_rand) {
+ r = os_random_long(&td->delay_state);
+ delayrange = (unsigned long long) ((double) delayrange * (r /
(OS_RAND_MAX + 1.0)));
+ } else {
+ r = __rand(&td->__delay_state);
+ delayrange = (unsigned long long) ((double) delayrange * (r /
(FRAND_MAX + 1.0)));
+ }
+
+ delayrange += td->o.start_delay;
+ return delayrange;
+}
+
/*
* Lazy way of fixing up options that depend on each other. We could also
* define option callback handlers, but this is easier.
@@ -496,6 +516,9 @@ static int fixup_options(struct thread_d
if (!o->file_size_high)
o->file_size_high = o->file_size_low;
+ if (o->start_delay_high)
+ o->start_delay = get_rand_start_delay(td);
+
if (o->norandommap && o->verify != VERIFY_NONE
&& !fixed_block_size(o)) {
log_err("fio: norandommap given for variable block sizes, "
@@ -711,6 +734,7 @@ static void td_fill_rand_seeds_os(struct
os_random_seed(td->rand_seeds[FIO_RAND_FILE_SIZE_OFF],
&td->file_size_state);
os_random_seed(td->rand_seeds[FIO_RAND_TRIM_OFF], &td->trim_state);
+ os_random_seed(td->rand_seeds[FIO_RAND_START_DELAY], &td->delay_state);
if (!td_random(td))
return;
@@ -736,6 +760,7 @@ static void td_fill_rand_seeds_internal(
init_rand_seed(&td->__file_size_state,
td->rand_seeds[FIO_RAND_FILE_SIZE_OFF]);
init_rand_seed(&td->__trim_state, td->rand_seeds[FIO_RAND_TRIM_OFF]);
+ init_rand_seed(&td->__delay_state, td->rand_seeds[FIO_RAND_START_DELAY]);
if (!td_random(td))
return;
--- a/options.c
+++ b/options.c
@@ -2018,6 +2018,7 @@ struct fio_option fio_options[FIO_MAX_OP
.lname = "Start delay",
.type = FIO_OPT_STR_VAL_TIME,
.off1 = td_var_offset(start_delay),
+ .off2 = td_var_offset(start_delay_high),
.help = "Only start job when this period has passed",
.def = "0",
.category = FIO_OPT_C_GENERAL,
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2014-02-20 17:03 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-02-20 13:20 [patch 4/9] fio: provide an option for a startdelay range ehrhardt
2014-02-20 17:03 ` Jens Axboe
[not found] <20140219143639.168501090@linux.vnet.ibm.com>
2014-02-19 15:12 ` Christian Ehrhardt
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox