gclient: Use proper time units in latency buckets chart
[fio.git] / gclient.c
index b8c681a65d9dc4703f4b409dc9e2bc53502b45df..59b0404865a5f477c9cccff128f3855854338964 100644 (file)
--- a/gclient.c
+++ b/gclient.c
@@ -13,6 +13,7 @@
 #include "graph.h"
 #include "gclient.h"
 #include "printing.h"
+#include "lib/pow2.h"
 
 static void gfio_display_ts(struct fio_client *client, struct thread_stat *ts,
                            struct group_run_stats *rs);
@@ -195,39 +196,39 @@ static int __gfio_disk_util_show(GtkWidget *res_notebook,
        vbox = gtk_hbox_new(TRUE, 3);
        gtk_container_add(GTK_CONTAINER(frame), vbox);
        entry = new_info_entry_in_frame(vbox, "IOs");
-       entry_set_int_value(entry, p->dus.ios[0]);
+       entry_set_int_value(entry, p->dus.s.ios[0]);
        entry = new_info_entry_in_frame(vbox, "Merges");
-       entry_set_int_value(entry, p->dus.merges[0]);
+       entry_set_int_value(entry, p->dus.s.merges[0]);
        entry = new_info_entry_in_frame(vbox, "Sectors");
-       entry_set_int_value(entry, p->dus.sectors[0]);
+       entry_set_int_value(entry, p->dus.s.sectors[0]);
        entry = new_info_entry_in_frame(vbox, "Ticks");
-       entry_set_int_value(entry, p->dus.ticks[0]);
+       entry_set_int_value(entry, p->dus.s.ticks[0]);
 
        frame = gtk_frame_new("Write");
        gtk_box_pack_start(GTK_BOX(box), frame, FALSE, FALSE, 2);
        vbox = gtk_hbox_new(TRUE, 3);
        gtk_container_add(GTK_CONTAINER(frame), vbox);
        entry = new_info_entry_in_frame(vbox, "IOs");
-       entry_set_int_value(entry, p->dus.ios[1]);
+       entry_set_int_value(entry, p->dus.s.ios[1]);
        entry = new_info_entry_in_frame(vbox, "Merges");
-       entry_set_int_value(entry, p->dus.merges[1]);
+       entry_set_int_value(entry, p->dus.s.merges[1]);
        entry = new_info_entry_in_frame(vbox, "Sectors");
-       entry_set_int_value(entry, p->dus.sectors[1]);
+       entry_set_int_value(entry, p->dus.s.sectors[1]);
        entry = new_info_entry_in_frame(vbox, "Ticks");
-       entry_set_int_value(entry, p->dus.ticks[1]);
+       entry_set_int_value(entry, p->dus.s.ticks[1]);
 
        frame = gtk_frame_new("Shared");
        gtk_box_pack_start(GTK_BOX(box), frame, FALSE, FALSE, 2);
        vbox = gtk_hbox_new(TRUE, 3);
        gtk_container_add(GTK_CONTAINER(frame), vbox);
        entry = new_info_entry_in_frame(vbox, "IO ticks");
-       entry_set_int_value(entry, p->dus.io_ticks);
+       entry_set_int_value(entry, p->dus.s.io_ticks);
        entry = new_info_entry_in_frame(vbox, "Time in queue");
-       entry_set_int_value(entry, p->dus.time_in_queue);
+       entry_set_int_value(entry, p->dus.s.time_in_queue);
 
        util = 0.0;
-       if (p->dus.msec)
-               util = (double) 100 * p->dus.io_ticks / (double) p->dus.msec;
+       if (p->dus.s.msec)
+               util = (double) 100 * p->dus.s.io_ticks / (double) p->dus.s.msec;
        if (util > 100.0)
                util = 100.0;
 
@@ -279,10 +280,6 @@ static void gfio_disk_util_op(struct fio_client *client, struct fio_net_cmd *cmd
        gdk_threads_leave();
 }
 
-extern int sum_stat_clients;
-extern struct thread_stat client_ts;
-extern struct group_run_stats client_gs;
-
 static int sum_stat_nr;
 
 static void gfio_thread_status_op(struct fio_client *client,
@@ -295,7 +292,7 @@ static void gfio_thread_status_op(struct fio_client *client,
        if (sum_stat_clients == 1)
                return;
 
-       sum_thread_stats(&client_ts, &p->ts, sum_stat_nr);
+       sum_thread_stats(&client_ts, &p->ts, sum_stat_nr == 1);
        sum_group_stats(&client_gs, &p->rs);
 
        client_ts.members++;
@@ -367,26 +364,6 @@ static void gfio_update_client_eta(struct fio_client *client, struct jobs_eta *j
        sprintf(tmp, "%u", je->files_open);
        gtk_entry_set_text(GTK_ENTRY(ge->eta.files), tmp);
 
-#if 0
-       if (je->m_rate[0] || je->m_rate[1] || je->t_rate[0] || je->t_rate[1]) {
-       if (je->m_rate || je->t_rate) {
-               char *tr, *mr;
-
-               mr = num2str(je->m_rate, 4, 0, i2p);
-               tr = num2str(je->t_rate, 4, 0, i2p);
-               gtk_entry_set_text(GTK_ENTRY(ge->eta);
-               p += sprintf(p, ", CR=%s/%s KB/s", tr, mr);
-               free(tr);
-               free(mr);
-       } else if (je->m_iops || je->t_iops)
-               p += sprintf(p, ", CR=%d/%d IOPS", je->t_iops, je->m_iops);
-
-       gtk_entry_set_text(GTK_ENTRY(ge->eta.cr_bw), "---");
-       gtk_entry_set_text(GTK_ENTRY(ge->eta.cr_iops), "---");
-       gtk_entry_set_text(GTK_ENTRY(ge->eta.cw_bw), "---");
-       gtk_entry_set_text(GTK_ENTRY(ge->eta.cw_iops), "---");
-#endif
-
        if (je->eta_sec != INT_MAX && je->nr_running) {
                char *iops_str[DDIR_RWDIR_CNT];
                char *rate_str[DDIR_RWDIR_CNT];
@@ -400,13 +377,13 @@ static void gfio_update_client_eta(struct fio_client *client, struct jobs_eta *j
                        sprintf(output, "%3.1f%% done", perc);
                }
 
-               rate_str[0] = num2str(je->rate[0], 5, 10, i2p);
-               rate_str[1] = num2str(je->rate[1], 5, 10, i2p);
-               rate_str[2] = num2str(je->rate[2], 5, 10, i2p);
+               rate_str[0] = num2str(je->rate[0], 5, 10, i2p, 0);
+               rate_str[1] = num2str(je->rate[1], 5, 10, i2p, 0);
+               rate_str[2] = num2str(je->rate[2], 5, 10, i2p, 0);
 
-               iops_str[0] = num2str(je->iops[0], 4, 1, 0);
-               iops_str[1] = num2str(je->iops[1], 4, 1, 0);
-               iops_str[2] = num2str(je->iops[2], 4, 1, 0);
+               iops_str[0] = num2str(je->iops[0], 4, 1, 0, 0);
+               iops_str[1] = num2str(je->iops[1], 4, 1, 0, 0);
+               iops_str[2] = num2str(je->iops[2], 4, 1, 0, 0);
 
                gtk_entry_set_text(GTK_ENTRY(ge->eta.read_bw), rate_str[0]);
                gtk_entry_set_text(GTK_ENTRY(ge->eta.read_iops), iops_str[0]);
@@ -460,26 +437,6 @@ static void gfio_update_all_eta(struct jobs_eta *je)
                eta_to_str(eta_str, je->eta_sec);
        }
 
-#if 0
-       if (je->m_rate[0] || je->m_rate[1] || je->t_rate[0] || je->t_rate[1]) {
-       if (je->m_rate || je->t_rate) {
-               char *tr, *mr;
-
-               mr = num2str(je->m_rate, 4, 0, i2p);
-               tr = num2str(je->t_rate, 4, 0, i2p);
-               gtk_entry_set_text(GTK_ENTRY(ui->eta);
-               p += sprintf(p, ", CR=%s/%s KB/s", tr, mr);
-               free(tr);
-               free(mr);
-       } else if (je->m_iops || je->t_iops)
-               p += sprintf(p, ", CR=%d/%d IOPS", je->t_iops, je->m_iops);
-
-       gtk_entry_set_text(GTK_ENTRY(ui->eta.cr_bw), "---");
-       gtk_entry_set_text(GTK_ENTRY(ui->eta.cr_iops), "---");
-       gtk_entry_set_text(GTK_ENTRY(ui->eta.cw_bw), "---");
-       gtk_entry_set_text(GTK_ENTRY(ui->eta.cw_iops), "---");
-#endif
-
        entry_set_int_value(ui->eta.jobs, je->nr_running);
 
        if (je->eta_sec != INT_MAX && je->nr_running) {
@@ -494,13 +451,13 @@ static void gfio_update_all_eta(struct jobs_eta *je)
                        sprintf(output, "%3.1f%% done", perc);
                }
 
-               rate_str[0] = num2str(je->rate[0], 5, 10, i2p);
-               rate_str[1] = num2str(je->rate[1], 5, 10, i2p);
-               rate_str[2] = num2str(je->rate[2], 5, 10, i2p);
+               rate_str[0] = num2str(je->rate[0], 5, 10, i2p, 0);
+               rate_str[1] = num2str(je->rate[1], 5, 10, i2p, 0);
+               rate_str[2] = num2str(je->rate[2], 5, 10, i2p, 0);
 
-               iops_str[0] = num2str(je->iops[0], 4, 1, 0);
-               iops_str[1] = num2str(je->iops[1], 4, 1, 0);
-               iops_str[2] = num2str(je->iops[2], 4, 1, 0);
+               iops_str[0] = num2str(je->iops[0], 4, 1, 0, 0);
+               iops_str[1] = num2str(je->iops[1], 4, 1, 0, 0);
+               iops_str[2] = num2str(je->iops[2], 4, 1, 0, 0);
 
                gtk_entry_set_text(GTK_ENTRY(ui->eta.read_bw), rate_str[0]);
                gtk_entry_set_text(GTK_ENTRY(ui->eta.read_iops), iops_str[0]);
@@ -534,7 +491,7 @@ static void gfio_update_all_eta(struct jobs_eta *je)
 
 static void gfio_probe_op(struct fio_client *client, struct fio_net_cmd *cmd)
 {
-       struct cmd_probe_pdu *probe = (struct cmd_probe_pdu *) cmd->payload;
+       struct cmd_probe_reply_pdu *probe = (struct cmd_probe_reply_pdu *) cmd->payload;
        struct gfio_client *gc = client->client_data;
        struct gui_entry *ge = gc->ge;
        const char *os, *arch;
@@ -692,12 +649,6 @@ static void gfio_client_job_start(struct fio_client *client, struct fio_net_cmd
        gdk_threads_leave();
 }
 
-static void gfio_client_iolog(struct fio_client *client, struct cmd_iolog_pdu *pdu)
-{
-       printf("got iolog: name=%s, type=%u, entries=%u\n", pdu->name, pdu->log_type, pdu->nr_samples);
-       free(pdu);
-}
-
 static void gfio_add_total_depths_tree(GtkListStore *model,
                                       struct thread_stat *ts, unsigned int len)
 {
@@ -957,10 +908,10 @@ static void gfio_show_latency_buckets(struct gfio_client *gc, GtkWidget *vbox,
                                      struct thread_stat *ts)
 {
        double io_u_lat[FIO_IO_U_LAT_U_NR + FIO_IO_U_LAT_M_NR];
-       const char *ranges[] = { "2u", "4u", "10u", "20u", "50u", "100u",
-                                "250u", "500u", "750u", "1m", "2m",
-                                "4m", "10m", "20m", "50m", "100m",
-                                "250m", "500m", "750m", "1s", "2s", ">= 2s" };
+       const char *ranges[] = { "2us", "4us", "10us", "20us", "50us", "100us",
+                                "250us", "500us", "750us", "1ms", "2ms",
+                                "4ms", "10ms", "20ms", "50ms", "100ms",
+                                "250ms", "500ms", "750ms", "1s", "2s", ">= 2s" };
        int start, end, i;
        const int total = FIO_IO_U_LAT_U_NR + FIO_IO_U_LAT_M_NR;
        GtkWidget *frame, *tree_view, *hbox, *completion_vbox, *drawing_area;
@@ -989,7 +940,7 @@ static void gfio_show_latency_buckets(struct gfio_client *gc, GtkWidget *vbox,
                return;
 
        tree_view = gfio_output_lat_buckets(&io_u_lat[start], &ranges[start], end - start + 1);
-       ge->lat_bucket_graph = setup_lat_bucket_graph("Latency Buckets", &io_u_lat[start], &ranges[start], end - start + 1, 700.0, 300.0);
+       ge->lat_bucket_graph = setup_lat_bucket_graph("Latency buckets", &io_u_lat[start], &ranges[start], end - start + 1, 700.0, 300.0);
 
        frame = gtk_frame_new("Latency buckets");
        gtk_box_pack_start(GTK_BOX(vbox), frame, FALSE, FALSE, 5);
@@ -1017,11 +968,11 @@ static void gfio_show_lat(GtkWidget *vbox, const char *name, unsigned long min,
        char *minp, *maxp;
        char tmp[64];
 
-       if (!usec_to_msec(&min, &max, &mean, &dev))
+       if (usec_to_msec(&min, &max, &mean, &dev))
                base = "(msec)";
 
-       minp = num2str(min, 6, 1, 0);
-       maxp = num2str(max, 6, 1, 0);
+       minp = num2str(min, 6, 1, 0, 0);
+       maxp = num2str(max, 6, 1, 0, 0);
 
        sprintf(tmp, "%s %s", name, base);
        frame = gtk_frame_new(tmp);
@@ -1192,11 +1143,11 @@ static void gfio_show_ddir_status(struct gfio_client *gc, GtkWidget *mbox,
        runt = ts->runtime[ddir];
 
        bw = (1000 * ts->io_bytes[ddir]) / runt;
-       io_p = num2str(ts->io_bytes[ddir], 6, 1, i2p);
-       bw_p = num2str(bw, 6, 1, i2p);
+       io_p = num2str(ts->io_bytes[ddir], 6, 1, i2p, 8);
+       bw_p = num2str(bw, 6, 1, i2p, ts->unit_base);
 
        iops = (1000 * (uint64_t)ts->total_io_u[ddir]) / runt;
-       iops_p = num2str(iops, 6, 1, 0);
+       iops_p = num2str(iops, 6, 1, 0, 0);
 
        box = gtk_hbox_new(FALSE, 3);
        gtk_box_pack_start(GTK_BOX(mbox), box, TRUE, FALSE, 3);
@@ -1393,7 +1344,6 @@ struct client_ops gfio_client_ops = {
        .stop                   = gfio_client_stop,
        .start                  = gfio_client_start,
        .job_start              = gfio_client_job_start,
-       .iolog                  = gfio_client_iolog,
        .removed                = gfio_client_removed,
        .eta_msec               = FIO_CLIENT_DEF_ETA_MSEC,
        .stay_connected         = 1,