Commit | Line | Data |
---|---|---|
1252d8f2 JA |
1 | #include <malloc.h> |
2 | #include <string.h> | |
3 | ||
4 | #include <glib.h> | |
5 | #include <cairo.h> | |
6 | #include <gtk/gtk.h> | |
7 | ||
8 | #include "fio.h" | |
9 | #include "gfio.h" | |
10 | #include "ghelpers.h" | |
11 | #include "goptions.h" | |
12 | #include "gerror.h" | |
13 | #include "graph.h" | |
14 | #include "gclient.h" | |
bf3f7027 | 15 | #include "printing.h" |
1252d8f2 JA |
16 | |
17 | static void gfio_display_ts(struct fio_client *client, struct thread_stat *ts, | |
18 | struct group_run_stats *rs); | |
19 | ||
20 | static gboolean results_window_delete(GtkWidget *w, gpointer data) | |
21 | { | |
22 | struct gui_entry *ge = (struct gui_entry *) data; | |
23 | ||
24 | gtk_widget_destroy(w); | |
25 | ge->results_window = NULL; | |
26 | ge->results_notebook = NULL; | |
27 | return TRUE; | |
28 | } | |
29 | ||
30 | static void results_close(GtkWidget *w, gpointer *data) | |
31 | { | |
32 | struct gui_entry *ge = (struct gui_entry *) data; | |
33 | ||
34 | gtk_widget_destroy(ge->results_window); | |
35 | } | |
36 | ||
bf3f7027 SC |
37 | static void results_print(GtkWidget *w, gpointer *data) |
38 | { | |
39 | struct gui_entry *ge = (struct gui_entry *) data; | |
40 | ||
41 | gfio_print_results(ge); | |
42 | } | |
43 | ||
1252d8f2 JA |
44 | static GtkActionEntry results_menu_items[] = { |
45 | { "FileMenuAction", GTK_STOCK_FILE, "File", NULL, NULL, NULL}, | |
46 | { "GraphMenuAction", GTK_STOCK_FILE, "Graph", NULL, NULL, NULL}, | |
bf3f7027 | 47 | { "PrintFile", GTK_STOCK_PRINT, "Print", "<Control>P", NULL, G_CALLBACK(results_print) }, |
1252d8f2 JA |
48 | { "CloseFile", GTK_STOCK_CLOSE, "Close", "<Control>W", NULL, G_CALLBACK(results_close) }, |
49 | }; | |
50 | static gint results_nmenu_items = sizeof(results_menu_items) / sizeof(results_menu_items[0]); | |
51 | ||
52 | static const gchar *results_ui_string = " \ | |
53 | <ui> \ | |
54 | <menubar name=\"MainMenu\"> \ | |
55 | <menu name=\"FileMenu\" action=\"FileMenuAction\"> \ | |
bf3f7027 | 56 | <menuitem name=\"Print\" action=\"PrintFile\" /> \ |
1252d8f2 JA |
57 | <menuitem name=\"Close\" action=\"CloseFile\" /> \ |
58 | </menu> \ | |
59 | <menu name=\"GraphMenu\" action=\"GraphMenuAction\"> \ | |
60 | </menu>\ | |
61 | </menubar> \ | |
62 | </ui> \ | |
63 | "; | |
64 | ||
65 | static GtkWidget *get_results_menubar(GtkWidget *window, struct gui_entry *ge) | |
66 | { | |
67 | GtkActionGroup *action_group; | |
68 | GtkWidget *widget; | |
69 | GError *error = 0; | |
70 | ||
71 | ge->results_uimanager = gtk_ui_manager_new(); | |
72 | ||
73 | action_group = gtk_action_group_new("ResultsMenu"); | |
74 | gtk_action_group_add_actions(action_group, results_menu_items, results_nmenu_items, ge); | |
75 | ||
76 | gtk_ui_manager_insert_action_group(ge->results_uimanager, action_group, 0); | |
77 | gtk_ui_manager_add_ui_from_string(GTK_UI_MANAGER(ge->results_uimanager), results_ui_string, -1, &error); | |
78 | ||
79 | gtk_window_add_accel_group(GTK_WINDOW(window), gtk_ui_manager_get_accel_group(ge->results_uimanager)); | |
80 | ||
81 | widget = gtk_ui_manager_get_widget(ge->results_uimanager, "/MainMenu"); | |
82 | return widget; | |
83 | } | |
84 | ||
85 | static GtkWidget *get_results_window(struct gui_entry *ge) | |
86 | { | |
87 | GtkWidget *win, *notebook, *vbox; | |
88 | ||
89 | if (ge->results_window) | |
90 | return ge->results_notebook; | |
91 | ||
92 | win = gtk_window_new(GTK_WINDOW_TOPLEVEL); | |
93 | gtk_window_set_title(GTK_WINDOW(win), "Results"); | |
94 | gtk_window_set_default_size(GTK_WINDOW(win), 1024, 768); | |
95 | g_signal_connect(win, "delete-event", G_CALLBACK(results_window_delete), ge); | |
96 | g_signal_connect(win, "destroy", G_CALLBACK(results_window_delete), ge); | |
97 | ||
98 | vbox = gtk_vbox_new(FALSE, 0); | |
99 | gtk_container_add(GTK_CONTAINER(win), vbox); | |
100 | ||
101 | ge->results_menu = get_results_menubar(win, ge); | |
102 | gtk_box_pack_start(GTK_BOX(vbox), ge->results_menu, FALSE, FALSE, 0); | |
103 | ||
104 | notebook = gtk_notebook_new(); | |
105 | gtk_notebook_set_scrollable(GTK_NOTEBOOK(notebook), 1); | |
106 | gtk_notebook_popup_enable(GTK_NOTEBOOK(notebook)); | |
107 | gtk_container_add(GTK_CONTAINER(vbox), notebook); | |
108 | ||
109 | ge->results_window = win; | |
110 | ge->results_notebook = notebook; | |
111 | return ge->results_notebook; | |
112 | } | |
113 | ||
114 | static void gfio_text_op(struct fio_client *client, struct fio_net_cmd *cmd) | |
115 | { | |
116 | struct cmd_text_pdu *p = (struct cmd_text_pdu *) cmd->payload; | |
117 | struct gfio_client *gc = client->client_data; | |
118 | struct gui_entry *ge = gc->ge; | |
119 | struct gui *ui = ge->ui; | |
120 | GtkTreeIter iter; | |
121 | struct tm *tm; | |
122 | time_t sec; | |
123 | char tmp[64], timebuf[80]; | |
124 | ||
125 | sec = p->log_sec; | |
126 | tm = localtime(&sec); | |
127 | strftime(tmp, sizeof(tmp), "%Y-%m-%d %H:%M:%S", tm); | |
1fae4855 | 128 | sprintf(timebuf, "%s.%03ld", tmp, (long) p->log_usec / 1000); |
1252d8f2 JA |
129 | |
130 | gdk_threads_enter(); | |
131 | ||
132 | gtk_list_store_append(ui->log_model, &iter); | |
133 | gtk_list_store_set(ui->log_model, &iter, 0, timebuf, -1); | |
134 | gtk_list_store_set(ui->log_model, &iter, 1, client->hostname, -1); | |
3ad04399 | 135 | gtk_list_store_set(ui->log_model, &iter, 2, log_get_level(p->level), -1); |
1252d8f2 JA |
136 | gtk_list_store_set(ui->log_model, &iter, 3, p->buf, -1); |
137 | ||
138 | if (p->level == FIO_LOG_ERR) | |
139 | gfio_view_log(ui); | |
140 | ||
141 | gdk_threads_leave(); | |
142 | } | |
143 | ||
144 | static void disk_util_destroy(GtkWidget *w, gpointer data) | |
145 | { | |
146 | struct gui_entry *ge = (struct gui_entry *) data; | |
147 | ||
148 | ge->disk_util_vbox = NULL; | |
149 | gtk_widget_destroy(w); | |
150 | } | |
151 | ||
152 | static GtkWidget *gfio_disk_util_get_vbox(struct gui_entry *ge) | |
153 | { | |
154 | GtkWidget *vbox, *box, *scroll, *res_notebook; | |
155 | ||
156 | if (ge->disk_util_vbox) | |
157 | return ge->disk_util_vbox; | |
158 | ||
159 | scroll = get_scrolled_window(5); | |
160 | vbox = gtk_vbox_new(FALSE, 3); | |
161 | box = gtk_hbox_new(FALSE, 0); | |
162 | gtk_box_pack_start(GTK_BOX(vbox), box, FALSE, FALSE, 5); | |
163 | ||
164 | gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(scroll), vbox); | |
165 | res_notebook = get_results_window(ge); | |
166 | ||
167 | gtk_notebook_append_page(GTK_NOTEBOOK(res_notebook), scroll, gtk_label_new("Disk utilization")); | |
168 | ge->disk_util_vbox = box; | |
169 | g_signal_connect(vbox, "destroy", G_CALLBACK(disk_util_destroy), ge); | |
170 | ||
171 | return ge->disk_util_vbox; | |
172 | } | |
173 | ||
174 | static int __gfio_disk_util_show(GtkWidget *res_notebook, | |
175 | struct gfio_client *gc, struct cmd_du_pdu *p) | |
176 | { | |
177 | GtkWidget *box, *frame, *entry, *vbox, *util_vbox; | |
178 | struct gui_entry *ge = gc->ge; | |
179 | double util; | |
180 | char tmp[16]; | |
181 | ||
182 | util_vbox = gfio_disk_util_get_vbox(ge); | |
183 | ||
184 | vbox = gtk_vbox_new(FALSE, 3); | |
185 | gtk_container_add(GTK_CONTAINER(util_vbox), vbox); | |
186 | ||
187 | frame = gtk_frame_new((char *) p->dus.name); | |
188 | gtk_box_pack_start(GTK_BOX(vbox), frame, FALSE, FALSE, 2); | |
189 | ||
190 | box = gtk_vbox_new(FALSE, 3); | |
191 | gtk_container_add(GTK_CONTAINER(frame), box); | |
192 | ||
193 | frame = gtk_frame_new("Read"); | |
194 | gtk_box_pack_start(GTK_BOX(box), frame, FALSE, FALSE, 2); | |
195 | vbox = gtk_hbox_new(TRUE, 3); | |
196 | gtk_container_add(GTK_CONTAINER(frame), vbox); | |
197 | entry = new_info_entry_in_frame(vbox, "IOs"); | |
198 | entry_set_int_value(entry, p->dus.ios[0]); | |
199 | entry = new_info_entry_in_frame(vbox, "Merges"); | |
200 | entry_set_int_value(entry, p->dus.merges[0]); | |
201 | entry = new_info_entry_in_frame(vbox, "Sectors"); | |
202 | entry_set_int_value(entry, p->dus.sectors[0]); | |
203 | entry = new_info_entry_in_frame(vbox, "Ticks"); | |
204 | entry_set_int_value(entry, p->dus.ticks[0]); | |
205 | ||
206 | frame = gtk_frame_new("Write"); | |
207 | gtk_box_pack_start(GTK_BOX(box), frame, FALSE, FALSE, 2); | |
208 | vbox = gtk_hbox_new(TRUE, 3); | |
209 | gtk_container_add(GTK_CONTAINER(frame), vbox); | |
210 | entry = new_info_entry_in_frame(vbox, "IOs"); | |
211 | entry_set_int_value(entry, p->dus.ios[1]); | |
212 | entry = new_info_entry_in_frame(vbox, "Merges"); | |
213 | entry_set_int_value(entry, p->dus.merges[1]); | |
214 | entry = new_info_entry_in_frame(vbox, "Sectors"); | |
215 | entry_set_int_value(entry, p->dus.sectors[1]); | |
216 | entry = new_info_entry_in_frame(vbox, "Ticks"); | |
217 | entry_set_int_value(entry, p->dus.ticks[1]); | |
218 | ||
219 | frame = gtk_frame_new("Shared"); | |
220 | gtk_box_pack_start(GTK_BOX(box), frame, FALSE, FALSE, 2); | |
221 | vbox = gtk_hbox_new(TRUE, 3); | |
222 | gtk_container_add(GTK_CONTAINER(frame), vbox); | |
223 | entry = new_info_entry_in_frame(vbox, "IO ticks"); | |
224 | entry_set_int_value(entry, p->dus.io_ticks); | |
225 | entry = new_info_entry_in_frame(vbox, "Time in queue"); | |
226 | entry_set_int_value(entry, p->dus.time_in_queue); | |
227 | ||
228 | util = 0.0; | |
229 | if (p->dus.msec) | |
230 | util = (double) 100 * p->dus.io_ticks / (double) p->dus.msec; | |
231 | if (util > 100.0) | |
232 | util = 100.0; | |
233 | ||
234 | sprintf(tmp, "%3.2f%%", util); | |
235 | entry = new_info_entry_in_frame(vbox, "Disk utilization"); | |
236 | gtk_entry_set_text(GTK_ENTRY(entry), tmp); | |
237 | ||
238 | gtk_widget_show_all(ge->results_window); | |
239 | return 0; | |
240 | } | |
241 | ||
242 | static int gfio_disk_util_show(struct gfio_client *gc) | |
243 | { | |
244 | struct gui_entry *ge = gc->ge; | |
245 | GtkWidget *res_notebook; | |
246 | int i; | |
247 | ||
248 | if (!gc->nr_du) | |
249 | return 1; | |
250 | ||
251 | res_notebook = get_results_window(ge); | |
252 | ||
253 | for (i = 0; i < gc->nr_du; i++) { | |
254 | struct cmd_du_pdu *p = &gc->du[i]; | |
255 | ||
256 | __gfio_disk_util_show(res_notebook, gc, p); | |
257 | } | |
258 | ||
259 | gtk_widget_show_all(ge->results_window); | |
260 | return 0; | |
261 | } | |
262 | ||
263 | static void gfio_disk_util_op(struct fio_client *client, struct fio_net_cmd *cmd) | |
264 | { | |
265 | struct cmd_du_pdu *p = (struct cmd_du_pdu *) cmd->payload; | |
266 | struct gfio_client *gc = client->client_data; | |
267 | struct gui_entry *ge = gc->ge; | |
268 | unsigned int nr = gc->nr_du; | |
269 | ||
270 | gc->du = realloc(gc->du, (nr + 1) * sizeof(struct cmd_du_pdu)); | |
271 | memcpy(&gc->du[nr], p, sizeof(*p)); | |
272 | gc->nr_du++; | |
273 | ||
274 | gdk_threads_enter(); | |
275 | if (ge->results_window) | |
276 | __gfio_disk_util_show(ge->results_notebook, gc, p); | |
277 | else | |
278 | gfio_disk_util_show(gc); | |
279 | gdk_threads_leave(); | |
280 | } | |
281 | ||
282 | extern int sum_stat_clients; | |
283 | extern struct thread_stat client_ts; | |
284 | extern struct group_run_stats client_gs; | |
285 | ||
286 | static int sum_stat_nr; | |
287 | ||
288 | static void gfio_thread_status_op(struct fio_client *client, | |
289 | struct fio_net_cmd *cmd) | |
290 | { | |
291 | struct cmd_ts_pdu *p = (struct cmd_ts_pdu *) cmd->payload; | |
292 | ||
293 | gfio_display_ts(client, &p->ts, &p->rs); | |
294 | ||
295 | if (sum_stat_clients == 1) | |
296 | return; | |
297 | ||
298 | sum_thread_stats(&client_ts, &p->ts, sum_stat_nr); | |
299 | sum_group_stats(&client_gs, &p->rs); | |
300 | ||
301 | client_ts.members++; | |
302 | client_ts.thread_number = p->ts.thread_number; | |
303 | client_ts.groupid = p->ts.groupid; | |
304 | ||
305 | if (++sum_stat_nr == sum_stat_clients) { | |
306 | strcpy(client_ts.name, "All clients"); | |
307 | gfio_display_ts(client, &client_ts, &client_gs); | |
308 | } | |
309 | } | |
310 | ||
311 | static void gfio_group_stats_op(struct fio_client *client, | |
312 | struct fio_net_cmd *cmd) | |
313 | { | |
314 | /* We're ignoring group stats for now */ | |
315 | } | |
316 | ||
317 | static void gfio_update_thread_status(struct gui_entry *ge, | |
318 | char *status_message, double perc) | |
319 | { | |
320 | static char message[100]; | |
321 | const char *m = message; | |
322 | ||
323 | strncpy(message, status_message, sizeof(message) - 1); | |
324 | gtk_progress_bar_set_text(GTK_PROGRESS_BAR(ge->thread_status_pb), m); | |
325 | gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(ge->thread_status_pb), perc / 100.0); | |
326 | gtk_widget_queue_draw(ge->ui->window); | |
327 | } | |
328 | ||
329 | static void gfio_update_thread_status_all(struct gui *ui, char *status_message, | |
330 | double perc) | |
331 | { | |
332 | static char message[100]; | |
333 | const char *m = message; | |
334 | ||
335 | strncpy(message, status_message, sizeof(message) - 1); | |
336 | gtk_progress_bar_set_text(GTK_PROGRESS_BAR(ui->thread_status_pb), m); | |
337 | gtk_progress_bar_set_fraction(GTK_PROGRESS_BAR(ui->thread_status_pb), perc / 100.0); | |
338 | gtk_widget_queue_draw(ui->window); | |
339 | } | |
340 | ||
341 | /* | |
342 | * Client specific ETA | |
343 | */ | |
344 | static void gfio_update_client_eta(struct fio_client *client, struct jobs_eta *je) | |
345 | { | |
346 | struct gfio_client *gc = client->client_data; | |
347 | struct gui_entry *ge = gc->ge; | |
348 | static int eta_good; | |
349 | char eta_str[128]; | |
350 | char output[256]; | |
351 | char tmp[32]; | |
352 | double perc = 0.0; | |
353 | int i2p = 0; | |
354 | ||
355 | gdk_threads_enter(); | |
356 | ||
357 | eta_str[0] = '\0'; | |
358 | output[0] = '\0'; | |
359 | ||
360 | if (je->eta_sec != INT_MAX && je->elapsed_sec) { | |
361 | perc = (double) je->elapsed_sec / (double) (je->elapsed_sec + je->eta_sec); | |
362 | eta_to_str(eta_str, je->eta_sec); | |
363 | } | |
364 | ||
365 | sprintf(tmp, "%u", je->nr_running); | |
366 | gtk_entry_set_text(GTK_ENTRY(ge->eta.jobs), tmp); | |
367 | sprintf(tmp, "%u", je->files_open); | |
368 | gtk_entry_set_text(GTK_ENTRY(ge->eta.files), tmp); | |
369 | ||
370 | #if 0 | |
371 | if (je->m_rate[0] || je->m_rate[1] || je->t_rate[0] || je->t_rate[1]) { | |
372 | if (je->m_rate || je->t_rate) { | |
373 | char *tr, *mr; | |
374 | ||
375 | mr = num2str(je->m_rate, 4, 0, i2p); | |
376 | tr = num2str(je->t_rate, 4, 0, i2p); | |
377 | gtk_entry_set_text(GTK_ENTRY(ge->eta); | |
378 | p += sprintf(p, ", CR=%s/%s KB/s", tr, mr); | |
379 | free(tr); | |
380 | free(mr); | |
381 | } else if (je->m_iops || je->t_iops) | |
382 | p += sprintf(p, ", CR=%d/%d IOPS", je->t_iops, je->m_iops); | |
383 | ||
384 | gtk_entry_set_text(GTK_ENTRY(ge->eta.cr_bw), "---"); | |
385 | gtk_entry_set_text(GTK_ENTRY(ge->eta.cr_iops), "---"); | |
386 | gtk_entry_set_text(GTK_ENTRY(ge->eta.cw_bw), "---"); | |
387 | gtk_entry_set_text(GTK_ENTRY(ge->eta.cw_iops), "---"); | |
388 | #endif | |
389 | ||
390 | if (je->eta_sec != INT_MAX && je->nr_running) { | |
391 | char *iops_str[2]; | |
392 | char *rate_str[2]; | |
393 | ||
394 | if ((!je->eta_sec && !eta_good) || je->nr_ramp == je->nr_running) | |
395 | strcpy(output, "-.-% done"); | |
396 | else { | |
397 | eta_good = 1; | |
398 | perc *= 100.0; | |
399 | sprintf(output, "%3.1f%% done", perc); | |
400 | } | |
401 | ||
402 | rate_str[0] = num2str(je->rate[0], 5, 10, i2p); | |
403 | rate_str[1] = num2str(je->rate[1], 5, 10, i2p); | |
404 | ||
405 | iops_str[0] = num2str(je->iops[0], 4, 1, 0); | |
406 | iops_str[1] = num2str(je->iops[1], 4, 1, 0); | |
407 | ||
408 | gtk_entry_set_text(GTK_ENTRY(ge->eta.read_bw), rate_str[0]); | |
409 | gtk_entry_set_text(GTK_ENTRY(ge->eta.read_iops), iops_str[0]); | |
410 | gtk_entry_set_text(GTK_ENTRY(ge->eta.write_bw), rate_str[1]); | |
411 | gtk_entry_set_text(GTK_ENTRY(ge->eta.write_iops), iops_str[1]); | |
412 | ||
8dfd6071 JA |
413 | graph_add_xy_data(ge->graphs.iops_graph, ge->graphs.read_iops, je->elapsed_sec, je->iops[0], iops_str[0]); |
414 | graph_add_xy_data(ge->graphs.iops_graph, ge->graphs.write_iops, je->elapsed_sec, je->iops[1], iops_str[1]); | |
415 | graph_add_xy_data(ge->graphs.bandwidth_graph, ge->graphs.read_bw, je->elapsed_sec, je->rate[0], rate_str[0]); | |
416 | graph_add_xy_data(ge->graphs.bandwidth_graph, ge->graphs.write_bw, je->elapsed_sec, je->rate[1], rate_str[1]); | |
1252d8f2 JA |
417 | |
418 | free(rate_str[0]); | |
419 | free(rate_str[1]); | |
420 | free(iops_str[0]); | |
421 | free(iops_str[1]); | |
422 | } | |
423 | ||
424 | if (eta_str[0]) { | |
425 | char *dst = output + strlen(output); | |
426 | ||
427 | sprintf(dst, " - %s", eta_str); | |
428 | } | |
3c3ed070 | 429 | |
1252d8f2 JA |
430 | gfio_update_thread_status(ge, output, perc); |
431 | gdk_threads_leave(); | |
432 | } | |
433 | ||
434 | /* | |
435 | * Update ETA in main window for all clients | |
436 | */ | |
437 | static void gfio_update_all_eta(struct jobs_eta *je) | |
438 | { | |
439 | struct gui *ui = &main_ui; | |
440 | static int eta_good; | |
441 | char eta_str[128]; | |
442 | char output[256]; | |
443 | double perc = 0.0; | |
444 | int i2p = 0; | |
445 | ||
446 | gdk_threads_enter(); | |
447 | ||
448 | eta_str[0] = '\0'; | |
449 | output[0] = '\0'; | |
450 | ||
451 | if (je->eta_sec != INT_MAX && je->elapsed_sec) { | |
452 | perc = (double) je->elapsed_sec / (double) (je->elapsed_sec + je->eta_sec); | |
453 | eta_to_str(eta_str, je->eta_sec); | |
454 | } | |
455 | ||
456 | #if 0 | |
457 | if (je->m_rate[0] || je->m_rate[1] || je->t_rate[0] || je->t_rate[1]) { | |
458 | if (je->m_rate || je->t_rate) { | |
459 | char *tr, *mr; | |
460 | ||
461 | mr = num2str(je->m_rate, 4, 0, i2p); | |
462 | tr = num2str(je->t_rate, 4, 0, i2p); | |
463 | gtk_entry_set_text(GTK_ENTRY(ui->eta); | |
464 | p += sprintf(p, ", CR=%s/%s KB/s", tr, mr); | |
465 | free(tr); | |
466 | free(mr); | |
467 | } else if (je->m_iops || je->t_iops) | |
468 | p += sprintf(p, ", CR=%d/%d IOPS", je->t_iops, je->m_iops); | |
469 | ||
470 | gtk_entry_set_text(GTK_ENTRY(ui->eta.cr_bw), "---"); | |
471 | gtk_entry_set_text(GTK_ENTRY(ui->eta.cr_iops), "---"); | |
472 | gtk_entry_set_text(GTK_ENTRY(ui->eta.cw_bw), "---"); | |
473 | gtk_entry_set_text(GTK_ENTRY(ui->eta.cw_iops), "---"); | |
474 | #endif | |
475 | ||
476 | entry_set_int_value(ui->eta.jobs, je->nr_running); | |
477 | ||
478 | if (je->eta_sec != INT_MAX && je->nr_running) { | |
479 | char *iops_str[2]; | |
480 | char *rate_str[2]; | |
481 | ||
482 | if ((!je->eta_sec && !eta_good) || je->nr_ramp == je->nr_running) | |
483 | strcpy(output, "-.-% done"); | |
484 | else { | |
485 | eta_good = 1; | |
486 | perc *= 100.0; | |
487 | sprintf(output, "%3.1f%% done", perc); | |
488 | } | |
489 | ||
490 | rate_str[0] = num2str(je->rate[0], 5, 10, i2p); | |
491 | rate_str[1] = num2str(je->rate[1], 5, 10, i2p); | |
492 | ||
493 | iops_str[0] = num2str(je->iops[0], 4, 1, 0); | |
494 | iops_str[1] = num2str(je->iops[1], 4, 1, 0); | |
495 | ||
496 | gtk_entry_set_text(GTK_ENTRY(ui->eta.read_bw), rate_str[0]); | |
497 | gtk_entry_set_text(GTK_ENTRY(ui->eta.read_iops), iops_str[0]); | |
498 | gtk_entry_set_text(GTK_ENTRY(ui->eta.write_bw), rate_str[1]); | |
499 | gtk_entry_set_text(GTK_ENTRY(ui->eta.write_iops), iops_str[1]); | |
500 | ||
8dfd6071 JA |
501 | graph_add_xy_data(ui->graphs.iops_graph, ui->graphs.read_iops, je->elapsed_sec, je->iops[0], iops_str[0]); |
502 | graph_add_xy_data(ui->graphs.iops_graph, ui->graphs.write_iops, je->elapsed_sec, je->iops[1], iops_str[1]); | |
503 | graph_add_xy_data(ui->graphs.bandwidth_graph, ui->graphs.read_bw, je->elapsed_sec, je->rate[0], rate_str[0]); | |
504 | graph_add_xy_data(ui->graphs.bandwidth_graph, ui->graphs.write_bw, je->elapsed_sec, je->rate[1], rate_str[1]); | |
1252d8f2 JA |
505 | |
506 | free(rate_str[0]); | |
507 | free(rate_str[1]); | |
508 | free(iops_str[0]); | |
509 | free(iops_str[1]); | |
510 | } | |
511 | ||
512 | if (eta_str[0]) { | |
513 | char *dst = output + strlen(output); | |
514 | ||
515 | sprintf(dst, " - %s", eta_str); | |
516 | } | |
3c3ed070 | 517 | |
1252d8f2 JA |
518 | gfio_update_thread_status_all(ui, output, perc); |
519 | gdk_threads_leave(); | |
520 | } | |
521 | ||
522 | static void gfio_probe_op(struct fio_client *client, struct fio_net_cmd *cmd) | |
523 | { | |
524 | struct cmd_probe_pdu *probe = (struct cmd_probe_pdu *) cmd->payload; | |
525 | struct gfio_client *gc = client->client_data; | |
526 | struct gui_entry *ge = gc->ge; | |
527 | const char *os, *arch; | |
528 | char buf[64]; | |
529 | ||
530 | os = fio_get_os_string(probe->os); | |
531 | if (!os) | |
532 | os = "unknown"; | |
533 | ||
534 | arch = fio_get_arch_string(probe->arch); | |
535 | if (!arch) | |
536 | os = "unknown"; | |
537 | ||
538 | if (!client->name) | |
539 | client->name = strdup((char *) probe->hostname); | |
540 | ||
541 | gdk_threads_enter(); | |
542 | ||
543 | gtk_label_set_text(GTK_LABEL(ge->probe.hostname), (char *) probe->hostname); | |
544 | gtk_label_set_text(GTK_LABEL(ge->probe.os), os); | |
545 | gtk_label_set_text(GTK_LABEL(ge->probe.arch), arch); | |
546 | sprintf(buf, "%u.%u.%u", probe->fio_major, probe->fio_minor, probe->fio_patch); | |
547 | gtk_label_set_text(GTK_LABEL(ge->probe.fio_ver), buf); | |
548 | ||
549 | gfio_set_state(ge, GE_STATE_CONNECTED); | |
550 | ||
551 | gdk_threads_leave(); | |
552 | } | |
553 | ||
554 | static void gfio_quit_op(struct fio_client *client, struct fio_net_cmd *cmd) | |
555 | { | |
556 | struct gfio_client *gc = client->client_data; | |
557 | ||
558 | gdk_threads_enter(); | |
559 | gfio_set_state(gc->ge, GE_STATE_NEW); | |
560 | gdk_threads_leave(); | |
561 | } | |
562 | ||
cf3d8241 JA |
563 | static struct thread_options *gfio_client_add_job(struct gfio_client *gc, |
564 | struct thread_options_pack *top) | |
565 | { | |
566 | struct gfio_client_options *gco; | |
567 | ||
568 | gco = calloc(1, sizeof(*gco)); | |
569 | convert_thread_options_to_cpu(&gco->o, top); | |
753e9e64 | 570 | INIT_FLIST_HEAD(&gco->list); |
cf3d8241 | 571 | flist_add_tail(&gco->list, &gc->o_list); |
753e9e64 | 572 | gc->o_list_nr = 1; |
cf3d8241 JA |
573 | return &gco->o; |
574 | } | |
575 | ||
1252d8f2 JA |
576 | static void gfio_add_job_op(struct fio_client *client, struct fio_net_cmd *cmd) |
577 | { | |
578 | struct cmd_add_job_pdu *p = (struct cmd_add_job_pdu *) cmd->payload; | |
579 | struct gfio_client *gc = client->client_data; | |
1252d8f2 | 580 | struct gui_entry *ge = gc->ge; |
cf3d8241 | 581 | struct thread_options *o; |
1252d8f2 JA |
582 | char *c1, *c2, *c3, *c4; |
583 | char tmp[80]; | |
584 | ||
585 | p->thread_number = le32_to_cpu(p->thread_number); | |
586 | p->groupid = le32_to_cpu(p->groupid); | |
cf3d8241 | 587 | o = gfio_client_add_job(gc, &p->top); |
1252d8f2 JA |
588 | |
589 | gdk_threads_enter(); | |
590 | ||
f762cef9 | 591 | gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(ge->eta.names), (gchar *) o->name); |
1252d8f2 JA |
592 | gtk_combo_box_set_active(GTK_COMBO_BOX(ge->eta.names), 0); |
593 | ||
594 | sprintf(tmp, "%s %s", o->odirect ? "direct" : "buffered", ddir_str(o->td_ddir)); | |
595 | multitext_add_entry(&ge->eta.iotype, tmp); | |
596 | ||
597 | c1 = fio_uint_to_kmg(o->min_bs[DDIR_READ]); | |
598 | c2 = fio_uint_to_kmg(o->max_bs[DDIR_WRITE]); | |
599 | c3 = fio_uint_to_kmg(o->min_bs[DDIR_READ]); | |
600 | c4 = fio_uint_to_kmg(o->max_bs[DDIR_WRITE]); | |
601 | sprintf(tmp, "%s-%s/%s-%s", c1, c2, c3, c4); | |
602 | free(c1); | |
603 | free(c2); | |
604 | free(c3); | |
605 | free(c4); | |
606 | multitext_add_entry(&ge->eta.bs, tmp); | |
607 | ||
608 | multitext_add_entry(&ge->eta.ioengine, (const char *) o->ioengine); | |
609 | ||
610 | sprintf(tmp, "%u", o->iodepth); | |
611 | multitext_add_entry(&ge->eta.iodepth, tmp); | |
612 | ||
613 | multitext_set_entry(&ge->eta.iotype, 0); | |
614 | multitext_set_entry(&ge->eta.bs, 0); | |
615 | multitext_set_entry(&ge->eta.ioengine, 0); | |
616 | multitext_set_entry(&ge->eta.iodepth, 0); | |
617 | ||
618 | gfio_set_state(ge, GE_STATE_JOB_SENT); | |
619 | ||
620 | gdk_threads_leave(); | |
621 | } | |
622 | ||
40c60516 JA |
623 | static void gfio_update_job_op(struct fio_client *client, |
624 | struct fio_net_cmd *cmd) | |
625 | { | |
626 | uint32_t *pdu_error = (uint32_t *) cmd->payload; | |
627 | struct gfio_client *gc = client->client_data; | |
628 | ||
28db256b JA |
629 | gc->update_job_status = le32_to_cpu(*pdu_error); |
630 | gc->update_job_done = 1; | |
40c60516 JA |
631 | } |
632 | ||
1252d8f2 JA |
633 | static void gfio_client_timed_out(struct fio_client *client) |
634 | { | |
635 | struct gfio_client *gc = client->client_data; | |
636 | char buf[256]; | |
637 | ||
638 | gdk_threads_enter(); | |
639 | ||
640 | gfio_set_state(gc->ge, GE_STATE_NEW); | |
641 | clear_ge_ui_info(gc->ge); | |
642 | ||
643 | sprintf(buf, "Client %s: timeout talking to server.\n", client->hostname); | |
644 | gfio_report_info(gc->ge->ui, "Network timeout", buf); | |
645 | ||
646 | gdk_threads_leave(); | |
647 | } | |
648 | ||
649 | static void gfio_client_stop(struct fio_client *client, struct fio_net_cmd *cmd) | |
650 | { | |
651 | struct gfio_client *gc = client->client_data; | |
652 | ||
653 | gdk_threads_enter(); | |
654 | ||
655 | gfio_set_state(gc->ge, GE_STATE_JOB_DONE); | |
656 | ||
657 | if (gc->err_entry) | |
658 | entry_set_int_value(gc->err_entry, client->error); | |
659 | ||
660 | gdk_threads_leave(); | |
661 | } | |
662 | ||
663 | static void gfio_client_start(struct fio_client *client, struct fio_net_cmd *cmd) | |
664 | { | |
665 | struct gfio_client *gc = client->client_data; | |
666 | ||
667 | gdk_threads_enter(); | |
668 | gfio_set_state(gc->ge, GE_STATE_JOB_STARTED); | |
669 | gdk_threads_leave(); | |
670 | } | |
671 | ||
672 | static void gfio_client_job_start(struct fio_client *client, struct fio_net_cmd *cmd) | |
673 | { | |
674 | struct gfio_client *gc = client->client_data; | |
675 | ||
676 | gdk_threads_enter(); | |
677 | gfio_set_state(gc->ge, GE_STATE_JOB_RUNNING); | |
678 | gdk_threads_leave(); | |
679 | } | |
680 | ||
681 | static void gfio_client_iolog(struct fio_client *client, struct cmd_iolog_pdu *pdu) | |
682 | { | |
683 | printf("got iolog: name=%s, type=%u, entries=%u\n", pdu->name, pdu->log_type, pdu->nr_samples); | |
684 | free(pdu); | |
685 | } | |
686 | ||
687 | static void gfio_add_total_depths_tree(GtkListStore *model, | |
688 | struct thread_stat *ts, unsigned int len) | |
689 | { | |
690 | double io_u_dist[FIO_IO_U_MAP_NR]; | |
691 | GtkTreeIter iter; | |
692 | /* Bits 1-6, and 8 */ | |
693 | const int add_mask = 0x17e; | |
694 | int i, j; | |
695 | ||
696 | stat_calc_dist(ts->io_u_map, ts_total_io_u(ts), io_u_dist); | |
697 | ||
698 | gtk_list_store_append(model, &iter); | |
699 | ||
700 | gtk_list_store_set(model, &iter, 0, "Total", -1); | |
701 | ||
702 | for (i = 1, j = 0; i < len; i++) { | |
703 | char fbuf[32]; | |
704 | ||
705 | if (!(add_mask & (1UL << (i - 1)))) | |
706 | sprintf(fbuf, "0.0%%"); | |
707 | else { | |
708 | sprintf(fbuf, "%3.1f%%", io_u_dist[j]); | |
709 | j++; | |
710 | } | |
711 | ||
712 | gtk_list_store_set(model, &iter, i, fbuf, -1); | |
713 | } | |
714 | ||
715 | } | |
716 | ||
717 | static void gfio_add_end_results(struct gfio_client *gc, struct thread_stat *ts, | |
718 | struct group_run_stats *rs) | |
719 | { | |
720 | unsigned int nr = gc->nr_results; | |
721 | ||
722 | gc->results = realloc(gc->results, (nr + 1) * sizeof(struct end_results)); | |
723 | memcpy(&gc->results[nr].ts, ts, sizeof(*ts)); | |
724 | memcpy(&gc->results[nr].gs, rs, sizeof(*rs)); | |
725 | gc->nr_results++; | |
726 | } | |
727 | ||
728 | static void gfio_add_sc_depths_tree(GtkListStore *model, | |
729 | struct thread_stat *ts, unsigned int len, | |
730 | int submit) | |
731 | { | |
732 | double io_u_dist[FIO_IO_U_MAP_NR]; | |
733 | GtkTreeIter iter; | |
734 | /* Bits 0, and 3-8 */ | |
735 | const int add_mask = 0x1f9; | |
736 | int i, j; | |
737 | ||
738 | if (submit) | |
739 | stat_calc_dist(ts->io_u_submit, ts->total_submit, io_u_dist); | |
740 | else | |
741 | stat_calc_dist(ts->io_u_complete, ts->total_complete, io_u_dist); | |
742 | ||
743 | gtk_list_store_append(model, &iter); | |
744 | ||
745 | gtk_list_store_set(model, &iter, 0, submit ? "Submit" : "Complete", -1); | |
746 | ||
747 | for (i = 1, j = 0; i < len; i++) { | |
748 | char fbuf[32]; | |
749 | ||
750 | if (!(add_mask & (1UL << (i - 1)))) | |
751 | sprintf(fbuf, "0.0%%"); | |
752 | else { | |
753 | sprintf(fbuf, "%3.1f%%", io_u_dist[j]); | |
754 | j++; | |
755 | } | |
756 | ||
757 | gtk_list_store_set(model, &iter, i, fbuf, -1); | |
758 | } | |
759 | ||
760 | } | |
761 | ||
762 | static void gfio_show_io_depths(GtkWidget *vbox, struct thread_stat *ts) | |
763 | { | |
764 | GtkWidget *frame, *box, *tree_view = NULL; | |
765 | GtkTreeSelection *selection; | |
766 | GtkListStore *model; | |
1252d8f2 JA |
767 | int i; |
768 | const char *labels[] = { "Depth", "0", "1", "2", "4", "8", "16", "32", "64", ">= 64" }; | |
05775438 | 769 | const int nr_labels = ARRAY_SIZE(labels); |
1fae4855 | 770 | GType types[nr_labels]; |
1252d8f2 JA |
771 | |
772 | frame = gtk_frame_new("IO depths"); | |
773 | gtk_box_pack_start(GTK_BOX(vbox), frame, FALSE, FALSE, 5); | |
774 | ||
775 | box = gtk_hbox_new(FALSE, 3); | |
776 | gtk_container_add(GTK_CONTAINER(frame), box); | |
777 | ||
778 | for (i = 0; i < nr_labels; i++) | |
779 | types[i] = G_TYPE_STRING; | |
780 | ||
781 | model = gtk_list_store_newv(nr_labels, types); | |
782 | ||
783 | tree_view = gtk_tree_view_new_with_model(GTK_TREE_MODEL(model)); | |
784 | gtk_widget_set_can_focus(tree_view, FALSE); | |
785 | ||
786 | g_object_set(G_OBJECT(tree_view), "headers-visible", TRUE, | |
787 | "enable-grid-lines", GTK_TREE_VIEW_GRID_LINES_BOTH, NULL); | |
788 | ||
789 | selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(tree_view)); | |
790 | gtk_tree_selection_set_mode(GTK_TREE_SELECTION(selection), GTK_SELECTION_BROWSE); | |
791 | ||
792 | for (i = 0; i < nr_labels; i++) | |
793 | tree_view_column(tree_view, i, labels[i], ALIGN_RIGHT | UNSORTABLE); | |
794 | ||
795 | gfio_add_total_depths_tree(model, ts, nr_labels); | |
796 | gfio_add_sc_depths_tree(model, ts, nr_labels, 1); | |
797 | gfio_add_sc_depths_tree(model, ts, nr_labels, 0); | |
798 | ||
f5e653e6 | 799 | gtk_box_pack_start(GTK_BOX(box), tree_view, TRUE, TRUE, 3); |
1252d8f2 JA |
800 | } |
801 | ||
802 | static void gfio_show_cpu_usage(GtkWidget *vbox, struct thread_stat *ts) | |
803 | { | |
804 | GtkWidget *box, *frame, *entry; | |
805 | double usr_cpu, sys_cpu; | |
806 | unsigned long runtime; | |
807 | char tmp[32]; | |
808 | ||
809 | runtime = ts->total_run_time; | |
810 | if (runtime) { | |
811 | double runt = (double) runtime; | |
812 | ||
813 | usr_cpu = (double) ts->usr_time * 100 / runt; | |
814 | sys_cpu = (double) ts->sys_time * 100 / runt; | |
815 | } else { | |
816 | usr_cpu = 0; | |
817 | sys_cpu = 0; | |
818 | } | |
819 | ||
820 | frame = gtk_frame_new("OS resources"); | |
821 | gtk_box_pack_start(GTK_BOX(vbox), frame, FALSE, FALSE, 5); | |
822 | ||
823 | box = gtk_hbox_new(FALSE, 3); | |
824 | gtk_container_add(GTK_CONTAINER(frame), box); | |
825 | ||
826 | entry = new_info_entry_in_frame(box, "User CPU"); | |
827 | sprintf(tmp, "%3.2f%%", usr_cpu); | |
828 | gtk_entry_set_text(GTK_ENTRY(entry), tmp); | |
829 | entry = new_info_entry_in_frame(box, "System CPU"); | |
830 | sprintf(tmp, "%3.2f%%", sys_cpu); | |
831 | gtk_entry_set_text(GTK_ENTRY(entry), tmp); | |
832 | entry = new_info_entry_in_frame(box, "Context switches"); | |
833 | entry_set_int_value(entry, ts->ctx); | |
834 | entry = new_info_entry_in_frame(box, "Major faults"); | |
835 | entry_set_int_value(entry, ts->majf); | |
836 | entry = new_info_entry_in_frame(box, "Minor faults"); | |
837 | entry_set_int_value(entry, ts->minf); | |
838 | } | |
839 | ||
840 | static GtkWidget *gfio_output_lat_buckets(double *lat, const char **labels, | |
841 | int num) | |
842 | { | |
843 | GtkWidget *tree_view; | |
844 | GtkTreeSelection *selection; | |
845 | GtkListStore *model; | |
846 | GtkTreeIter iter; | |
847 | GType *types; | |
848 | int i; | |
849 | ||
850 | types = malloc(num * sizeof(GType)); | |
851 | ||
852 | for (i = 0; i < num; i++) | |
853 | types[i] = G_TYPE_STRING; | |
854 | ||
855 | model = gtk_list_store_newv(num, types); | |
856 | free(types); | |
857 | types = NULL; | |
858 | ||
859 | tree_view = gtk_tree_view_new_with_model(GTK_TREE_MODEL(model)); | |
860 | gtk_widget_set_can_focus(tree_view, FALSE); | |
861 | ||
862 | g_object_set(G_OBJECT(tree_view), "headers-visible", TRUE, | |
863 | "enable-grid-lines", GTK_TREE_VIEW_GRID_LINES_BOTH, NULL); | |
864 | ||
865 | selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(tree_view)); | |
866 | gtk_tree_selection_set_mode(GTK_TREE_SELECTION(selection), GTK_SELECTION_BROWSE); | |
867 | ||
868 | for (i = 0; i < num; i++) | |
869 | tree_view_column(tree_view, i, labels[i], ALIGN_RIGHT | UNSORTABLE); | |
870 | ||
871 | gtk_list_store_append(model, &iter); | |
872 | ||
873 | for (i = 0; i < num; i++) { | |
874 | char fbuf[32]; | |
875 | ||
876 | if (lat[i] <= 0.0) | |
877 | sprintf(fbuf, "0.00"); | |
878 | else | |
879 | sprintf(fbuf, "%3.2f%%", lat[i]); | |
880 | ||
881 | gtk_list_store_set(model, &iter, i, fbuf, -1); | |
882 | } | |
883 | ||
884 | return tree_view; | |
885 | } | |
886 | ||
887 | static struct graph *setup_lat_bucket_graph(const char *title, double *lat, | |
888 | const char **labels, | |
889 | unsigned int len, | |
890 | double xdim, double ydim) | |
891 | { | |
892 | struct graph *g; | |
893 | int i; | |
894 | ||
895 | g = graph_new(xdim, ydim, gfio_graph_font); | |
896 | graph_title(g, title); | |
897 | graph_x_title(g, "Buckets"); | |
898 | graph_y_title(g, "Percent"); | |
899 | ||
900 | for (i = 0; i < len; i++) { | |
8dfd6071 JA |
901 | graph_label_t l; |
902 | ||
903 | l = graph_add_label(g, labels[i]); | |
904 | graph_add_data(g, l, lat[i]); | |
1252d8f2 JA |
905 | } |
906 | ||
907 | return g; | |
908 | } | |
909 | ||
910 | static int on_expose_lat_drawing_area(GtkWidget *w, GdkEvent *event, gpointer p) | |
911 | { | |
912 | struct graph *g = p; | |
913 | cairo_t *cr; | |
914 | ||
cd0d2db8 | 915 | cr = gdk_cairo_create(gtk_widget_get_window(w)); |
1252d8f2 JA |
916 | #if 0 |
917 | if (graph_has_tooltips(g)) { | |
918 | g_object_set(w, "has-tooltip", TRUE, NULL); | |
919 | g_signal_connect(w, "query-tooltip", G_CALLBACK(clat_graph_tooltip), g); | |
920 | } | |
921 | #endif | |
922 | cairo_set_source_rgb(cr, 0, 0, 0); | |
923 | bar_graph_draw(g, cr); | |
924 | cairo_destroy(cr); | |
925 | ||
926 | return FALSE; | |
927 | } | |
928 | ||
929 | static gint on_config_lat_drawing_area(GtkWidget *w, GdkEventConfigure *event, | |
930 | gpointer data) | |
931 | { | |
cd0d2db8 JA |
932 | guint width = gtk_widget_get_allocated_width(w); |
933 | guint height = gtk_widget_get_allocated_height(w); | |
1252d8f2 JA |
934 | struct graph *g = data; |
935 | ||
cd0d2db8 JA |
936 | graph_set_size(g, width, height); |
937 | graph_set_size(g, width, height); | |
1252d8f2 JA |
938 | graph_set_position(g, 0, 0); |
939 | return TRUE; | |
940 | } | |
941 | ||
942 | static void gfio_show_latency_buckets(struct gfio_client *gc, GtkWidget *vbox, | |
943 | struct thread_stat *ts) | |
944 | { | |
945 | double io_u_lat[FIO_IO_U_LAT_U_NR + FIO_IO_U_LAT_M_NR]; | |
946 | const char *ranges[] = { "2u", "4u", "10u", "20u", "50u", "100u", | |
947 | "250u", "500u", "750u", "1m", "2m", | |
948 | "4m", "10m", "20m", "50m", "100m", | |
949 | "250m", "500m", "750m", "1s", "2s", ">= 2s" }; | |
950 | int start, end, i; | |
951 | const int total = FIO_IO_U_LAT_U_NR + FIO_IO_U_LAT_M_NR; | |
952 | GtkWidget *frame, *tree_view, *hbox, *completion_vbox, *drawing_area; | |
953 | struct gui_entry *ge = gc->ge; | |
954 | ||
955 | stat_calc_lat_u(ts, io_u_lat); | |
956 | stat_calc_lat_m(ts, &io_u_lat[FIO_IO_U_LAT_U_NR]); | |
957 | ||
958 | /* | |
959 | * Found out which first bucket has entries, and which last bucket | |
960 | */ | |
961 | start = end = -1U; | |
962 | for (i = 0; i < total; i++) { | |
963 | if (io_u_lat[i] == 0.00) | |
964 | continue; | |
965 | ||
966 | if (start == -1U) | |
967 | start = i; | |
968 | end = i; | |
969 | } | |
970 | ||
971 | /* | |
972 | * No entries... | |
973 | */ | |
974 | if (start == -1U) | |
975 | return; | |
3c3ed070 | 976 | |
1252d8f2 JA |
977 | tree_view = gfio_output_lat_buckets(&io_u_lat[start], &ranges[start], end - start + 1); |
978 | ge->lat_bucket_graph = setup_lat_bucket_graph("Latency Buckets", &io_u_lat[start], &ranges[start], end - start + 1, 700.0, 300.0); | |
979 | ||
980 | frame = gtk_frame_new("Latency buckets"); | |
981 | gtk_box_pack_start(GTK_BOX(vbox), frame, FALSE, FALSE, 5); | |
982 | ||
983 | completion_vbox = gtk_vbox_new(FALSE, 3); | |
984 | gtk_container_add(GTK_CONTAINER(frame), completion_vbox); | |
985 | hbox = gtk_hbox_new(FALSE, 3); | |
986 | gtk_container_add(GTK_CONTAINER(completion_vbox), hbox); | |
987 | ||
988 | drawing_area = gtk_drawing_area_new(); | |
989 | gtk_widget_set_size_request(GTK_WIDGET(drawing_area), 700, 300); | |
990 | gtk_widget_modify_bg(drawing_area, GTK_STATE_NORMAL, &gfio_color_white); | |
991 | gtk_container_add(GTK_CONTAINER(completion_vbox), drawing_area); | |
b6ab6a31 | 992 | g_signal_connect(G_OBJECT(drawing_area), GFIO_DRAW_EVENT, G_CALLBACK(on_expose_lat_drawing_area), ge->lat_bucket_graph); |
3c3ed070 | 993 | g_signal_connect(G_OBJECT(drawing_area), "configure_event", G_CALLBACK(on_config_lat_drawing_area), ge->lat_bucket_graph); |
1252d8f2 | 994 | |
b4d669e6 | 995 | gtk_box_pack_start(GTK_BOX(hbox), tree_view, TRUE, TRUE, 3); |
1252d8f2 JA |
996 | } |
997 | ||
998 | static void gfio_show_lat(GtkWidget *vbox, const char *name, unsigned long min, | |
999 | unsigned long max, double mean, double dev) | |
1000 | { | |
1001 | const char *base = "(usec)"; | |
1002 | GtkWidget *hbox, *label, *frame; | |
1003 | char *minp, *maxp; | |
1004 | char tmp[64]; | |
1005 | ||
1006 | if (!usec_to_msec(&min, &max, &mean, &dev)) | |
1007 | base = "(msec)"; | |
1008 | ||
1009 | minp = num2str(min, 6, 1, 0); | |
1010 | maxp = num2str(max, 6, 1, 0); | |
1011 | ||
1012 | sprintf(tmp, "%s %s", name, base); | |
1013 | frame = gtk_frame_new(tmp); | |
1014 | gtk_box_pack_start(GTK_BOX(vbox), frame, FALSE, FALSE, 5); | |
1015 | ||
1016 | hbox = gtk_hbox_new(FALSE, 3); | |
1017 | gtk_container_add(GTK_CONTAINER(frame), hbox); | |
1018 | ||
1019 | label = new_info_label_in_frame(hbox, "Minimum"); | |
1020 | gtk_label_set_text(GTK_LABEL(label), minp); | |
1021 | label = new_info_label_in_frame(hbox, "Maximum"); | |
1022 | gtk_label_set_text(GTK_LABEL(label), maxp); | |
1023 | label = new_info_label_in_frame(hbox, "Average"); | |
1024 | sprintf(tmp, "%5.02f", mean); | |
1025 | gtk_label_set_text(GTK_LABEL(label), tmp); | |
1026 | label = new_info_label_in_frame(hbox, "Standard deviation"); | |
1027 | sprintf(tmp, "%5.02f", dev); | |
1028 | gtk_label_set_text(GTK_LABEL(label), tmp); | |
1029 | ||
1030 | free(minp); | |
1031 | free(maxp); | |
1032 | } | |
1033 | ||
1034 | static GtkWidget *gfio_output_clat_percentiles(unsigned int *ovals, | |
1035 | fio_fp64_t *plist, | |
1036 | unsigned int len, | |
1037 | const char *base, | |
1038 | unsigned int scale) | |
1039 | { | |
1040 | GType types[FIO_IO_U_LIST_MAX_LEN]; | |
1041 | GtkWidget *tree_view; | |
1042 | GtkTreeSelection *selection; | |
1043 | GtkListStore *model; | |
1044 | GtkTreeIter iter; | |
1045 | int i; | |
1046 | ||
1047 | for (i = 0; i < len; i++) | |
1048 | types[i] = G_TYPE_INT; | |
1049 | ||
1050 | model = gtk_list_store_newv(len, types); | |
1051 | ||
1052 | tree_view = gtk_tree_view_new_with_model(GTK_TREE_MODEL(model)); | |
1053 | gtk_widget_set_can_focus(tree_view, FALSE); | |
1054 | ||
1055 | g_object_set(G_OBJECT(tree_view), "headers-visible", TRUE, | |
1056 | "enable-grid-lines", GTK_TREE_VIEW_GRID_LINES_BOTH, NULL); | |
1057 | ||
1058 | selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(tree_view)); | |
1059 | gtk_tree_selection_set_mode(GTK_TREE_SELECTION(selection), GTK_SELECTION_BROWSE); | |
1060 | ||
1061 | for (i = 0; i < len; i++) { | |
1062 | char fbuf[8]; | |
1063 | ||
1064 | sprintf(fbuf, "%2.2f%%", plist[i].u.f); | |
1065 | tree_view_column(tree_view, i, fbuf, ALIGN_RIGHT | UNSORTABLE); | |
1066 | } | |
1067 | ||
1068 | gtk_list_store_append(model, &iter); | |
1069 | ||
1070 | for (i = 0; i < len; i++) { | |
1071 | if (scale) | |
1072 | ovals[i] = (ovals[i] + 999) / 1000; | |
1073 | gtk_list_store_set(model, &iter, i, ovals[i], -1); | |
1074 | } | |
1075 | ||
1076 | return tree_view; | |
1077 | } | |
1078 | ||
1079 | static struct graph *setup_clat_graph(char *title, unsigned int *ovals, | |
1080 | fio_fp64_t *plist, | |
1081 | unsigned int len, | |
1082 | double xdim, double ydim) | |
1083 | { | |
1084 | struct graph *g; | |
1085 | int i; | |
1086 | ||
1087 | g = graph_new(xdim, ydim, gfio_graph_font); | |
1088 | graph_title(g, title); | |
1089 | graph_x_title(g, "Percentile"); | |
1090 | graph_y_title(g, "Time"); | |
1091 | ||
1092 | for (i = 0; i < len; i++) { | |
8dfd6071 | 1093 | graph_label_t l; |
1252d8f2 JA |
1094 | char fbuf[8]; |
1095 | ||
1096 | sprintf(fbuf, "%2.2f%%", plist[i].u.f); | |
8dfd6071 JA |
1097 | l = graph_add_label(g, fbuf); |
1098 | graph_add_data(g, l, (double) ovals[i]); | |
1252d8f2 JA |
1099 | } |
1100 | ||
1101 | return g; | |
1102 | } | |
1103 | ||
1104 | static void gfio_show_clat_percentiles(struct gfio_client *gc, | |
1105 | GtkWidget *vbox, struct thread_stat *ts, | |
1106 | int ddir) | |
1107 | { | |
1108 | unsigned int *io_u_plat = ts->io_u_plat[ddir]; | |
1109 | unsigned long nr = ts->clat_stat[ddir].samples; | |
1110 | fio_fp64_t *plist = ts->percentile_list; | |
1111 | unsigned int *ovals, len, minv, maxv, scale_down; | |
1112 | const char *base; | |
1113 | GtkWidget *tree_view, *frame, *hbox, *drawing_area, *completion_vbox; | |
1114 | struct gui_entry *ge = gc->ge; | |
1115 | char tmp[64]; | |
1116 | ||
1117 | len = calc_clat_percentiles(io_u_plat, nr, plist, &ovals, &maxv, &minv); | |
1118 | if (!len) | |
1119 | goto out; | |
1120 | ||
1121 | /* | |
1122 | * We default to usecs, but if the value range is such that we | |
1123 | * should scale down to msecs, do that. | |
1124 | */ | |
1125 | if (minv > 2000 && maxv > 99999) { | |
1126 | scale_down = 1; | |
1127 | base = "msec"; | |
1128 | } else { | |
1129 | scale_down = 0; | |
1130 | base = "usec"; | |
1131 | } | |
1132 | ||
1133 | sprintf(tmp, "Completion percentiles (%s)", base); | |
1134 | tree_view = gfio_output_clat_percentiles(ovals, plist, len, base, scale_down); | |
1135 | ge->clat_graph = setup_clat_graph(tmp, ovals, plist, len, 700.0, 300.0); | |
1136 | ||
1137 | frame = gtk_frame_new(tmp); | |
1138 | gtk_box_pack_start(GTK_BOX(vbox), frame, FALSE, FALSE, 5); | |
1139 | ||
1140 | completion_vbox = gtk_vbox_new(FALSE, 3); | |
1141 | gtk_container_add(GTK_CONTAINER(frame), completion_vbox); | |
1142 | hbox = gtk_hbox_new(FALSE, 3); | |
1143 | gtk_container_add(GTK_CONTAINER(completion_vbox), hbox); | |
1144 | drawing_area = gtk_drawing_area_new(); | |
1145 | gtk_widget_set_size_request(GTK_WIDGET(drawing_area), 700, 300); | |
1146 | gtk_widget_modify_bg(drawing_area, GTK_STATE_NORMAL, &gfio_color_white); | |
1147 | gtk_container_add(GTK_CONTAINER(completion_vbox), drawing_area); | |
b6ab6a31 | 1148 | g_signal_connect(G_OBJECT(drawing_area), GFIO_DRAW_EVENT, G_CALLBACK(on_expose_lat_drawing_area), ge->clat_graph); |
1252d8f2 JA |
1149 | g_signal_connect(G_OBJECT(drawing_area), "configure_event", G_CALLBACK(on_config_lat_drawing_area), ge->clat_graph); |
1150 | ||
bf0f6cc7 | 1151 | gtk_box_pack_start(GTK_BOX(hbox), tree_view, TRUE, TRUE, 3); |
1252d8f2 JA |
1152 | out: |
1153 | if (ovals) | |
1154 | free(ovals); | |
1155 | } | |
1156 | ||
1157 | #define GFIO_CLAT 1 | |
1158 | #define GFIO_SLAT 2 | |
1159 | #define GFIO_LAT 4 | |
1160 | ||
1161 | static void gfio_show_ddir_status(struct gfio_client *gc, GtkWidget *mbox, | |
1162 | struct group_run_stats *rs, | |
1163 | struct thread_stat *ts, int ddir) | |
1164 | { | |
1165 | const char *ddir_label[2] = { "Read", "Write" }; | |
1166 | GtkWidget *frame, *label, *box, *vbox, *main_vbox; | |
1167 | unsigned long min[3], max[3], runt; | |
1168 | unsigned long long bw, iops; | |
1169 | unsigned int flags = 0; | |
1170 | double mean[3], dev[3]; | |
1171 | char *io_p, *bw_p, *iops_p; | |
1172 | int i2p; | |
1173 | ||
1174 | if (!ts->runtime[ddir]) | |
1175 | return; | |
1176 | ||
1177 | i2p = is_power_of_2(rs->kb_base); | |
1178 | runt = ts->runtime[ddir]; | |
1179 | ||
1180 | bw = (1000 * ts->io_bytes[ddir]) / runt; | |
1181 | io_p = num2str(ts->io_bytes[ddir], 6, 1, i2p); | |
1182 | bw_p = num2str(bw, 6, 1, i2p); | |
1183 | ||
1184 | iops = (1000 * (uint64_t)ts->total_io_u[ddir]) / runt; | |
1185 | iops_p = num2str(iops, 6, 1, 0); | |
1186 | ||
1187 | box = gtk_hbox_new(FALSE, 3); | |
1188 | gtk_box_pack_start(GTK_BOX(mbox), box, TRUE, FALSE, 3); | |
1189 | ||
1190 | frame = gtk_frame_new(ddir_label[ddir]); | |
f614437e | 1191 | gtk_box_pack_start(GTK_BOX(box), frame, TRUE, TRUE, 5); |
1252d8f2 JA |
1192 | |
1193 | main_vbox = gtk_vbox_new(FALSE, 3); | |
1194 | gtk_container_add(GTK_CONTAINER(frame), main_vbox); | |
1195 | ||
1196 | box = gtk_hbox_new(FALSE, 3); | |
1197 | gtk_box_pack_start(GTK_BOX(main_vbox), box, TRUE, FALSE, 3); | |
1198 | ||
1199 | label = new_info_label_in_frame(box, "IO"); | |
1200 | gtk_label_set_text(GTK_LABEL(label), io_p); | |
1201 | label = new_info_label_in_frame(box, "Bandwidth"); | |
1202 | gtk_label_set_text(GTK_LABEL(label), bw_p); | |
1203 | label = new_info_label_in_frame(box, "IOPS"); | |
1204 | gtk_label_set_text(GTK_LABEL(label), iops_p); | |
1205 | label = new_info_label_in_frame(box, "Runtime (msec)"); | |
1206 | label_set_int_value(label, ts->runtime[ddir]); | |
1207 | ||
1208 | if (calc_lat(&ts->bw_stat[ddir], &min[0], &max[0], &mean[0], &dev[0])) { | |
1209 | double p_of_agg = 100.0; | |
1210 | const char *bw_str = "KB"; | |
1211 | char tmp[32]; | |
1212 | ||
1213 | if (rs->agg[ddir]) { | |
1214 | p_of_agg = mean[0] * 100 / (double) rs->agg[ddir]; | |
1215 | if (p_of_agg > 100.0) | |
1216 | p_of_agg = 100.0; | |
1217 | } | |
1218 | ||
1219 | if (mean[0] > 999999.9) { | |
1220 | min[0] /= 1000.0; | |
1221 | max[0] /= 1000.0; | |
1222 | mean[0] /= 1000.0; | |
1223 | dev[0] /= 1000.0; | |
1224 | bw_str = "MB"; | |
1225 | } | |
1226 | ||
1227 | sprintf(tmp, "Bandwidth (%s)", bw_str); | |
1228 | frame = gtk_frame_new(tmp); | |
1229 | gtk_box_pack_start(GTK_BOX(main_vbox), frame, FALSE, FALSE, 5); | |
1230 | ||
1231 | box = gtk_hbox_new(FALSE, 3); | |
1232 | gtk_container_add(GTK_CONTAINER(frame), box); | |
1233 | ||
1234 | label = new_info_label_in_frame(box, "Minimum"); | |
1235 | label_set_int_value(label, min[0]); | |
1236 | label = new_info_label_in_frame(box, "Maximum"); | |
1237 | label_set_int_value(label, max[0]); | |
1238 | label = new_info_label_in_frame(box, "Percentage of jobs"); | |
1239 | sprintf(tmp, "%3.2f%%", p_of_agg); | |
1240 | gtk_label_set_text(GTK_LABEL(label), tmp); | |
1241 | label = new_info_label_in_frame(box, "Average"); | |
1242 | sprintf(tmp, "%5.02f", mean[0]); | |
1243 | gtk_label_set_text(GTK_LABEL(label), tmp); | |
1244 | label = new_info_label_in_frame(box, "Standard deviation"); | |
1245 | sprintf(tmp, "%5.02f", dev[0]); | |
1246 | gtk_label_set_text(GTK_LABEL(label), tmp); | |
1247 | } | |
1248 | ||
1249 | if (calc_lat(&ts->slat_stat[ddir], &min[0], &max[0], &mean[0], &dev[0])) | |
1250 | flags |= GFIO_SLAT; | |
1251 | if (calc_lat(&ts->clat_stat[ddir], &min[1], &max[1], &mean[1], &dev[1])) | |
1252 | flags |= GFIO_CLAT; | |
1253 | if (calc_lat(&ts->lat_stat[ddir], &min[2], &max[2], &mean[2], &dev[2])) | |
1254 | flags |= GFIO_LAT; | |
1255 | ||
1256 | if (flags) { | |
1257 | frame = gtk_frame_new("Latency"); | |
1258 | gtk_box_pack_start(GTK_BOX(main_vbox), frame, FALSE, FALSE, 5); | |
1259 | ||
1260 | vbox = gtk_vbox_new(FALSE, 3); | |
1261 | gtk_container_add(GTK_CONTAINER(frame), vbox); | |
1262 | ||
1263 | if (flags & GFIO_SLAT) | |
1264 | gfio_show_lat(vbox, "Submission latency", min[0], max[0], mean[0], dev[0]); | |
1265 | if (flags & GFIO_CLAT) | |
1266 | gfio_show_lat(vbox, "Completion latency", min[1], max[1], mean[1], dev[1]); | |
1267 | if (flags & GFIO_LAT) | |
1268 | gfio_show_lat(vbox, "Total latency", min[2], max[2], mean[2], dev[2]); | |
1269 | } | |
1270 | ||
1271 | if (ts->clat_percentiles) | |
1272 | gfio_show_clat_percentiles(gc, main_vbox, ts, ddir); | |
1273 | ||
1274 | free(io_p); | |
1275 | free(bw_p); | |
1276 | free(iops_p); | |
1277 | } | |
1278 | ||
1279 | static void __gfio_display_end_results(GtkWidget *win, struct gfio_client *gc, | |
1280 | struct thread_stat *ts, | |
1281 | struct group_run_stats *rs) | |
1282 | { | |
1283 | GtkWidget *box, *vbox, *entry, *scroll; | |
1284 | ||
1285 | scroll = gtk_scrolled_window_new(NULL, NULL); | |
1286 | gtk_container_set_border_width(GTK_CONTAINER(scroll), 5); | |
1287 | gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scroll), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); | |
1288 | ||
1289 | vbox = gtk_vbox_new(FALSE, 3); | |
1290 | ||
1291 | box = gtk_hbox_new(FALSE, 0); | |
1292 | gtk_box_pack_start(GTK_BOX(vbox), box, TRUE, FALSE, 5); | |
1293 | ||
1294 | gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(scroll), vbox); | |
1295 | ||
1296 | gtk_notebook_append_page(GTK_NOTEBOOK(win), scroll, gtk_label_new(ts->name)); | |
1297 | ||
1298 | entry = new_info_entry_in_frame(box, "Name"); | |
1299 | gtk_entry_set_text(GTK_ENTRY(entry), ts->name); | |
1300 | if (strlen(ts->description)) { | |
1301 | entry = new_info_entry_in_frame(box, "Description"); | |
1302 | gtk_entry_set_text(GTK_ENTRY(entry), ts->description); | |
1303 | } | |
1304 | entry = new_info_entry_in_frame(box, "Group ID"); | |
1305 | entry_set_int_value(entry, ts->groupid); | |
1306 | entry = new_info_entry_in_frame(box, "Jobs"); | |
1307 | entry_set_int_value(entry, ts->members); | |
1308 | gc->err_entry = entry = new_info_entry_in_frame(box, "Error"); | |
1309 | entry_set_int_value(entry, ts->error); | |
1310 | entry = new_info_entry_in_frame(box, "PID"); | |
1311 | entry_set_int_value(entry, ts->pid); | |
1312 | ||
1313 | if (ts->io_bytes[DDIR_READ]) | |
1314 | gfio_show_ddir_status(gc, vbox, rs, ts, DDIR_READ); | |
1315 | if (ts->io_bytes[DDIR_WRITE]) | |
1316 | gfio_show_ddir_status(gc, vbox, rs, ts, DDIR_WRITE); | |
1317 | ||
1318 | gfio_show_latency_buckets(gc, vbox, ts); | |
1319 | gfio_show_cpu_usage(vbox, ts); | |
1320 | gfio_show_io_depths(vbox, ts); | |
1321 | } | |
1322 | ||
1323 | void gfio_display_end_results(struct gfio_client *gc) | |
1324 | { | |
1325 | struct gui_entry *ge = gc->ge; | |
1326 | GtkWidget *res_notebook; | |
1327 | int i; | |
1328 | ||
1329 | res_notebook = get_results_window(ge); | |
1330 | ||
1331 | for (i = 0; i < gc->nr_results; i++) { | |
1332 | struct end_results *e = &gc->results[i]; | |
1333 | ||
1334 | __gfio_display_end_results(res_notebook, gc, &e->ts, &e->gs); | |
1335 | } | |
1336 | ||
1337 | if (gfio_disk_util_show(gc)) | |
1338 | gtk_widget_show_all(ge->results_window); | |
1339 | } | |
1340 | ||
1341 | static void gfio_display_ts(struct fio_client *client, struct thread_stat *ts, | |
1342 | struct group_run_stats *rs) | |
1343 | { | |
1344 | struct gfio_client *gc = client->client_data; | |
1345 | struct gui_entry *ge = gc->ge; | |
1346 | ||
1347 | gfio_add_end_results(gc, ts, rs); | |
1348 | ||
1349 | gdk_threads_enter(); | |
1350 | if (ge->results_window) | |
1351 | __gfio_display_end_results(ge->results_notebook, gc, ts, rs); | |
1352 | else | |
1353 | gfio_display_end_results(gc); | |
1354 | gdk_threads_leave(); | |
1355 | } | |
1356 | ||
1357 | static void gfio_client_removed(struct fio_client *client) | |
1358 | { | |
1359 | struct gfio_client *gc = client->client_data; | |
1360 | ||
1361 | assert(gc->client == client); | |
1362 | fio_put_client(gc->client); | |
1363 | gc->client = NULL; | |
1364 | } | |
1365 | ||
1366 | struct client_ops gfio_client_ops = { | |
1367 | .text = gfio_text_op, | |
1368 | .disk_util = gfio_disk_util_op, | |
1369 | .thread_status = gfio_thread_status_op, | |
1370 | .group_stats = gfio_group_stats_op, | |
1371 | .jobs_eta = gfio_update_client_eta, | |
1372 | .eta = gfio_update_all_eta, | |
1373 | .probe = gfio_probe_op, | |
1374 | .quit = gfio_quit_op, | |
1375 | .add_job = gfio_add_job_op, | |
40c60516 | 1376 | .update_job = gfio_update_job_op, |
1252d8f2 JA |
1377 | .timed_out = gfio_client_timed_out, |
1378 | .stop = gfio_client_stop, | |
1379 | .start = gfio_client_start, | |
1380 | .job_start = gfio_client_job_start, | |
1381 | .iolog = gfio_client_iolog, | |
1382 | .removed = gfio_client_removed, | |
1383 | .eta_msec = FIO_CLIENT_DEF_ETA_MSEC, | |
1384 | .stay_connected = 1, | |
1385 | .client_type = FIO_CLIENT_TYPE_GUI, | |
1386 | }; |