16 static void gfio_display_ts(struct fio_client *client, struct thread_stat *ts,
17 struct group_run_stats *rs);
19 static gboolean results_window_delete(GtkWidget *w, gpointer data)
21 struct gui_entry *ge = (struct gui_entry *) data;
23 gtk_widget_destroy(w);
24 ge->results_window = NULL;
25 ge->results_notebook = NULL;
29 static void results_close(GtkWidget *w, gpointer *data)
31 struct gui_entry *ge = (struct gui_entry *) data;
33 gtk_widget_destroy(ge->results_window);
36 static GtkActionEntry results_menu_items[] = {
37 { "FileMenuAction", GTK_STOCK_FILE, "File", NULL, NULL, NULL},
38 { "GraphMenuAction", GTK_STOCK_FILE, "Graph", NULL, NULL, NULL},
39 { "CloseFile", GTK_STOCK_CLOSE, "Close", "<Control>W", NULL, G_CALLBACK(results_close) },
41 static gint results_nmenu_items = sizeof(results_menu_items) / sizeof(results_menu_items[0]);
43 static const gchar *results_ui_string = " \
45 <menubar name=\"MainMenu\"> \
46 <menu name=\"FileMenu\" action=\"FileMenuAction\"> \
47 <menuitem name=\"Close\" action=\"CloseFile\" /> \
49 <menu name=\"GraphMenu\" action=\"GraphMenuAction\"> \
55 static GtkWidget *get_results_menubar(GtkWidget *window, struct gui_entry *ge)
57 GtkActionGroup *action_group;
61 ge->results_uimanager = gtk_ui_manager_new();
63 action_group = gtk_action_group_new("ResultsMenu");
64 gtk_action_group_add_actions(action_group, results_menu_items, results_nmenu_items, ge);
66 gtk_ui_manager_insert_action_group(ge->results_uimanager, action_group, 0);
67 gtk_ui_manager_add_ui_from_string(GTK_UI_MANAGER(ge->results_uimanager), results_ui_string, -1, &error);
69 gtk_window_add_accel_group(GTK_WINDOW(window), gtk_ui_manager_get_accel_group(ge->results_uimanager));
71 widget = gtk_ui_manager_get_widget(ge->results_uimanager, "/MainMenu");
75 static GtkWidget *get_results_window(struct gui_entry *ge)
77 GtkWidget *win, *notebook, *vbox;
79 if (ge->results_window)
80 return ge->results_notebook;
82 win = gtk_window_new(GTK_WINDOW_TOPLEVEL);
83 gtk_window_set_title(GTK_WINDOW(win), "Results");
84 gtk_window_set_default_size(GTK_WINDOW(win), 1024, 768);
85 g_signal_connect(win, "delete-event", G_CALLBACK(results_window_delete), ge);
86 g_signal_connect(win, "destroy", G_CALLBACK(results_window_delete), ge);
88 vbox = gtk_vbox_new(FALSE, 0);
89 gtk_container_add(GTK_CONTAINER(win), vbox);
91 ge->results_menu = get_results_menubar(win, ge);
92 gtk_box_pack_start(GTK_BOX(vbox), ge->results_menu, FALSE, FALSE, 0);
94 notebook = gtk_notebook_new();
95 gtk_notebook_set_scrollable(GTK_NOTEBOOK(notebook), 1);
96 gtk_notebook_popup_enable(GTK_NOTEBOOK(notebook));
97 gtk_container_add(GTK_CONTAINER(vbox), notebook);
99 ge->results_window = win;
100 ge->results_notebook = notebook;
101 return ge->results_notebook;
104 static void gfio_text_op(struct fio_client *client, struct fio_net_cmd *cmd)
106 struct cmd_text_pdu *p = (struct cmd_text_pdu *) cmd->payload;
107 struct gfio_client *gc = client->client_data;
108 struct gui_entry *ge = gc->ge;
109 struct gui *ui = ge->ui;
113 char tmp[64], timebuf[80];
116 tm = localtime(&sec);
117 strftime(tmp, sizeof(tmp), "%Y-%m-%d %H:%M:%S", tm);
118 sprintf(timebuf, "%s.%03ld", tmp, p->log_usec / 1000);
122 gtk_list_store_append(ui->log_model, &iter);
123 gtk_list_store_set(ui->log_model, &iter, 0, timebuf, -1);
124 gtk_list_store_set(ui->log_model, &iter, 1, client->hostname, -1);
125 gtk_list_store_set(ui->log_model, &iter, 2, p->level, -1);
126 gtk_list_store_set(ui->log_model, &iter, 3, p->buf, -1);
128 if (p->level == FIO_LOG_ERR)
134 static void disk_util_destroy(GtkWidget *w, gpointer data)
136 struct gui_entry *ge = (struct gui_entry *) data;
138 ge->disk_util_vbox = NULL;
139 gtk_widget_destroy(w);
142 static GtkWidget *gfio_disk_util_get_vbox(struct gui_entry *ge)
144 GtkWidget *vbox, *box, *scroll, *res_notebook;
146 if (ge->disk_util_vbox)
147 return ge->disk_util_vbox;
149 scroll = get_scrolled_window(5);
150 vbox = gtk_vbox_new(FALSE, 3);
151 box = gtk_hbox_new(FALSE, 0);
152 gtk_box_pack_start(GTK_BOX(vbox), box, FALSE, FALSE, 5);
154 gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(scroll), vbox);
155 res_notebook = get_results_window(ge);
157 gtk_notebook_append_page(GTK_NOTEBOOK(res_notebook), scroll, gtk_label_new("Disk utilization"));
158 ge->disk_util_vbox = box;
159 g_signal_connect(vbox, "destroy", G_CALLBACK(disk_util_destroy), ge);
161 return ge->disk_util_vbox;
164 static int __gfio_disk_util_show(GtkWidget *res_notebook,
165 struct gfio_client *gc, struct cmd_du_pdu *p)
167 GtkWidget *box, *frame, *entry, *vbox, *util_vbox;
168 struct gui_entry *ge = gc->ge;
172 util_vbox = gfio_disk_util_get_vbox(ge);
174 vbox = gtk_vbox_new(FALSE, 3);
175 gtk_container_add(GTK_CONTAINER(util_vbox), vbox);
177 frame = gtk_frame_new((char *) p->dus.name);
178 gtk_box_pack_start(GTK_BOX(vbox), frame, FALSE, FALSE, 2);
180 box = gtk_vbox_new(FALSE, 3);
181 gtk_container_add(GTK_CONTAINER(frame), box);
183 frame = gtk_frame_new("Read");
184 gtk_box_pack_start(GTK_BOX(box), frame, FALSE, FALSE, 2);
185 vbox = gtk_hbox_new(TRUE, 3);
186 gtk_container_add(GTK_CONTAINER(frame), vbox);
187 entry = new_info_entry_in_frame(vbox, "IOs");
188 entry_set_int_value(entry, p->dus.ios[0]);
189 entry = new_info_entry_in_frame(vbox, "Merges");
190 entry_set_int_value(entry, p->dus.merges[0]);
191 entry = new_info_entry_in_frame(vbox, "Sectors");
192 entry_set_int_value(entry, p->dus.sectors[0]);
193 entry = new_info_entry_in_frame(vbox, "Ticks");
194 entry_set_int_value(entry, p->dus.ticks[0]);
196 frame = gtk_frame_new("Write");
197 gtk_box_pack_start(GTK_BOX(box), frame, FALSE, FALSE, 2);
198 vbox = gtk_hbox_new(TRUE, 3);
199 gtk_container_add(GTK_CONTAINER(frame), vbox);
200 entry = new_info_entry_in_frame(vbox, "IOs");
201 entry_set_int_value(entry, p->dus.ios[1]);
202 entry = new_info_entry_in_frame(vbox, "Merges");
203 entry_set_int_value(entry, p->dus.merges[1]);
204 entry = new_info_entry_in_frame(vbox, "Sectors");
205 entry_set_int_value(entry, p->dus.sectors[1]);
206 entry = new_info_entry_in_frame(vbox, "Ticks");
207 entry_set_int_value(entry, p->dus.ticks[1]);
209 frame = gtk_frame_new("Shared");
210 gtk_box_pack_start(GTK_BOX(box), frame, FALSE, FALSE, 2);
211 vbox = gtk_hbox_new(TRUE, 3);
212 gtk_container_add(GTK_CONTAINER(frame), vbox);
213 entry = new_info_entry_in_frame(vbox, "IO ticks");
214 entry_set_int_value(entry, p->dus.io_ticks);
215 entry = new_info_entry_in_frame(vbox, "Time in queue");
216 entry_set_int_value(entry, p->dus.time_in_queue);
220 util = (double) 100 * p->dus.io_ticks / (double) p->dus.msec;
224 sprintf(tmp, "%3.2f%%", util);
225 entry = new_info_entry_in_frame(vbox, "Disk utilization");
226 gtk_entry_set_text(GTK_ENTRY(entry), tmp);
228 gtk_widget_show_all(ge->results_window);
232 static int gfio_disk_util_show(struct gfio_client *gc)
234 struct gui_entry *ge = gc->ge;
235 GtkWidget *res_notebook;
241 res_notebook = get_results_window(ge);
243 for (i = 0; i < gc->nr_du; i++) {
244 struct cmd_du_pdu *p = &gc->du[i];
246 __gfio_disk_util_show(res_notebook, gc, p);
249 gtk_widget_show_all(ge->results_window);
253 static void gfio_disk_util_op(struct fio_client *client, struct fio_net_cmd *cmd)
255 struct cmd_du_pdu *p = (struct cmd_du_pdu *) cmd->payload;
256 struct gfio_client *gc = client->client_data;
257 struct gui_entry *ge = gc->ge;
258 unsigned int nr = gc->nr_du;
260 gc->du = realloc(gc->du, (nr + 1) * sizeof(struct cmd_du_pdu));
261 memcpy(&gc->du[nr], p, sizeof(*p));
265 if (ge->results_window)
266 __gfio_disk_util_show(ge->results_notebook, gc, p);
268 gfio_disk_util_show(gc);
272 extern int sum_stat_clients;
273 extern struct thread_stat client_ts;
274 extern struct group_run_stats client_gs;
276 static int sum_stat_nr;
278 static void gfio_thread_status_op(struct fio_client *client,
279 struct fio_net_cmd *cmd)
281 struct cmd_ts_pdu *p = (struct cmd_ts_pdu *) cmd->payload;
283 gfio_display_ts(client, &p->ts, &p->rs);
285 if (sum_stat_clients == 1)
288 sum_thread_stats(&client_ts, &p->ts, sum_stat_nr);
289 sum_group_stats(&client_gs, &p->rs);
292 client_ts.thread_number = p->ts.thread_number;
293 client_ts.groupid = p->ts.groupid;
295 if (++sum_stat_nr == sum_stat_clients) {
296 strcpy(client_ts.name, "All clients");
297 gfio_display_ts(client, &client_ts, &client_gs);
301 static void gfio_group_stats_op(struct fio_client *client,
302 struct fio_net_cmd *cmd)
304 /* We're ignoring group stats for now */
307 static void gfio_update_thread_status(struct gui_entry *ge,
308 char *status_message, double perc)
310 static char message[100];
311 const char *m = message;
313 strncpy(message, status_message, sizeof(message) - 1);
314 gtk_progress_bar_set_text(GTK_PROGRESS_BAR(ge->thread_status_pb), m);
315 gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(ge->thread_status_pb), perc / 100.0);
316 gtk_widget_queue_draw(ge->ui->window);
319 static void gfio_update_thread_status_all(struct gui *ui, char *status_message,
322 static char message[100];
323 const char *m = message;
325 strncpy(message, status_message, sizeof(message) - 1);
326 gtk_progress_bar_set_text(GTK_PROGRESS_BAR(ui->thread_status_pb), m);
327 gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(ui->thread_status_pb), perc / 100.0);
328 gtk_widget_queue_draw(ui->window);
332 * Client specific ETA
334 static void gfio_update_client_eta(struct fio_client *client, struct jobs_eta *je)
336 struct gfio_client *gc = client->client_data;
337 struct gui_entry *ge = gc->ge;
350 if (je->eta_sec != INT_MAX && je->elapsed_sec) {
351 perc = (double) je->elapsed_sec / (double) (je->elapsed_sec + je->eta_sec);
352 eta_to_str(eta_str, je->eta_sec);
355 sprintf(tmp, "%u", je->nr_running);
356 gtk_entry_set_text(GTK_ENTRY(ge->eta.jobs), tmp);
357 sprintf(tmp, "%u", je->files_open);
358 gtk_entry_set_text(GTK_ENTRY(ge->eta.files), tmp);
361 if (je->m_rate[0] || je->m_rate[1] || je->t_rate[0] || je->t_rate[1]) {
362 if (je->m_rate || je->t_rate) {
365 mr = num2str(je->m_rate, 4, 0, i2p);
366 tr = num2str(je->t_rate, 4, 0, i2p);
367 gtk_entry_set_text(GTK_ENTRY(ge->eta);
368 p += sprintf(p, ", CR=%s/%s KB/s", tr, mr);
371 } else if (je->m_iops || je->t_iops)
372 p += sprintf(p, ", CR=%d/%d IOPS", je->t_iops, je->m_iops);
374 gtk_entry_set_text(GTK_ENTRY(ge->eta.cr_bw), "---");
375 gtk_entry_set_text(GTK_ENTRY(ge->eta.cr_iops), "---");
376 gtk_entry_set_text(GTK_ENTRY(ge->eta.cw_bw), "---");
377 gtk_entry_set_text(GTK_ENTRY(ge->eta.cw_iops), "---");
380 if (je->eta_sec != INT_MAX && je->nr_running) {
384 if ((!je->eta_sec && !eta_good) || je->nr_ramp == je->nr_running)
385 strcpy(output, "-.-% done");
389 sprintf(output, "%3.1f%% done", perc);
392 rate_str[0] = num2str(je->rate[0], 5, 10, i2p);
393 rate_str[1] = num2str(je->rate[1], 5, 10, i2p);
395 iops_str[0] = num2str(je->iops[0], 4, 1, 0);
396 iops_str[1] = num2str(je->iops[1], 4, 1, 0);
398 gtk_entry_set_text(GTK_ENTRY(ge->eta.read_bw), rate_str[0]);
399 gtk_entry_set_text(GTK_ENTRY(ge->eta.read_iops), iops_str[0]);
400 gtk_entry_set_text(GTK_ENTRY(ge->eta.write_bw), rate_str[1]);
401 gtk_entry_set_text(GTK_ENTRY(ge->eta.write_iops), iops_str[1]);
403 graph_add_xy_data(ge->graphs.iops_graph, "Read IOPS", je->elapsed_sec, je->iops[0], iops_str[0]);
404 graph_add_xy_data(ge->graphs.iops_graph, "Write IOPS", je->elapsed_sec, je->iops[1], iops_str[1]);
405 graph_add_xy_data(ge->graphs.bandwidth_graph, "Read Bandwidth", je->elapsed_sec, je->rate[0], rate_str[0]);
406 graph_add_xy_data(ge->graphs.bandwidth_graph, "Write Bandwidth", je->elapsed_sec, je->rate[1], rate_str[1]);
415 char *dst = output + strlen(output);
417 sprintf(dst, " - %s", eta_str);
420 gfio_update_thread_status(ge, output, perc);
425 * Update ETA in main window for all clients
427 static void gfio_update_all_eta(struct jobs_eta *je)
429 struct gui *ui = &main_ui;
441 if (je->eta_sec != INT_MAX && je->elapsed_sec) {
442 perc = (double) je->elapsed_sec / (double) (je->elapsed_sec + je->eta_sec);
443 eta_to_str(eta_str, je->eta_sec);
447 if (je->m_rate[0] || je->m_rate[1] || je->t_rate[0] || je->t_rate[1]) {
448 if (je->m_rate || je->t_rate) {
451 mr = num2str(je->m_rate, 4, 0, i2p);
452 tr = num2str(je->t_rate, 4, 0, i2p);
453 gtk_entry_set_text(GTK_ENTRY(ui->eta);
454 p += sprintf(p, ", CR=%s/%s KB/s", tr, mr);
457 } else if (je->m_iops || je->t_iops)
458 p += sprintf(p, ", CR=%d/%d IOPS", je->t_iops, je->m_iops);
460 gtk_entry_set_text(GTK_ENTRY(ui->eta.cr_bw), "---");
461 gtk_entry_set_text(GTK_ENTRY(ui->eta.cr_iops), "---");
462 gtk_entry_set_text(GTK_ENTRY(ui->eta.cw_bw), "---");
463 gtk_entry_set_text(GTK_ENTRY(ui->eta.cw_iops), "---");
466 entry_set_int_value(ui->eta.jobs, je->nr_running);
468 if (je->eta_sec != INT_MAX && je->nr_running) {
472 if ((!je->eta_sec && !eta_good) || je->nr_ramp == je->nr_running)
473 strcpy(output, "-.-% done");
477 sprintf(output, "%3.1f%% done", perc);
480 rate_str[0] = num2str(je->rate[0], 5, 10, i2p);
481 rate_str[1] = num2str(je->rate[1], 5, 10, i2p);
483 iops_str[0] = num2str(je->iops[0], 4, 1, 0);
484 iops_str[1] = num2str(je->iops[1], 4, 1, 0);
486 gtk_entry_set_text(GTK_ENTRY(ui->eta.read_bw), rate_str[0]);
487 gtk_entry_set_text(GTK_ENTRY(ui->eta.read_iops), iops_str[0]);
488 gtk_entry_set_text(GTK_ENTRY(ui->eta.write_bw), rate_str[1]);
489 gtk_entry_set_text(GTK_ENTRY(ui->eta.write_iops), iops_str[1]);
491 graph_add_xy_data(ui->graphs.iops_graph, "Read IOPS", je->elapsed_sec, je->iops[0], iops_str[0]);
492 graph_add_xy_data(ui->graphs.iops_graph, "Write IOPS", je->elapsed_sec, je->iops[1], iops_str[1]);
493 graph_add_xy_data(ui->graphs.bandwidth_graph, "Read Bandwidth", je->elapsed_sec, je->rate[0], rate_str[0]);
494 graph_add_xy_data(ui->graphs.bandwidth_graph, "Write Bandwidth", je->elapsed_sec, je->rate[1], rate_str[1]);
503 char *dst = output + strlen(output);
505 sprintf(dst, " - %s", eta_str);
508 gfio_update_thread_status_all(ui, output, perc);
512 static void gfio_probe_op(struct fio_client *client, struct fio_net_cmd *cmd)
514 struct cmd_probe_pdu *probe = (struct cmd_probe_pdu *) cmd->payload;
515 struct gfio_client *gc = client->client_data;
516 struct gui_entry *ge = gc->ge;
517 const char *os, *arch;
520 os = fio_get_os_string(probe->os);
524 arch = fio_get_arch_string(probe->arch);
529 client->name = strdup((char *) probe->hostname);
533 gtk_label_set_text(GTK_LABEL(ge->probe.hostname), (char *) probe->hostname);
534 gtk_label_set_text(GTK_LABEL(ge->probe.os), os);
535 gtk_label_set_text(GTK_LABEL(ge->probe.arch), arch);
536 sprintf(buf, "%u.%u.%u", probe->fio_major, probe->fio_minor, probe->fio_patch);
537 gtk_label_set_text(GTK_LABEL(ge->probe.fio_ver), buf);
539 gfio_set_state(ge, GE_STATE_CONNECTED);
544 static void gfio_quit_op(struct fio_client *client, struct fio_net_cmd *cmd)
546 struct gfio_client *gc = client->client_data;
549 gfio_set_state(gc->ge, GE_STATE_NEW);
553 static void gfio_add_job_op(struct fio_client *client, struct fio_net_cmd *cmd)
555 struct cmd_add_job_pdu *p = (struct cmd_add_job_pdu *) cmd->payload;
556 struct gfio_client *gc = client->client_data;
557 struct thread_options *o = &gc->o;
558 struct gui_entry *ge = gc->ge;
559 char *c1, *c2, *c3, *c4;
562 p->thread_number = le32_to_cpu(p->thread_number);
563 p->groupid = le32_to_cpu(p->groupid);
564 convert_thread_options_to_cpu(o, &p->top);
568 gtk_label_set_text(GTK_LABEL(ge->page_label), (gchar *) o->name);
570 gtk_combo_box_append_text(GTK_COMBO_BOX(ge->eta.names), (gchar *) o->name);
571 gtk_combo_box_set_active(GTK_COMBO_BOX(ge->eta.names), 0);
573 sprintf(tmp, "%s %s", o->odirect ? "direct" : "buffered", ddir_str(o->td_ddir));
574 multitext_add_entry(&ge->eta.iotype, tmp);
576 c1 = fio_uint_to_kmg(o->min_bs[DDIR_READ]);
577 c2 = fio_uint_to_kmg(o->max_bs[DDIR_WRITE]);
578 c3 = fio_uint_to_kmg(o->min_bs[DDIR_READ]);
579 c4 = fio_uint_to_kmg(o->max_bs[DDIR_WRITE]);
580 sprintf(tmp, "%s-%s/%s-%s", c1, c2, c3, c4);
585 multitext_add_entry(&ge->eta.bs, tmp);
587 multitext_add_entry(&ge->eta.ioengine, (const char *) o->ioengine);
589 sprintf(tmp, "%u", o->iodepth);
590 multitext_add_entry(&ge->eta.iodepth, tmp);
592 multitext_set_entry(&ge->eta.iotype, 0);
593 multitext_set_entry(&ge->eta.bs, 0);
594 multitext_set_entry(&ge->eta.ioengine, 0);
595 multitext_set_entry(&ge->eta.iodepth, 0);
597 gfio_set_state(ge, GE_STATE_JOB_SENT);
602 static void gfio_client_timed_out(struct fio_client *client)
604 struct gfio_client *gc = client->client_data;
609 gfio_set_state(gc->ge, GE_STATE_NEW);
610 clear_ge_ui_info(gc->ge);
612 sprintf(buf, "Client %s: timeout talking to server.\n", client->hostname);
613 gfio_report_info(gc->ge->ui, "Network timeout", buf);
618 static void gfio_client_stop(struct fio_client *client, struct fio_net_cmd *cmd)
620 struct gfio_client *gc = client->client_data;
624 gfio_set_state(gc->ge, GE_STATE_JOB_DONE);
627 entry_set_int_value(gc->err_entry, client->error);
632 static void gfio_client_start(struct fio_client *client, struct fio_net_cmd *cmd)
634 struct gfio_client *gc = client->client_data;
637 gfio_set_state(gc->ge, GE_STATE_JOB_STARTED);
641 static void gfio_client_job_start(struct fio_client *client, struct fio_net_cmd *cmd)
643 struct gfio_client *gc = client->client_data;
646 gfio_set_state(gc->ge, GE_STATE_JOB_RUNNING);
650 static void gfio_client_iolog(struct fio_client *client, struct cmd_iolog_pdu *pdu)
652 printf("got iolog: name=%s, type=%u, entries=%u\n", pdu->name, pdu->log_type, pdu->nr_samples);
656 static void gfio_add_total_depths_tree(GtkListStore *model,
657 struct thread_stat *ts, unsigned int len)
659 double io_u_dist[FIO_IO_U_MAP_NR];
661 /* Bits 1-6, and 8 */
662 const int add_mask = 0x17e;
665 stat_calc_dist(ts->io_u_map, ts_total_io_u(ts), io_u_dist);
667 gtk_list_store_append(model, &iter);
669 gtk_list_store_set(model, &iter, 0, "Total", -1);
671 for (i = 1, j = 0; i < len; i++) {
674 if (!(add_mask & (1UL << (i - 1))))
675 sprintf(fbuf, "0.0%%");
677 sprintf(fbuf, "%3.1f%%", io_u_dist[j]);
681 gtk_list_store_set(model, &iter, i, fbuf, -1);
686 static void gfio_add_end_results(struct gfio_client *gc, struct thread_stat *ts,
687 struct group_run_stats *rs)
689 unsigned int nr = gc->nr_results;
691 gc->results = realloc(gc->results, (nr + 1) * sizeof(struct end_results));
692 memcpy(&gc->results[nr].ts, ts, sizeof(*ts));
693 memcpy(&gc->results[nr].gs, rs, sizeof(*rs));
697 static void gfio_add_sc_depths_tree(GtkListStore *model,
698 struct thread_stat *ts, unsigned int len,
701 double io_u_dist[FIO_IO_U_MAP_NR];
703 /* Bits 0, and 3-8 */
704 const int add_mask = 0x1f9;
708 stat_calc_dist(ts->io_u_submit, ts->total_submit, io_u_dist);
710 stat_calc_dist(ts->io_u_complete, ts->total_complete, io_u_dist);
712 gtk_list_store_append(model, &iter);
714 gtk_list_store_set(model, &iter, 0, submit ? "Submit" : "Complete", -1);
716 for (i = 1, j = 0; i < len; i++) {
719 if (!(add_mask & (1UL << (i - 1))))
720 sprintf(fbuf, "0.0%%");
722 sprintf(fbuf, "%3.1f%%", io_u_dist[j]);
726 gtk_list_store_set(model, &iter, i, fbuf, -1);
731 static void gfio_show_io_depths(GtkWidget *vbox, struct thread_stat *ts)
733 GtkWidget *frame, *box, *tree_view = NULL;
734 GtkTreeSelection *selection;
736 GType types[FIO_IO_U_MAP_NR + 1];
738 const char *labels[] = { "Depth", "0", "1", "2", "4", "8", "16", "32", "64", ">= 64" };
739 const int nr_labels = ARRAY_SIZE(labels);
741 frame = gtk_frame_new("IO depths");
742 gtk_box_pack_start(GTK_BOX(vbox), frame, FALSE, FALSE, 5);
744 box = gtk_hbox_new(FALSE, 3);
745 gtk_container_add(GTK_CONTAINER(frame), box);
747 for (i = 0; i < nr_labels; i++)
748 types[i] = G_TYPE_STRING;
750 model = gtk_list_store_newv(nr_labels, types);
752 tree_view = gtk_tree_view_new_with_model(GTK_TREE_MODEL(model));
753 gtk_widget_set_can_focus(tree_view, FALSE);
755 g_object_set(G_OBJECT(tree_view), "headers-visible", TRUE,
756 "enable-grid-lines", GTK_TREE_VIEW_GRID_LINES_BOTH, NULL);
758 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(tree_view));
759 gtk_tree_selection_set_mode(GTK_TREE_SELECTION(selection), GTK_SELECTION_BROWSE);
761 for (i = 0; i < nr_labels; i++)
762 tree_view_column(tree_view, i, labels[i], ALIGN_RIGHT | UNSORTABLE);
764 gfio_add_total_depths_tree(model, ts, nr_labels);
765 gfio_add_sc_depths_tree(model, ts, nr_labels, 1);
766 gfio_add_sc_depths_tree(model, ts, nr_labels, 0);
768 gtk_box_pack_start(GTK_BOX(box), tree_view, TRUE, FALSE, 3);
771 static void gfio_show_cpu_usage(GtkWidget *vbox, struct thread_stat *ts)
773 GtkWidget *box, *frame, *entry;
774 double usr_cpu, sys_cpu;
775 unsigned long runtime;
778 runtime = ts->total_run_time;
780 double runt = (double) runtime;
782 usr_cpu = (double) ts->usr_time * 100 / runt;
783 sys_cpu = (double) ts->sys_time * 100 / runt;
789 frame = gtk_frame_new("OS resources");
790 gtk_box_pack_start(GTK_BOX(vbox), frame, FALSE, FALSE, 5);
792 box = gtk_hbox_new(FALSE, 3);
793 gtk_container_add(GTK_CONTAINER(frame), box);
795 entry = new_info_entry_in_frame(box, "User CPU");
796 sprintf(tmp, "%3.2f%%", usr_cpu);
797 gtk_entry_set_text(GTK_ENTRY(entry), tmp);
798 entry = new_info_entry_in_frame(box, "System CPU");
799 sprintf(tmp, "%3.2f%%", sys_cpu);
800 gtk_entry_set_text(GTK_ENTRY(entry), tmp);
801 entry = new_info_entry_in_frame(box, "Context switches");
802 entry_set_int_value(entry, ts->ctx);
803 entry = new_info_entry_in_frame(box, "Major faults");
804 entry_set_int_value(entry, ts->majf);
805 entry = new_info_entry_in_frame(box, "Minor faults");
806 entry_set_int_value(entry, ts->minf);
809 static GtkWidget *gfio_output_lat_buckets(double *lat, const char **labels,
812 GtkWidget *tree_view;
813 GtkTreeSelection *selection;
819 types = malloc(num * sizeof(GType));
821 for (i = 0; i < num; i++)
822 types[i] = G_TYPE_STRING;
824 model = gtk_list_store_newv(num, types);
828 tree_view = gtk_tree_view_new_with_model(GTK_TREE_MODEL(model));
829 gtk_widget_set_can_focus(tree_view, FALSE);
831 g_object_set(G_OBJECT(tree_view), "headers-visible", TRUE,
832 "enable-grid-lines", GTK_TREE_VIEW_GRID_LINES_BOTH, NULL);
834 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(tree_view));
835 gtk_tree_selection_set_mode(GTK_TREE_SELECTION(selection), GTK_SELECTION_BROWSE);
837 for (i = 0; i < num; i++)
838 tree_view_column(tree_view, i, labels[i], ALIGN_RIGHT | UNSORTABLE);
840 gtk_list_store_append(model, &iter);
842 for (i = 0; i < num; i++) {
846 sprintf(fbuf, "0.00");
848 sprintf(fbuf, "%3.2f%%", lat[i]);
850 gtk_list_store_set(model, &iter, i, fbuf, -1);
856 static struct graph *setup_lat_bucket_graph(const char *title, double *lat,
859 double xdim, double ydim)
864 g = graph_new(xdim, ydim, gfio_graph_font);
865 graph_title(g, title);
866 graph_x_title(g, "Buckets");
867 graph_y_title(g, "Percent");
869 for (i = 0; i < len; i++) {
870 graph_add_label(g, labels[i]);
871 graph_add_data(g, labels[i], lat[i]);
877 static int on_expose_lat_drawing_area(GtkWidget *w, GdkEvent *event, gpointer p)
882 cr = gdk_cairo_create(w->window);
884 if (graph_has_tooltips(g)) {
885 g_object_set(w, "has-tooltip", TRUE, NULL);
886 g_signal_connect(w, "query-tooltip", G_CALLBACK(clat_graph_tooltip), g);
889 cairo_set_source_rgb(cr, 0, 0, 0);
890 bar_graph_draw(g, cr);
896 static gint on_config_lat_drawing_area(GtkWidget *w, GdkEventConfigure *event,
899 struct graph *g = data;
901 graph_set_size(g, w->allocation.width, w->allocation.height);
902 graph_set_size(g, w->allocation.width, w->allocation.height);
903 graph_set_position(g, 0, 0);
907 static void gfio_show_latency_buckets(struct gfio_client *gc, GtkWidget *vbox,
908 struct thread_stat *ts)
910 double io_u_lat[FIO_IO_U_LAT_U_NR + FIO_IO_U_LAT_M_NR];
911 const char *ranges[] = { "2u", "4u", "10u", "20u", "50u", "100u",
912 "250u", "500u", "750u", "1m", "2m",
913 "4m", "10m", "20m", "50m", "100m",
914 "250m", "500m", "750m", "1s", "2s", ">= 2s" };
916 const int total = FIO_IO_U_LAT_U_NR + FIO_IO_U_LAT_M_NR;
917 GtkWidget *frame, *tree_view, *hbox, *completion_vbox, *drawing_area;
918 struct gui_entry *ge = gc->ge;
920 stat_calc_lat_u(ts, io_u_lat);
921 stat_calc_lat_m(ts, &io_u_lat[FIO_IO_U_LAT_U_NR]);
924 * Found out which first bucket has entries, and which last bucket
927 for (i = 0; i < total; i++) {
928 if (io_u_lat[i] == 0.00)
942 tree_view = gfio_output_lat_buckets(&io_u_lat[start], &ranges[start], end - start + 1);
943 ge->lat_bucket_graph = setup_lat_bucket_graph("Latency Buckets", &io_u_lat[start], &ranges[start], end - start + 1, 700.0, 300.0);
945 frame = gtk_frame_new("Latency buckets");
946 gtk_box_pack_start(GTK_BOX(vbox), frame, FALSE, FALSE, 5);
948 completion_vbox = gtk_vbox_new(FALSE, 3);
949 gtk_container_add(GTK_CONTAINER(frame), completion_vbox);
950 hbox = gtk_hbox_new(FALSE, 3);
951 gtk_container_add(GTK_CONTAINER(completion_vbox), hbox);
953 drawing_area = gtk_drawing_area_new();
954 gtk_widget_set_size_request(GTK_WIDGET(drawing_area), 700, 300);
955 gtk_widget_modify_bg(drawing_area, GTK_STATE_NORMAL, &gfio_color_white);
956 gtk_container_add(GTK_CONTAINER(completion_vbox), drawing_area);
957 g_signal_connect(G_OBJECT(drawing_area), "expose_event", G_CALLBACK(on_expose_lat_drawing_area), ge->lat_bucket_graph);
958 g_signal_connect(G_OBJECT(drawing_area), "configure_event", G_CALLBACK(on_config_lat_drawing_area), ge->lat_bucket_graph);
960 gtk_box_pack_start(GTK_BOX(hbox), tree_view, TRUE, FALSE, 3);
963 static void gfio_show_lat(GtkWidget *vbox, const char *name, unsigned long min,
964 unsigned long max, double mean, double dev)
966 const char *base = "(usec)";
967 GtkWidget *hbox, *label, *frame;
971 if (!usec_to_msec(&min, &max, &mean, &dev))
974 minp = num2str(min, 6, 1, 0);
975 maxp = num2str(max, 6, 1, 0);
977 sprintf(tmp, "%s %s", name, base);
978 frame = gtk_frame_new(tmp);
979 gtk_box_pack_start(GTK_BOX(vbox), frame, FALSE, FALSE, 5);
981 hbox = gtk_hbox_new(FALSE, 3);
982 gtk_container_add(GTK_CONTAINER(frame), hbox);
984 label = new_info_label_in_frame(hbox, "Minimum");
985 gtk_label_set_text(GTK_LABEL(label), minp);
986 label = new_info_label_in_frame(hbox, "Maximum");
987 gtk_label_set_text(GTK_LABEL(label), maxp);
988 label = new_info_label_in_frame(hbox, "Average");
989 sprintf(tmp, "%5.02f", mean);
990 gtk_label_set_text(GTK_LABEL(label), tmp);
991 label = new_info_label_in_frame(hbox, "Standard deviation");
992 sprintf(tmp, "%5.02f", dev);
993 gtk_label_set_text(GTK_LABEL(label), tmp);
999 static GtkWidget *gfio_output_clat_percentiles(unsigned int *ovals,
1005 GType types[FIO_IO_U_LIST_MAX_LEN];
1006 GtkWidget *tree_view;
1007 GtkTreeSelection *selection;
1008 GtkListStore *model;
1012 for (i = 0; i < len; i++)
1013 types[i] = G_TYPE_INT;
1015 model = gtk_list_store_newv(len, types);
1017 tree_view = gtk_tree_view_new_with_model(GTK_TREE_MODEL(model));
1018 gtk_widget_set_can_focus(tree_view, FALSE);
1020 g_object_set(G_OBJECT(tree_view), "headers-visible", TRUE,
1021 "enable-grid-lines", GTK_TREE_VIEW_GRID_LINES_BOTH, NULL);
1023 selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(tree_view));
1024 gtk_tree_selection_set_mode(GTK_TREE_SELECTION(selection), GTK_SELECTION_BROWSE);
1026 for (i = 0; i < len; i++) {
1029 sprintf(fbuf, "%2.2f%%", plist[i].u.f);
1030 tree_view_column(tree_view, i, fbuf, ALIGN_RIGHT | UNSORTABLE);
1033 gtk_list_store_append(model, &iter);
1035 for (i = 0; i < len; i++) {
1037 ovals[i] = (ovals[i] + 999) / 1000;
1038 gtk_list_store_set(model, &iter, i, ovals[i], -1);
1044 static struct graph *setup_clat_graph(char *title, unsigned int *ovals,
1047 double xdim, double ydim)
1052 g = graph_new(xdim, ydim, gfio_graph_font);
1053 graph_title(g, title);
1054 graph_x_title(g, "Percentile");
1055 graph_y_title(g, "Time");
1057 for (i = 0; i < len; i++) {
1060 sprintf(fbuf, "%2.2f%%", plist[i].u.f);
1061 graph_add_label(g, fbuf);
1062 graph_add_data(g, fbuf, (double) ovals[i]);
1068 static void gfio_show_clat_percentiles(struct gfio_client *gc,
1069 GtkWidget *vbox, struct thread_stat *ts,
1072 unsigned int *io_u_plat = ts->io_u_plat[ddir];
1073 unsigned long nr = ts->clat_stat[ddir].samples;
1074 fio_fp64_t *plist = ts->percentile_list;
1075 unsigned int *ovals, len, minv, maxv, scale_down;
1077 GtkWidget *tree_view, *frame, *hbox, *drawing_area, *completion_vbox;
1078 struct gui_entry *ge = gc->ge;
1081 len = calc_clat_percentiles(io_u_plat, nr, plist, &ovals, &maxv, &minv);
1086 * We default to usecs, but if the value range is such that we
1087 * should scale down to msecs, do that.
1089 if (minv > 2000 && maxv > 99999) {
1097 sprintf(tmp, "Completion percentiles (%s)", base);
1098 tree_view = gfio_output_clat_percentiles(ovals, plist, len, base, scale_down);
1099 ge->clat_graph = setup_clat_graph(tmp, ovals, plist, len, 700.0, 300.0);
1101 frame = gtk_frame_new(tmp);
1102 gtk_box_pack_start(GTK_BOX(vbox), frame, FALSE, FALSE, 5);
1104 completion_vbox = gtk_vbox_new(FALSE, 3);
1105 gtk_container_add(GTK_CONTAINER(frame), completion_vbox);
1106 hbox = gtk_hbox_new(FALSE, 3);
1107 gtk_container_add(GTK_CONTAINER(completion_vbox), hbox);
1108 drawing_area = gtk_drawing_area_new();
1109 gtk_widget_set_size_request(GTK_WIDGET(drawing_area), 700, 300);
1110 gtk_widget_modify_bg(drawing_area, GTK_STATE_NORMAL, &gfio_color_white);
1111 gtk_container_add(GTK_CONTAINER(completion_vbox), drawing_area);
1112 g_signal_connect(G_OBJECT(drawing_area), "expose_event", G_CALLBACK(on_expose_lat_drawing_area), ge->clat_graph);
1113 g_signal_connect(G_OBJECT(drawing_area), "configure_event", G_CALLBACK(on_config_lat_drawing_area), ge->clat_graph);
1115 gtk_box_pack_start(GTK_BOX(hbox), tree_view, TRUE, FALSE, 3);
1125 static void gfio_show_ddir_status(struct gfio_client *gc, GtkWidget *mbox,
1126 struct group_run_stats *rs,
1127 struct thread_stat *ts, int ddir)
1129 const char *ddir_label[2] = { "Read", "Write" };
1130 GtkWidget *frame, *label, *box, *vbox, *main_vbox;
1131 unsigned long min[3], max[3], runt;
1132 unsigned long long bw, iops;
1133 unsigned int flags = 0;
1134 double mean[3], dev[3];
1135 char *io_p, *bw_p, *iops_p;
1138 if (!ts->runtime[ddir])
1141 i2p = is_power_of_2(rs->kb_base);
1142 runt = ts->runtime[ddir];
1144 bw = (1000 * ts->io_bytes[ddir]) / runt;
1145 io_p = num2str(ts->io_bytes[ddir], 6, 1, i2p);
1146 bw_p = num2str(bw, 6, 1, i2p);
1148 iops = (1000 * (uint64_t)ts->total_io_u[ddir]) / runt;
1149 iops_p = num2str(iops, 6, 1, 0);
1151 box = gtk_hbox_new(FALSE, 3);
1152 gtk_box_pack_start(GTK_BOX(mbox), box, TRUE, FALSE, 3);
1154 frame = gtk_frame_new(ddir_label[ddir]);
1155 gtk_box_pack_start(GTK_BOX(box), frame, FALSE, FALSE, 5);
1157 main_vbox = gtk_vbox_new(FALSE, 3);
1158 gtk_container_add(GTK_CONTAINER(frame), main_vbox);
1160 box = gtk_hbox_new(FALSE, 3);
1161 gtk_box_pack_start(GTK_BOX(main_vbox), box, TRUE, FALSE, 3);
1163 label = new_info_label_in_frame(box, "IO");
1164 gtk_label_set_text(GTK_LABEL(label), io_p);
1165 label = new_info_label_in_frame(box, "Bandwidth");
1166 gtk_label_set_text(GTK_LABEL(label), bw_p);
1167 label = new_info_label_in_frame(box, "IOPS");
1168 gtk_label_set_text(GTK_LABEL(label), iops_p);
1169 label = new_info_label_in_frame(box, "Runtime (msec)");
1170 label_set_int_value(label, ts->runtime[ddir]);
1172 if (calc_lat(&ts->bw_stat[ddir], &min[0], &max[0], &mean[0], &dev[0])) {
1173 double p_of_agg = 100.0;
1174 const char *bw_str = "KB";
1177 if (rs->agg[ddir]) {
1178 p_of_agg = mean[0] * 100 / (double) rs->agg[ddir];
1179 if (p_of_agg > 100.0)
1183 if (mean[0] > 999999.9) {
1191 sprintf(tmp, "Bandwidth (%s)", bw_str);
1192 frame = gtk_frame_new(tmp);
1193 gtk_box_pack_start(GTK_BOX(main_vbox), frame, FALSE, FALSE, 5);
1195 box = gtk_hbox_new(FALSE, 3);
1196 gtk_container_add(GTK_CONTAINER(frame), box);
1198 label = new_info_label_in_frame(box, "Minimum");
1199 label_set_int_value(label, min[0]);
1200 label = new_info_label_in_frame(box, "Maximum");
1201 label_set_int_value(label, max[0]);
1202 label = new_info_label_in_frame(box, "Percentage of jobs");
1203 sprintf(tmp, "%3.2f%%", p_of_agg);
1204 gtk_label_set_text(GTK_LABEL(label), tmp);
1205 label = new_info_label_in_frame(box, "Average");
1206 sprintf(tmp, "%5.02f", mean[0]);
1207 gtk_label_set_text(GTK_LABEL(label), tmp);
1208 label = new_info_label_in_frame(box, "Standard deviation");
1209 sprintf(tmp, "%5.02f", dev[0]);
1210 gtk_label_set_text(GTK_LABEL(label), tmp);
1213 if (calc_lat(&ts->slat_stat[ddir], &min[0], &max[0], &mean[0], &dev[0]))
1215 if (calc_lat(&ts->clat_stat[ddir], &min[1], &max[1], &mean[1], &dev[1]))
1217 if (calc_lat(&ts->lat_stat[ddir], &min[2], &max[2], &mean[2], &dev[2]))
1221 frame = gtk_frame_new("Latency");
1222 gtk_box_pack_start(GTK_BOX(main_vbox), frame, FALSE, FALSE, 5);
1224 vbox = gtk_vbox_new(FALSE, 3);
1225 gtk_container_add(GTK_CONTAINER(frame), vbox);
1227 if (flags & GFIO_SLAT)
1228 gfio_show_lat(vbox, "Submission latency", min[0], max[0], mean[0], dev[0]);
1229 if (flags & GFIO_CLAT)
1230 gfio_show_lat(vbox, "Completion latency", min[1], max[1], mean[1], dev[1]);
1231 if (flags & GFIO_LAT)
1232 gfio_show_lat(vbox, "Total latency", min[2], max[2], mean[2], dev[2]);
1235 if (ts->clat_percentiles)
1236 gfio_show_clat_percentiles(gc, main_vbox, ts, ddir);
1243 static void __gfio_display_end_results(GtkWidget *win, struct gfio_client *gc,
1244 struct thread_stat *ts,
1245 struct group_run_stats *rs)
1247 GtkWidget *box, *vbox, *entry, *scroll;
1249 scroll = gtk_scrolled_window_new(NULL, NULL);
1250 gtk_container_set_border_width(GTK_CONTAINER(scroll), 5);
1251 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scroll), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
1253 vbox = gtk_vbox_new(FALSE, 3);
1255 box = gtk_hbox_new(FALSE, 0);
1256 gtk_box_pack_start(GTK_BOX(vbox), box, TRUE, FALSE, 5);
1258 gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(scroll), vbox);
1260 gtk_notebook_append_page(GTK_NOTEBOOK(win), scroll, gtk_label_new(ts->name));
1262 entry = new_info_entry_in_frame(box, "Name");
1263 gtk_entry_set_text(GTK_ENTRY(entry), ts->name);
1264 if (strlen(ts->description)) {
1265 entry = new_info_entry_in_frame(box, "Description");
1266 gtk_entry_set_text(GTK_ENTRY(entry), ts->description);
1268 entry = new_info_entry_in_frame(box, "Group ID");
1269 entry_set_int_value(entry, ts->groupid);
1270 entry = new_info_entry_in_frame(box, "Jobs");
1271 entry_set_int_value(entry, ts->members);
1272 gc->err_entry = entry = new_info_entry_in_frame(box, "Error");
1273 entry_set_int_value(entry, ts->error);
1274 entry = new_info_entry_in_frame(box, "PID");
1275 entry_set_int_value(entry, ts->pid);
1277 if (ts->io_bytes[DDIR_READ])
1278 gfio_show_ddir_status(gc, vbox, rs, ts, DDIR_READ);
1279 if (ts->io_bytes[DDIR_WRITE])
1280 gfio_show_ddir_status(gc, vbox, rs, ts, DDIR_WRITE);
1282 gfio_show_latency_buckets(gc, vbox, ts);
1283 gfio_show_cpu_usage(vbox, ts);
1284 gfio_show_io_depths(vbox, ts);
1287 void gfio_display_end_results(struct gfio_client *gc)
1289 struct gui_entry *ge = gc->ge;
1290 GtkWidget *res_notebook;
1293 res_notebook = get_results_window(ge);
1295 for (i = 0; i < gc->nr_results; i++) {
1296 struct end_results *e = &gc->results[i];
1298 __gfio_display_end_results(res_notebook, gc, &e->ts, &e->gs);
1301 if (gfio_disk_util_show(gc))
1302 gtk_widget_show_all(ge->results_window);
1305 static void gfio_display_ts(struct fio_client *client, struct thread_stat *ts,
1306 struct group_run_stats *rs)
1308 struct gfio_client *gc = client->client_data;
1309 struct gui_entry *ge = gc->ge;
1311 gfio_add_end_results(gc, ts, rs);
1313 gdk_threads_enter();
1314 if (ge->results_window)
1315 __gfio_display_end_results(ge->results_notebook, gc, ts, rs);
1317 gfio_display_end_results(gc);
1318 gdk_threads_leave();
1321 static void gfio_client_removed(struct fio_client *client)
1323 struct gfio_client *gc = client->client_data;
1325 assert(gc->client == client);
1326 fio_put_client(gc->client);
1330 struct client_ops gfio_client_ops = {
1331 .text = gfio_text_op,
1332 .disk_util = gfio_disk_util_op,
1333 .thread_status = gfio_thread_status_op,
1334 .group_stats = gfio_group_stats_op,
1335 .jobs_eta = gfio_update_client_eta,
1336 .eta = gfio_update_all_eta,
1337 .probe = gfio_probe_op,
1338 .quit = gfio_quit_op,
1339 .add_job = gfio_add_job_op,
1340 .timed_out = gfio_client_timed_out,
1341 .stop = gfio_client_stop,
1342 .start = gfio_client_start,
1343 .job_start = gfio_client_job_start,
1344 .iolog = gfio_client_iolog,
1345 .removed = gfio_client_removed,
1346 .eta_msec = FIO_CLIENT_DEF_ETA_MSEC,
1347 .stay_connected = 1,
1348 .client_type = FIO_CLIENT_TYPE_GUI,