[PATCH] Add in-progress io rate
authorJens Axboe <jens.axboe@oracle.com>
Fri, 3 Nov 2006 10:37:47 +0000 (11:37 +0100)
committerJens Axboe <jens.axboe@oracle.com>
Fri, 3 Nov 2006 10:37:47 +0000 (11:37 +0100)
Dumped along with percentage and eta.

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

diff --git a/HOWTO b/HOWTO
index 78a9be037839b1692bdca1e64f6283daaa3aad4c..c17d29e5652a864de9d3ffbf0763f68be6e4a4c1 100644 (file)
--- a/HOWTO
+++ b/HOWTO
@@ -454,7 +454,7 @@ cpuchunks=int       If the job is a CPU cycle eater, split the load into
 fio spits out a lot of output. While running, fio will display the
 status of the jobs created. An example of that would be:
 
 fio spits out a lot of output. While running, fio will display the
 status of the jobs created. An example of that would be:
 
-Threads running: 1: [_r] [24.79% done] [eta 00h:01m:31s]
+Threads running: 1: [_r] [24.79% done] [ 13509/  8334 kb/s] [eta 00h:01m:31s]
 
 The characters inside the square brackets denote the current status of
 each thread. The possible values (in typical life cycle order) are:
 
 The characters inside the square brackets denote the current status of
 each thread. The possible values (in typical life cycle order) are:
@@ -476,9 +476,9 @@ E           Thread exited, not reaped by main thread yet.
 _              Thread reaped.
 
 The other values are fairly self explanatory - number of threads
 _              Thread reaped.
 
 The other values are fairly self explanatory - number of threads
-currently running and doing io, and the estimated completion percentage
-and time for the running group. It's impossible to estimate runtime
-of the following groups (if any).
+currently running and doing io, rate of io since last check, and the estimated
+completion percentage and time for the running group. It's impossible to
+estimate runtime of the following groups (if any).
 
 When fio is done (or interrupted by ctrl-c), it will show the data for
 each thread, group of threads, and disks in that order. For each data
 
 When fio is done (or interrupted by ctrl-c), it will show the data for
 each thread, group of threads, and disks in that order. For each data
diff --git a/eta.c b/eta.c
index 8cf9ea25eb6127f675c5a16d4a4d02a9ecf6d596..339f6568b16de68bb3e6af774dd875367f5f6292 100644 (file)
--- a/eta.c
+++ b/eta.c
@@ -176,12 +176,22 @@ void print_thread_status(void)
        char eta_str[32];
        double perc = 0.0;
 
        char eta_str[32];
        double perc = 0.0;
 
+       static unsigned long long prev_io_bytes[2];
+       static struct timeval prev_time;
+       static unsigned int r_rate, w_rate;
+       unsigned long long io_bytes[2];
+       unsigned long mtime;
+
        if (temp_stall_ts || terse_output)
                return;
 
        if (temp_stall_ts || terse_output)
                return;
 
+       if (!prev_io_bytes[0] && !prev_io_bytes[1])
+               fill_start_time(&prev_time);
+
        eta_secs = malloc(thread_number * sizeof(int));
        memset(eta_secs, 0, thread_number * sizeof(int));
 
        eta_secs = malloc(thread_number * sizeof(int));
        memset(eta_secs, 0, thread_number * sizeof(int));
 
+       io_bytes[0] = io_bytes[1] = 0;
        nr_pending = nr_running = t_rate = m_rate = 0;
        for_each_td(td, i) {
                if (td->runstate == TD_RUNNING || td->runstate == TD_VERIFYING||
        nr_pending = nr_running = t_rate = m_rate = 0;
        for_each_td(td, i) {
                if (td->runstate == TD_RUNNING || td->runstate == TD_VERIFYING||
@@ -198,6 +208,8 @@ void print_thread_status(void)
                        eta_secs[i] = INT_MAX;
 
                check_str_update(td);
                        eta_secs[i] = INT_MAX;
 
                check_str_update(td);
+               io_bytes[0] += td->io_bytes[0];
+               io_bytes[1] += td->io_bytes[1];
        }
 
        if (exitall_on_terminate)
        }
 
        if (exitall_on_terminate)
@@ -222,6 +234,14 @@ void print_thread_status(void)
                eta_to_str(eta_str, eta_sec);
        }
 
                eta_to_str(eta_str, eta_sec);
        }
 
+       mtime = mtime_since_now(&prev_time);
+       if (mtime > 1000) {
+               r_rate = (io_bytes[0] - prev_io_bytes[0]) / mtime;
+               w_rate = (io_bytes[1] - prev_io_bytes[1]) / mtime;
+               gettimeofday(&prev_time, NULL);
+               memcpy(prev_io_bytes, io_bytes, sizeof(io_bytes));
+       }
+
        if (!nr_running && !nr_pending)
                return;
 
        if (!nr_running && !nr_pending)
                return;
 
@@ -230,7 +250,7 @@ void print_thread_status(void)
                printf(", commitrate %d/%dKiB/sec", t_rate, m_rate);
        if (eta_sec != INT_MAX && nr_running) {
                perc *= 100.0;
                printf(", commitrate %d/%dKiB/sec", t_rate, m_rate);
        if (eta_sec != INT_MAX && nr_running) {
                perc *= 100.0;
-               printf(": [%s] [%3.2f%% done] [eta %s]", run_str, perc,eta_str);
+               printf(": [%s] [%3.2f%% done] [%6u/%6u kb/s] [eta %s]", run_str, perc, r_rate, w_rate, eta_str);
        }
        printf("\r");
        fflush(stdout);
        }
        printf("\r");
        fflush(stdout);
diff --git a/fio.h b/fio.h
index 53e174e1b525808674143ef667960de6aad34dbd..5bb5569584cc289d49bb9afd9831ba05bd98d0ee 100644 (file)
--- a/fio.h
+++ b/fio.h
@@ -459,6 +459,7 @@ extern unsigned long mtime_since_genesis(void);
 extern void __usec_sleep(unsigned int);
 extern void usec_sleep(struct thread_data *, unsigned long);
 extern void rate_throttle(struct thread_data *, unsigned long, unsigned int, int);
 extern void __usec_sleep(unsigned int);
 extern void usec_sleep(struct thread_data *, unsigned long);
 extern void rate_throttle(struct thread_data *, unsigned long, unsigned int, int);
+extern void fill_start_time(struct timeval *);
 
 /*
  * Init functions
 
 /*
  * Init functions
diff --git a/time.c b/time.c
index 5d3dee20e8b6337109005efe507b96c549708ace..d08c791673f55b8139be5ec20cc757a891913423 100644 (file)
--- a/time.c
+++ b/time.c
@@ -132,3 +132,8 @@ void time_init(void)
 {
        gettimeofday(&genesis, NULL);
 }
 {
        gettimeofday(&genesis, NULL);
 }
+
+void fill_start_time(struct timeval *t)
+{
+       memcpy(t, &genesis, sizeof(genesis));
+}