From 38d77caebcb6f9cb33f247a341c162c0185bf604 Mon Sep 17 00:00:00 2001 From: Jens Axboe Date: Wed, 21 Mar 2007 14:20:20 +0100 Subject: [PATCH] Improve data direction runtime logging If we cut a data direction short, log that time so we don't account the full runtime. Signed-off-by: Jens Axboe --- fio.c | 22 ++++++++++++++++++---- fio.h | 2 ++ io_u.c | 7 ++++++- 3 files changed, 26 insertions(+), 5 deletions(-) diff --git a/fio.c b/fio.c index 29fecb79..9fabbe93 100644 --- a/fio.c +++ b/fio.c @@ -699,6 +699,7 @@ static int clear_io_state(struct thread_data *td) td->zone_bytes = 0; td->rate_bytes = 0; td->rate_blocks = 0; + td->rw_end_set[0] = td->rw_end_set[1] = 0; td->last_was_sync = 0; @@ -723,6 +724,7 @@ static void *thread_main(void *data) { unsigned long long runtime[2]; struct thread_data *td = data; + unsigned long elapsed; int clear_state; if (!td->o.use_thread) @@ -811,10 +813,22 @@ static void *thread_main(void *data) clear_state = 1; - if (td_read(td) && td->io_bytes[DDIR_READ]) - runtime[DDIR_READ] += utime_since_now(&td->start); - if (td_write(td) && td->io_bytes[DDIR_WRITE]) - runtime[DDIR_WRITE] += utime_since_now(&td->start); + if (td_read(td) && td->io_bytes[DDIR_READ]) { + if (td->rw_end_set[DDIR_READ]) + elapsed = utime_since(&td->start, &td->rw_end[DDIR_READ]); + else + elapsed = utime_since_now(&td->start); + + runtime[DDIR_READ] += elapsed; + } + if (td_write(td) && td->io_bytes[DDIR_WRITE]) { + if (td->rw_end_set[DDIR_WRITE]) + elapsed = utime_since(&td->start, &td->rw_end[DDIR_WRITE]); + else + elapsed = utime_since_now(&td->start); + + runtime[DDIR_WRITE] += elapsed; + } if (td->error || td->terminate) break; diff --git a/fio.h b/fio.h index 1fb01d95..e3334908 100644 --- a/fio.h +++ b/fio.h @@ -493,6 +493,8 @@ struct thread_data { struct timeval start; /* start of this loop */ struct timeval epoch; /* time job was started */ + struct timeval rw_end[2]; + unsigned int rw_end_set[2]; /* * read/write mixed workload state diff --git a/io_u.c b/io_u.c index 1f9ebbc8..fd25dfe7 100644 --- a/io_u.c +++ b/io_u.c @@ -235,8 +235,13 @@ static enum fio_ddir get_rw_ddir(struct thread_data *td) */ ddir = get_rand_ddir(td); max_bytes = td->this_io_bytes[ddir]; - if (max_bytes >= (td->io_size * td->o.rwmix[ddir] / 100)) + if (max_bytes >= (td->io_size * td->o.rwmix[ddir] / 100)) { + if (!td->rw_end_set[ddir]) { + td->rw_end_set[ddir] = 1; + memcpy(&td->rw_end[ddir], &now, sizeof(now)); + } ddir ^= 1; + } if (ddir != td->rwmix_ddir) set_rwmix_bytes(td); -- 2.25.1