Improve data direction runtime logging
authorJens Axboe <jens.axboe@oracle.com>
Wed, 21 Mar 2007 13:20:20 +0000 (14:20 +0100)
committerJens Axboe <jens.axboe@oracle.com>
Wed, 21 Mar 2007 13:20:20 +0000 (14:20 +0100)
If we cut a data direction short, log that time so we don't
account the full runtime.

Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
fio.c
fio.h
io_u.c

diff --git a/fio.c b/fio.c
index 29fecb79d1203e9d93502ca1c685ab865412ab62..9fabbe93bc53a7887cc6457371b55ea202ff3ebc 100644 (file)
--- 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->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;
 
 
        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 long runtime[2];
        struct thread_data *td = data;
+       unsigned long elapsed;
        int clear_state;
 
        if (!td->o.use_thread)
        int clear_state;
 
        if (!td->o.use_thread)
@@ -811,10 +813,22 @@ static void *thread_main(void *data)
 
                clear_state = 1;
 
 
                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;
                
                if (td->error || td->terminate)
                        break;
diff --git a/fio.h b/fio.h
index 1fb01d9522f5f2d4bd20babd81cc227bb87238e4..e33349088cebacb5869b4e4649cebea45f60b220 100644 (file)
--- 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 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
 
        /*
         * read/write mixed workload state
diff --git a/io_u.c b/io_u.c
index 1f9ebbc83bd61da39947274130aef529bc5708e0..fd25dfe704423dc989ef36df741efab67283d609 100644 (file)
--- 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];
                         */
                        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;
                                ddir ^= 1;
+                       }
 
                        if (ddir != td->rwmix_ddir)
                                set_rwmix_bytes(td);
 
                        if (ddir != td->rwmix_ddir)
                                set_rwmix_bytes(td);