Improve eta calculation and display for complex jobs
authorJens Axboe <jens.axboe@oracle.com>
Sun, 6 Apr 2008 10:19:05 +0000 (12:19 +0200)
committerJens Axboe <jens.axboe@oracle.com>
Sun, 6 Apr 2008 10:19:05 +0000 (12:19 +0200)
Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
eta.c
fio.c
fio.h

diff --git a/eta.c b/eta.c
index 9a9f658b1969bbbc328c87c44913d6ce78b22019..bac3ddfdd05c287e814fbf789cbc49e6d80edcc5 100644 (file)
--- a/eta.c
+++ b/eta.c
@@ -133,8 +133,9 @@ static int thread_eta(struct thread_data *td, unsigned long elapsed)
 
                eta_sec = (unsigned long) (elapsed * (1.0 / perc)) - elapsed;
 
 
                eta_sec = (unsigned long) (elapsed * (1.0 / perc)) - elapsed;
 
-               if (td->o.timeout && eta_sec > (td->o.timeout - elapsed))
-                       eta_sec = td->o.timeout - elapsed;
+               if (td->o.timeout &&
+                   eta_sec > (td->o.timeout + done_secs - elapsed))
+                       eta_sec = td->o.timeout + done_secs - elapsed;
        } else if (td->runstate == TD_NOT_CREATED || td->runstate == TD_CREATED
                        || td->runstate == TD_INITIALIZED) {
                int t_eta = 0, r_eta = 0;
        } else if (td->runstate == TD_NOT_CREATED || td->runstate == TD_CREATED
                        || td->runstate == TD_INITIALIZED) {
                int t_eta = 0, r_eta = 0;
@@ -144,10 +145,10 @@ static int thread_eta(struct thread_data *td, unsigned long elapsed)
                 * if given, otherwise assume it'll run at the specified rate.
                 */
                if (td->o.timeout)
                 * if given, otherwise assume it'll run at the specified rate.
                 */
                if (td->o.timeout)
-                       t_eta = td->o.timeout + td->o.start_delay - elapsed;
+                       t_eta = td->o.timeout + td->o.start_delay;
                if (td->o.rate) {
                        r_eta = (bytes_total / 1024) / td->o.rate;
                if (td->o.rate) {
                        r_eta = (bytes_total / 1024) / td->o.rate;
-                       r_eta += td->o.start_delay - elapsed;
+                       r_eta += td->o.start_delay;
                }
 
                if (r_eta && t_eta)
                }
 
                if (r_eta && t_eta)
@@ -184,13 +185,13 @@ static void calc_rate(unsigned long mtime, unsigned long long *io_bytes,
 void print_thread_status(void)
 {
        unsigned long elapsed = mtime_since_genesis() / 1000;
 void print_thread_status(void)
 {
        unsigned long elapsed = mtime_since_genesis() / 1000;
-       int i, nr_running, nr_pending, t_rate, m_rate, *eta_secs, eta_sec;
+       int i, nr_running, nr_pending, t_rate, m_rate;
        int t_iops, m_iops, files_open;
        struct thread_data *td;
        char eta_str[128];
        double perc = 0.0;
        unsigned long long io_bytes[2];
        int t_iops, m_iops, files_open;
        struct thread_data *td;
        char eta_str[128];
        double perc = 0.0;
        unsigned long long io_bytes[2];
-       unsigned long rate_time, disp_time, bw_avg_time;
+       unsigned long rate_time, disp_time, bw_avg_time, *eta_secs, eta_sec;
        struct timeval now;
 
        static unsigned long long rate_io_bytes[2];
        struct timeval now;
 
        static unsigned long long rate_io_bytes[2];
@@ -210,8 +211,8 @@ void print_thread_status(void)
        if (!disp_io_bytes[0] && !disp_io_bytes[1])
                fill_start_time(&disp_prev_time);
 
        if (!disp_io_bytes[0] && !disp_io_bytes[1])
                fill_start_time(&disp_prev_time);
 
-       eta_secs = malloc(thread_number * sizeof(int));
-       memset(eta_secs, 0, thread_number * sizeof(int));
+       eta_secs = malloc(thread_number * sizeof(unsigned long));
+       memset(eta_secs, 0, thread_number * sizeof(unsigned long));
 
        io_bytes[0] = io_bytes[1] = 0;
        nr_pending = nr_running = t_rate = m_rate = t_iops = m_iops = 0;
 
        io_bytes[0] = io_bytes[1] = 0;
        nr_pending = nr_running = t_rate = m_rate = t_iops = m_iops = 0;
@@ -247,13 +248,8 @@ void print_thread_status(void)
                eta_sec = 0;
 
        for_each_td(td, i) {
                eta_sec = 0;
 
        for_each_td(td, i) {
-               if (exitall_on_terminate) {
-                       if (eta_secs[i] < eta_sec)
-                               eta_sec = eta_secs[i];
-               } else {
-                       if (eta_secs[i] > eta_sec)
-                               eta_sec = eta_secs[i];
-               }
+               if (eta_secs[i] != INT_MAX)
+                       eta_sec += eta_secs[i];
        }
 
        free(eta_secs);
        }
 
        free(eta_secs);
diff --git a/fio.c b/fio.c
index 231a581f5478df56054531137d2f1b17ebc3ba57..b79aa93e644296be9bdf0439863760d8dd4a6cfd 100644 (file)
--- a/fio.c
+++ b/fio.c
@@ -49,6 +49,7 @@ int nr_process = 0;
 int nr_thread = 0;
 int shm_id = 0;
 int temp_stall_ts;
 int nr_thread = 0;
 int shm_id = 0;
 int temp_stall_ts;
+unsigned long done_secs = 0;
 
 static struct fio_mutex *startup_mutex;
 static volatile int fio_abort;
 
 static struct fio_mutex *startup_mutex;
 static volatile int fio_abort;
@@ -1118,6 +1119,8 @@ reaped:
 
                if (td->error)
                        exit_value++;
 
                if (td->error)
                        exit_value++;
+
+               done_secs += mtime_since_now(&td->epoch) / 1000;
        }
 
        if (*nr_running == cputhreads && !pending && realthreads)
        }
 
        if (*nr_running == cputhreads && !pending && realthreads)
diff --git a/fio.h b/fio.h
index b2930f11d29225a1abe891b1507753b81b27650f..661dd49b2519f11e748451e98e3af5c2b48f6a08 100644 (file)
--- a/fio.h
+++ b/fio.h
@@ -684,6 +684,7 @@ extern unsigned long long mlock_size;
 extern unsigned long page_mask, page_size;
 extern int read_only;
 extern int eta_print;
 extern unsigned long page_mask, page_size;
 extern int read_only;
 extern int eta_print;
+extern unsigned long done_secs;
 extern char *job_section;
 
 extern struct thread_data *threads;
 extern char *job_section;
 
 extern struct thread_data *threads;