From bd93158a49cd64b84d0e64735d2362dbceaecf87 Mon Sep 17 00:00:00 2001 From: Jonathan Herman Date: Wed, 22 Aug 2012 15:34:10 -0400 Subject: Draw plot once on load, distributing records via hashing. redraw_pixmap_backend was being called 3 times. 2 of these times were superflous calls to configure. Added a hack to ignore the second two configures. Plot CPU reduction: 70% Each record was being sent to every plot. Now, records are only sent to the CPU and Task plots which hash to a calculated PID. Container plots currently aren't covered by this. Plot CPU reduction (after previous change): 30% --- Makefile | 4 +-- event-viewer.py | 0 rt-plot-cpu.c | 7 ++++- rt-plot-task.c | 11 ++++---- rt-plot-vtask.c | 4 --- trace-graph.c | 82 +++++++++++++++++++++++++++++++++------------------------ 6 files changed, 60 insertions(+), 48 deletions(-) mode change 100755 => 100644 event-viewer.py diff --git a/Makefile b/Makefile index 1a8c0a2..b69552f 100644 --- a/Makefile +++ b/Makefile @@ -215,8 +215,8 @@ INCLUDES = -I. $(CONFIG_INCLUDES) include features.mk # Set compile option CFLAGS if not set elsewhere -CFLAGS ?= -g -Wall -LDFLAGS ?= +CFLAGS ?= -g -Wall -pg +LDFLAGS ?= -pg ifndef NO_PTRACE ifneq ($(call try-cc,$(SOURCE_PTRACE),),y) diff --git a/event-viewer.py b/event-viewer.py old mode 100755 new mode 100644 diff --git a/rt-plot-cpu.c b/rt-plot-cpu.c index cfc19c3..9a609e0 100644 --- a/rt-plot-cpu.c +++ b/rt-plot-cpu.c @@ -513,8 +513,11 @@ void rt_plot_cpus_update_callback(gboolean accept, if (plot->type != PLOT_TYPE_CPU) continue; rtc_info = plot->private; - if (!cpu_isset(selected_cpu_mask, rtc_info->cpu)) + if (!cpu_isset(selected_cpu_mask, rtc_info->cpu)) { trace_graph_plot_remove(ginfo, plot); + trace_graph_plot_remove_cpu(ginfo, plot, + rtc_info->cpu); + } } } @@ -573,6 +576,8 @@ void rt_plot_cpu_label(struct graph_info *ginfo, int cpu, char* label) plot = trace_graph_plot_append(ginfo, label, PLOT_TYPE_RT_CPU, TIME_TYPE_RT, &rt_cpu_cb, rtc_info); trace_graph_plot_add_all_recs(ginfo, plot); + + trace_graph_plot_add_cpu(ginfo, plot, cpu); } /** diff --git a/rt-plot-task.c b/rt-plot-task.c index 0415ecc..77a517b 100644 --- a/rt-plot-task.c +++ b/rt-plot-task.c @@ -63,11 +63,7 @@ next_box_record(struct graph_info *ginfo, struct rt_task_info *rtt_info, static int update_job(struct rt_task_info *rtt_info, int job) { rtt_info->fresh = FALSE; - if (job < rtt_info->last_job) { - printf("Inconsistent job state for %d:%d -> %d\n", - rtt_info->pid, rtt_info->last_job, job); - return 0; - } else if (job > rtt_info->last_job) { + if (job > rtt_info->last_job) { rtt_info->last_job = job; snprintf(rtt_info->label, LLABEL, "%d:%d", rtt_info->pid, rtt_info->last_job); @@ -237,7 +233,7 @@ static int try_block(struct graph_info *ginfo, struct rt_task_info *rtt_info, dprintf(3, "Block for %d on %d at %llu\n", pid, record->cpu, ts); ret = 1; - } + } return ret; } @@ -585,6 +581,7 @@ void rt_plot_task_update_callback(gboolean accept, } /* Remove the plot */ trace_graph_plot_remove(ginfo, plot); + trace_graph_plot_remove_task(ginfo, plot, rtt_info->pid); } /* Now add any plots that need to be added */ @@ -662,6 +659,8 @@ void rt_plot_task(struct graph_info *ginfo, int pid, int pos) &rt_task_cb, rtt_info); free(plot_label); trace_graph_plot_add_all_recs(ginfo, plot); + + trace_graph_plot_add_task(ginfo, plot, pid); } void rt_plot_add_all_tasks(struct graph_info *ginfo) diff --git a/rt-plot-vtask.c b/rt-plot-vtask.c index 91eeb19..16bb942 100644 --- a/rt-plot-vtask.c +++ b/rt-plot-vtask.c @@ -16,10 +16,6 @@ static void update_job(struct vcpu_info *info, int job) { info->fresh = FALSE; - if (job < info->last_job) { - dprintf(1, "Inconsistent job state for server %d:%d -> %d\n", - info->sid, info->last_job, job); - } if (job > info->last_job) { info->last_job = job; diff --git a/trace-graph.c b/trace-graph.c index 1ce3d47..c0f88c9 100644 --- a/trace-graph.c +++ b/trace-graph.c @@ -1859,7 +1859,7 @@ static void draw_plot(struct graph_info *ginfo, struct graph_plot *plot, plot->p1, plot->p2, ginfo->draw_width, width_16, font); } -static void draw_ft_plots(struct graph_info *ginfo) +static void draw_hashed_plots(struct graph_info *ginfo) { gint cpu, pid; struct record *record; @@ -1881,8 +1881,8 @@ static void draw_ft_plots(struct graph_info *ginfo) hash = trace_graph_plot_find_cpu(ginfo, cpu); if (hash) { for (list = hash->plots; list; list = list->next) { - if (list->plot->time != TIME_TYPE_FT) - continue; + /* if (list->plot->time != TIME_TYPE_FT) */ + /* continue; */ draw_plot(ginfo, list->plot, record); } } @@ -1890,44 +1890,52 @@ static void draw_ft_plots(struct graph_info *ginfo) hash = trace_graph_plot_find_task(ginfo, pid); if (hash) { for (list = hash->plots; list; list = list->next) { - if (list->plot->time != TIME_TYPE_FT) - continue; + /* if (list->plot->time != TIME_TYPE_FT) */ + /* continue; */ draw_plot(ginfo, list->plot, record); } } for (list = ginfo->all_recs; list; list = list->next) { - if (list->plot->time != TIME_TYPE_FT) - continue; - draw_plot(ginfo, list->plot, record); + /* if (list->plot->time != TIME_TYPE_FT) */ + /* continue; */ + // TODO: hacky assumption that everything else can be + // reached via previous hashes + // Should be an additional hashed list where things are + // added with arbitrary numbers, and a pevent_other_id + // which uses id ranges x < . < y to parse cids or lids + if (list->plot->type == PLOT_TYPE_SERVER_TASK || + list->plot->type == PLOT_TYPE_SERVER_CPU) { + draw_plot(ginfo, list->plot, record); + } } free_record(record); } } -static void draw_rt_plots(struct graph_info *ginfo) -{ - gint cpu; - struct record *record; - struct plot_list *list; - - set_cpus_to_rts(ginfo, ginfo->view_start_time); - while ((record = tracecmd_read_next_data(ginfo->handle, &cpu))) { - if (get_rts(ginfo, record) < ginfo->view_start_time) { - free_record(record); - continue; - } - if (get_rts(ginfo, record) > ginfo->view_end_time) { - free_record(record); - break; - } - for (list = ginfo->all_recs; list; list = list->next) { - if (list->plot->time != TIME_TYPE_RT) - continue; - draw_plot(ginfo, list->plot, record); - } - free_record(record); - } -} +/* static void draw_rt_plots(struct graph_info *ginfo) */ +/* { */ +/* gint cpu; */ +/* struct record *record; */ +/* struct plot_list *list; */ + +/* set_cpus_to_rts(ginfo, ginfo->view_start_time); */ +/* while ((record = tracecmd_read_next_data(ginfo->handle, &cpu))) { */ +/* if (get_rts(ginfo, record) < ginfo->view_start_time) { */ +/* free_record(record); */ +/* continue; */ +/* } */ +/* if (get_rts(ginfo, record) > ginfo->view_end_time) { */ +/* free_record(record); */ +/* break; */ +/* } */ +/* for (list = ginfo->all_recs; list; list = list->next) { */ +/* if (list->plot->time != TIME_TYPE_RT) */ +/* continue; */ +/* draw_plot(ginfo, list->plot, record); */ +/* } */ +/* free_record(record); */ +/* } */ +/* } */ static void draw_plots(struct graph_info *ginfo, gint new_width) { @@ -1984,8 +1992,7 @@ static void draw_plots(struct graph_info *ginfo, gint new_width) goto out; } - draw_ft_plots(ginfo); - draw_rt_plots(ginfo); + draw_hashed_plots(ginfo); out: for (i = 0; i < ginfo->plots; i++) { @@ -2324,6 +2331,8 @@ static void redraw_pixmap_backend(struct graph_info *ginfo) } } +static int tries = 0; + static gboolean configure_event(GtkWidget *widget, GdkEventMotion *event, gpointer data) { @@ -2331,7 +2340,10 @@ configure_event(GtkWidget *widget, GdkEventMotion *event, gpointer data) gtk_widget_set_size_request(widget, ginfo->draw_width, ginfo->draw_height); - redraw_pixmap_backend(ginfo); + // TODO: don't do this, compare widget to figure out if we should redraw + if (tries != 1 && tries != 2) + redraw_pixmap_backend(ginfo); + ++tries; /* debug */ ginfo->hadj_value = gtk_adjustment_get_value(ginfo->hadj); -- cgit v1.2.2