Skip to content

Commit dd8d112

Browse files
WIP: Per Job Start Delay axboe#1164
1 parent 6308ef2 commit dd8d112

File tree

3 files changed

+33
-1
lines changed

3 files changed

+33
-1
lines changed

backend.c

+17-1
Original file line numberDiff line numberDiff line change
@@ -2251,9 +2251,11 @@ static bool waitee_running(struct thread_data *me)
22512251
static void run_threads(struct sk_out *sk_out)
22522252
{
22532253
struct thread_data *td;
2254-
unsigned int i, todo, nr_running, nr_started;
2254+
struct timespec last_finish_time;
2255+
unsigned int i, todo, nr_running, nr_started, prev_nr_running;
22552256
uint64_t m_rate, t_rate;
22562257
uint64_t spent;
2258+
uint64_t per_job_spent;
22572259

22582260
if (fio_gtod_offload && fio_start_gtod_thread())
22592261
return;
@@ -2294,6 +2296,7 @@ static void run_threads(struct sk_out *sk_out)
22942296
todo = thread_number;
22952297
nr_running = 0;
22962298
nr_started = 0;
2299+
prev_nr_running = 0;
22972300
m_rate = t_rate = 0;
22982301

22992302
for_each_td(td, i) {
@@ -2338,6 +2341,7 @@ static void run_threads(struct sk_out *sk_out)
23382341
fio_idle_prof_start();
23392342

23402343
set_genesis_time();
2344+
fio_gettime(&last_finish_time, NULL);
23412345

23422346
while (todo) {
23432347
struct thread_data *map[REAL_MAX_JOBS];
@@ -2380,6 +2384,13 @@ static void run_threads(struct sk_out *sk_out)
23802384
continue;
23812385
}
23822386

2387+
if (td->o.stonewall && td->o.per_job_start_delay) {
2388+
per_job_spent = utime_since_now(&last_finish_time);
2389+
2390+
if (td->o.per_job_start_delay > per_job_spent)
2391+
continue;
2392+
}
2393+
23832394
init_disk_util(td);
23842395

23852396
td->rusage_sem = fio_sem_init(FIO_SEM_LOCKED);
@@ -2498,7 +2509,12 @@ static void run_threads(struct sk_out *sk_out)
24982509
fio_sem_up(td->sem);
24992510
}
25002511

2512+
prev_nr_running = nr_running;
25012513
reap_threads(&nr_running, &t_rate, &m_rate);
2514+
if (nr_running == prev_nr_running - 1) {
2515+
//sequential job has finished get new base time
2516+
fio_gettime(&last_finish_time, NULL);
2517+
}
25022518

25032519
if (todo)
25042520
do_usleep(100000);

options.c

+13
Original file line numberDiff line numberDiff line change
@@ -2744,6 +2744,19 @@ struct fio_option fio_options[FIO_MAX_OPTS] = {
27442744
.category = FIO_OPT_C_GENERAL,
27452745
.group = FIO_OPT_G_RUNTIME,
27462746
},
2747+
{
2748+
.name = "per_job_startdelay",
2749+
.lname = "Per Job Start delay",
2750+
.type = FIO_OPT_STR_VAL_TIME,
2751+
.off1 = offsetof(struct thread_options, per_job_start_delay),
2752+
.off2 = offsetof(struct thread_options, per_job_start_delay_high),
2753+
.help = "Only start job when this period has passed",
2754+
.def = "0",
2755+
.is_seconds = 1,
2756+
.is_time = 1,
2757+
.category = FIO_OPT_C_GENERAL,
2758+
.group = FIO_OPT_G_RUNTIME,
2759+
},
27472760
{
27482761
.name = "runtime",
27492762
.lname = "Runtime",

thread_options.h

+3
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,9 @@ struct thread_options {
187187
unsigned long long start_delay;
188188
unsigned long long start_delay_orig;
189189
unsigned long long start_delay_high;
190+
unsigned long long per_job_start_delay;
191+
unsigned long long per_job_start_delay_orig;
192+
unsigned long long per_job_start_delay_high;
190193
unsigned long long timeout;
191194
unsigned long long ramp_time;
192195
unsigned int ss_state;

0 commit comments

Comments
 (0)