Include transfer size in the clat/slat measurements
authorJens Axboe <jens.axboe@oracle.com>
Mon, 18 May 2009 11:08:12 +0000 (13:08 +0200)
committerJens Axboe <jens.axboe@oracle.com>
Mon, 18 May 2009 11:08:12 +0000 (13:08 +0200)
It's useful to know the block size that matches the given latency, so
add that to the end.

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

diff --git a/eta.c b/eta.c
index 1c809ee..5a5188f 100644 (file)
--- a/eta.c
+++ b/eta.c
@@ -296,8 +296,8 @@ void print_thread_status(void)
        if (write_bw_log && rate_time > bw_avg_time && !in_ramp_time(td)) {
                calc_rate(rate_time, io_bytes, rate_io_bytes, rate);
                memcpy(&rate_prev_time, &now, sizeof(now));
-               add_agg_sample(rate[DDIR_READ], DDIR_READ);
-               add_agg_sample(rate[DDIR_WRITE], DDIR_WRITE);
+               add_agg_sample(rate[DDIR_READ], DDIR_READ, 0);
+               add_agg_sample(rate[DDIR_WRITE], DDIR_WRITE, 0);
        }
 
        disp_time = mtime_since(&disp_prev_time, &now);
diff --git a/fio.h b/fio.h
index f5786ea..1ccc862 100644 (file)
--- a/fio.h
+++ b/fio.h
@@ -75,6 +75,7 @@ struct io_sample {
        unsigned long time;
        unsigned long val;
        enum fio_ddir ddir;
+       unsigned int bs;
 };
 
 /*
@@ -810,9 +811,12 @@ extern void write_iolog_close(struct thread_data *);
 /*
  * Logging
  */
-extern void add_clat_sample(struct thread_data *, enum fio_ddir, unsigned long);
-extern void add_slat_sample(struct thread_data *, enum fio_ddir, unsigned long);
-extern void add_bw_sample(struct thread_data *, enum fio_ddir, struct timeval *);
+extern void add_clat_sample(struct thread_data *, enum fio_ddir, unsigned long,
+                               unsigned int);
+extern void add_slat_sample(struct thread_data *, enum fio_ddir, unsigned long,
+                               unsigned int);
+extern void add_bw_sample(struct thread_data *, enum fio_ddir, unsigned int,
+                               struct timeval *);
 extern void show_run_stats(void);
 extern void init_disk_util(struct thread_data *);
 extern void update_rusage_stat(struct thread_data *);
@@ -823,7 +827,7 @@ extern void finish_log_named(struct thread_data *, struct io_log *, const char *
 extern void __finish_log(struct io_log *, const char *);
 extern struct io_log *agg_io_log[2];
 extern int write_bw_log;
-extern void add_agg_sample(unsigned long, enum fio_ddir);
+extern void add_agg_sample(unsigned long, enum fio_ddir, unsigned int);
 
 /*
  * Time functions
diff --git a/io_u.c b/io_u.c
index 8c2f33b..fc49bd3 100644 (file)
--- a/io_u.c
+++ b/io_u.c
@@ -917,11 +917,11 @@ static void io_completed(struct thread_data *td, struct io_u *io_u,
                                                        &icd->time);
 
                        if (!td->o.disable_clat) {
-                               add_clat_sample(td, idx, usec);
+                               add_clat_sample(td, idx, usec, bytes);
                                io_u_mark_latency(td, usec);
                        }
                        if (!td->o.disable_bw)
-                               add_bw_sample(td, idx, &icd->time);
+                               add_bw_sample(td, idx, bytes, &icd->time);
                }
 
                if (td_write(td) && idx == DDIR_WRITE &&
@@ -1026,7 +1026,7 @@ void io_u_queued(struct thread_data *td, struct io_u *io_u)
                unsigned long slat_time;
 
                slat_time = utime_since(&io_u->start_time, &io_u->issue_time);
-               add_slat_sample(td, io_u->ddir, slat_time);
+               add_slat_sample(td, io_u->ddir, io_u->xfer_buflen, slat_time);
        }
 }
 
diff --git a/log.c b/log.c
index 6913357..6d5e68d 100644 (file)
--- a/log.c
+++ b/log.c
@@ -471,8 +471,10 @@ void __finish_log(struct io_log *log, const char *name)
        }
 
        for (i = 0; i < log->nr_samples; i++) {
-               fprintf(f, "%lu, %lu, %u\n", log->log[i].time, log->log[i].val,
-                                               log->log[i].ddir);
+               fprintf(f, "%lu, %lu, %u, %u\n", log->log[i].time,
+                                               log->log[i].val,
+                                               log->log[i].ddir,
+                                               log->log[i].bs);
        }
 
        fclose(f);
diff --git a/stat.c b/stat.c
index beeceb7..a42ed98 100644 (file)
--- a/stat.c
+++ b/stat.c
@@ -700,8 +700,11 @@ static inline void add_stat_sample(struct io_stat *is, unsigned long data)
 }
 
 static void __add_log_sample(struct io_log *iolog, unsigned long val,
-                            enum fio_ddir ddir, unsigned long time)
+                            enum fio_ddir ddir, unsigned int bs,
+                            unsigned long time)
 {
+       const int nr_samples = iolog->nr_samples;
+
        if (iolog->nr_samples == iolog->max_samples) {
                int new_size = sizeof(struct io_sample) * iolog->max_samples*2;
 
@@ -709,48 +712,50 @@ static void __add_log_sample(struct io_log *iolog, unsigned long val,
                iolog->max_samples <<= 1;
        }
 
-       iolog->log[iolog->nr_samples].val = val;
-       iolog->log[iolog->nr_samples].time = time;
-       iolog->log[iolog->nr_samples].ddir = ddir;
+       iolog->log[nr_samples].val = val;
+       iolog->log[nr_samples].time = time;
+       iolog->log[nr_samples].ddir = ddir;
+       iolog->log[nr_samples].bs = bs;
        iolog->nr_samples++;
 }
 
 static void add_log_sample(struct thread_data *td, struct io_log *iolog,
-                          unsigned long val, enum fio_ddir ddir)
+                          unsigned long val, enum fio_ddir ddir,
+                          unsigned int bs)
 {
-       __add_log_sample(iolog, val, ddir, mtime_since_now(&td->epoch));
+       __add_log_sample(iolog, val, ddir, bs, mtime_since_now(&td->epoch));
 }
 
-void add_agg_sample(unsigned long val, enum fio_ddir ddir)
+void add_agg_sample(unsigned long val, enum fio_ddir ddir, unsigned int bs)
 {
        struct io_log *iolog = agg_io_log[ddir];
 
-       __add_log_sample(iolog, val, ddir, mtime_since_genesis());
+       __add_log_sample(iolog, val, ddir, bs, mtime_since_genesis());
 }
 
 void add_clat_sample(struct thread_data *td, enum fio_ddir ddir,
-                    unsigned long usec)
+                    unsigned long usec, unsigned int bs)
 {
        struct thread_stat *ts = &td->ts;
 
        add_stat_sample(&ts->clat_stat[ddir], usec);
 
        if (ts->clat_log)
-               add_log_sample(td, ts->clat_log, usec, ddir);
+               add_log_sample(td, ts->clat_log, usec, ddir, bs);
 }
 
 void add_slat_sample(struct thread_data *td, enum fio_ddir ddir,
-                    unsigned long usec)
+                    unsigned long usec, unsigned int bs)
 {
        struct thread_stat *ts = &td->ts;
 
        add_stat_sample(&ts->slat_stat[ddir], usec);
 
        if (ts->slat_log)
-               add_log_sample(td, ts->slat_log, usec, ddir);
+               add_log_sample(td, ts->slat_log, usec, ddir, bs);
 }
 
-void add_bw_sample(struct thread_data *td, enum fio_ddir ddir,
+void add_bw_sample(struct thread_data *td, enum fio_ddir ddir, unsigned int bs,
                   struct timeval *t)
 {
        struct thread_stat *ts = &td->ts;
@@ -764,7 +769,7 @@ void add_bw_sample(struct thread_data *td, enum fio_ddir ddir,
        add_stat_sample(&ts->bw_stat[ddir], rate);
 
        if (ts->bw_log)
-               add_log_sample(td, ts->bw_log, rate, ddir);
+               add_log_sample(td, ts->bw_log, rate, ddir, bs);
 
        fio_gettime(&ts->stat_sample_time[ddir], NULL);
        ts->stat_io_bytes[ddir] = td->this_io_bytes[ddir];