From 4e86ae2e22548733054ffe05644d4a66030c859e Mon Sep 17 00:00:00 2001 From: compudj Date: Sat, 14 Aug 2004 06:47:29 +0000 Subject: [PATCH] remove unnecessary calls to get process pixels, but rare case git-svn-id: http://ltt.polymtl.ca/svn@736 04897980-b3bd-0310-b5e0-8ef037075253 --- .../lttv/modules/gui/controlflow/drawing.c | 4 + .../lttv/modules/gui/controlflow/eventhooks.c | 117 ++++++++---------- .../modules/gui/controlflow/processlist.c | 47 ++++--- .../modules/gui/controlflow/processlist.h | 7 +- 4 files changed, 96 insertions(+), 79 deletions(-) diff --git a/ltt/branches/poly/lttv/modules/gui/controlflow/drawing.c b/ltt/branches/poly/lttv/modules/gui/controlflow/drawing.c index 1f4100ee..265c68d5 100644 --- a/ltt/branches/poly/lttv/modules/gui/controlflow/drawing.c +++ b/ltt/branches/poly/lttv/modules/gui/controlflow/drawing.c @@ -410,6 +410,10 @@ void drawing_data_request_begin(EventsRequest *events_request, LttvTracesetState g_hash_table_foreach(cfd->process_list->process_hash, set_last_start, (gpointer)x); + + cfd->process_list->current_process_info = NULL; + cfd->process_list->current_hash_data = NULL; + } void drawing_chunk_begin(EventsRequest *events_request, LttvTracesetState *tss) diff --git a/ltt/branches/poly/lttv/modules/gui/controlflow/eventhooks.c b/ltt/branches/poly/lttv/modules/gui/controlflow/eventhooks.c index e1afc464..49a2109a 100644 --- a/ltt/branches/poly/lttv/modules/gui/controlflow/eventhooks.c +++ b/ltt/branches/poly/lttv/modules/gui/controlflow/eventhooks.c @@ -428,6 +428,7 @@ int before_schedchange_hook(void *hook_data, void *call_data) * be added after the state update. */ LttvProcessState *process; process = lttv_state_find_process(tfs, pid_out); + //process = tfs->process; if(process != NULL) { /* Well, the process_out existed : we must get it in the process hash @@ -451,6 +452,7 @@ int before_schedchange_hook(void *hook_data, void *call_data) { g_assert(pid_out == 0 || pid_out != process->ppid); /* Process not present */ + ProcessInfo *process_info; processlist_add(process_list, pid_out, process->last_cpu, @@ -459,15 +461,13 @@ int before_schedchange_hook(void *hook_data, void *call_data) tfc->t_context->index, name, &pl_height, + &process_info, &hashed_process_data); - processlist_get_process_pixels(process_list, - pid_out, - process->last_cpu, - &birth, - tfc->t_context->index, + processlist_get_pixels_from_data(process_list, + process_info, + hashed_process_data, &y, - &height, - &hashed_process_data); + &height); drawing_insert_square( drawing, y, height); } @@ -596,6 +596,7 @@ int before_schedchange_hook(void *hook_data, void *call_data) { g_assert(pid_in == 0 || pid_in != process->ppid); /* Process not present */ + ProcessInfo *process_info; processlist_add(process_list, pid_in, process->last_cpu, @@ -604,15 +605,13 @@ int before_schedchange_hook(void *hook_data, void *call_data) tfc->t_context->index, name, &pl_height, + &process_info, &hashed_process_data); - processlist_get_process_pixels(process_list, - pid_in, - process->last_cpu, - &birth, - tfc->t_context->index, + processlist_get_pixels_from_data(process_list, + process_info, + hashed_process_data, &y, - &height, - &hashed_process_data); + &height); drawing_insert_square( drawing, y, height); } @@ -1399,6 +1398,7 @@ int after_schedchange_hook(void *hook_data, void *call_data) &hashed_process_data_in) == 1) { g_assert(pid_in == 0 || pid_in != process_in->ppid); + ProcessInfo *process_info; /* Process not present */ processlist_add(process_list, pid_in, @@ -1408,15 +1408,13 @@ int after_schedchange_hook(void *hook_data, void *call_data) tfc->t_context->index, name, &pl_height, + &process_info, &hashed_process_data_in); - processlist_get_process_pixels(process_list, - pid_in, - process_in->last_cpu, - &birth, - tfc->t_context->index, - &y_in, - &height, - &hashed_process_data_in); + processlist_get_pixels_from_data(process_list, + process_info, + hashed_process_data_in, + &y_in, + &height); drawing_insert_square( control_flow_data->drawing, y_in, height); } @@ -2003,6 +2001,7 @@ int before_execmode_hook(void *hook_data, void *call_data) &hashed_process_data) == 1) { g_assert(pid == 0 || pid != process->ppid); + ProcessInfo *process_info; /* Process not present */ processlist_add(process_list, pid, @@ -2012,15 +2011,13 @@ int before_execmode_hook(void *hook_data, void *call_data) tfc->t_context->index, name, &pl_height, + &process_info, &hashed_process_data); - processlist_get_process_pixels(process_list, - pid, - process->last_cpu, - &birth, - tfc->t_context->index, - &y, - &height, - &hashed_process_data); + processlist_get_pixels_from_data(process_list, + process_info, + hashed_process_data, + &y, + &height); drawing_insert_square( drawing, y, height); } @@ -2186,6 +2183,7 @@ int after_execmode_hook(void *hook_data, void *call_data) { g_assert(pid == 0 || pid != process->ppid); /* Process not present */ + ProcessInfo *process_info; processlist_add(process_list, pid, process->last_cpu, @@ -2194,15 +2192,13 @@ int after_execmode_hook(void *hook_data, void *call_data) tfc->t_context->index, name, &pl_height, + &process_info, &hashed_process_data); - processlist_get_process_pixels(process_list, - pid, - process->last_cpu, - &birth, - tfc->t_context->index, - &y, - &height, - &hashed_process_data); + processlist_get_pixels_from_data(process_list, + process_info, + hashed_process_data, + &y, + &height); drawing_insert_square( control_flow_data->drawing, y, height); } @@ -2301,6 +2297,7 @@ int before_process_hook(void *hook_data, void *call_data) { g_assert(pid == 0 || pid != process->ppid); /* Process not present */ + ProcessInfo *process_info; processlist_add(process_list, pid, process->last_cpu, @@ -2309,15 +2306,13 @@ int before_process_hook(void *hook_data, void *call_data) tfc->t_context->index, name, &pl_height, + &process_info, &hashed_process_data); - processlist_get_process_pixels(process_list, - pid, - process->last_cpu, - &birth, - tfc->t_context->index, - &y, - &height, - &hashed_process_data); + processlist_get_pixels_from_data(process_list, + process_info, + hashed_process_data, + &y, + &height); drawing_insert_square( control_flow_data->drawing, y, height); } @@ -2503,6 +2498,7 @@ int after_process_hook(void *hook_data, void *call_data) { g_assert(child_pid == 0 || child_pid != process_child->ppid); /* Process not present */ + ProcessInfo *process_info; processlist_add(process_list, child_pid, process_child->last_cpu, @@ -2511,15 +2507,13 @@ int after_process_hook(void *hook_data, void *call_data) tfc->t_context->index, name, &pl_height, + &process_info, &hashed_process_data_child); - processlist_get_process_pixels(process_list, - child_pid, - process_child->last_cpu, - &birth, - tfc->t_context->index, - &y_child, - &height, - &hashed_process_data_child); + processlist_get_pixels_from_data(process_list, + process_info, + hashed_process_data_child, + &y_child, + &height); drawing_insert_square( control_flow_data->drawing, y_child, height); } @@ -2578,6 +2572,7 @@ int after_process_hook(void *hook_data, void *call_data) { g_assert(pid == 0 || pid != process->ppid); /* Process not present */ + ProcessInfo *process_info; processlist_add(process_list, pid, process->last_cpu, @@ -2586,15 +2581,13 @@ int after_process_hook(void *hook_data, void *call_data) tfc->t_context->index, name, &pl_height, + &process_info, &hashed_process_data); - processlist_get_process_pixels(process_list, - pid, - process->last_cpu, - &birth, - tfc->t_context->index, - &y, - &height, - &hashed_process_data); + processlist_get_pixels_from_data(process_list, + process_info, + hashed_process_data, + &y, + &height); drawing_insert_square( control_flow_data->drawing, y, height); } diff --git a/ltt/branches/poly/lttv/modules/gui/controlflow/processlist.c b/ltt/branches/poly/lttv/modules/gui/controlflow/processlist.c index e56911e9..51b6922b 100644 --- a/ltt/branches/poly/lttv/modules/gui/controlflow/processlist.c +++ b/ltt/branches/poly/lttv/modules/gui/controlflow/processlist.c @@ -279,6 +279,9 @@ ProcessList *processlist_construct(void) process_list->number_of_process = 0; process_list->cell_height_cache = -1; + process_list->current_process_info = NULL; + process_list->current_hash_data = NULL; + /* Create the Process list */ process_list->list_store = gtk_list_store_new ( N_COLUMNS, G_TYPE_STRING, @@ -414,6 +417,11 @@ static gboolean remove_hash_item(ProcessInfo *process_info, gtk_list_store_remove (process_list->list_store, &iter); + if(process_info == process_list->current_process_info) + process_list->current_process_info = NULL; + if(hashed_process_data == process_list->current_hash_data) + process_list->current_hash_data = NULL; + return TRUE; /* remove the element from the hash table */ } @@ -468,11 +476,13 @@ int processlist_add( ProcessList *process_list, guint trace_num, const gchar *name, guint *height, + ProcessInfo **pm_process_info, HashedProcessData **pm_hashed_process_data) { ProcessInfo *Process_Info = g_new(ProcessInfo, 1); HashedProcessData *hashed_process_data = g_new(HashedProcessData, 1); *pm_hashed_process_data = hashed_process_data; + *pm_process_info = Process_Info; Process_Info->pid = pid; if(pid == 0) @@ -543,32 +553,37 @@ int processlist_remove( ProcessList *process_list, LttTime *birth, guint trace_num) { - ProcessInfo Process_Info; + ProcessInfo process_info; gint *path_indices; HashedProcessData *hashed_process_data; GtkTreeIter iter; - Process_Info.pid = pid; + process_info.pid = pid; if(pid == 0) - Process_Info.cpu = cpu; + process_info.cpu = cpu; else - Process_Info.cpu = 0; - Process_Info.birth = *birth; - Process_Info.trace_num = trace_num; + process_info.cpu = 0; + process_info.birth = *birth; + process_info.trace_num = trace_num; if(hashed_process_data = (HashedProcessData*)g_hash_table_lookup( process_list->process_hash, - &Process_Info)) + &process_info)) { iter = hashed_process_data->y_iter; gtk_list_store_remove (process_list->list_store, &iter); g_hash_table_remove(process_list->process_hash, - &Process_Info); - + &process_info); + + if(hashed_process_data == process_list->current_hash_data) { + process_list->current_process_info = NULL; + process_list->current_hash_data = NULL; + } + process_list->number_of_process--; return 0; @@ -592,23 +607,23 @@ __inline gint processlist_get_process_pixels( ProcessList *process_list, guint *height, HashedProcessData **pm_hashed_process_data) { - ProcessInfo Process_Info; + ProcessInfo process_info; gint *path_indices; GtkTreePath *tree_path; HashedProcessData *hashed_process_data = NULL; - Process_Info.pid = pid; + process_info.pid = pid; if(pid == 0) - Process_Info.cpu = cpu; + process_info.cpu = cpu; else - Process_Info.cpu = 0; - Process_Info.birth = *birth; - Process_Info.trace_num = trace_num; + process_info.cpu = 0; + process_info.birth = *birth; + process_info.trace_num = trace_num; if(hashed_process_data = (HashedProcessData*)g_hash_table_lookup( process_list->process_hash, - &Process_Info)) + &process_info)) { tree_path = gtk_tree_model_get_path( GTK_TREE_MODEL(process_list->list_store), diff --git a/ltt/branches/poly/lttv/modules/gui/controlflow/processlist.h b/ltt/branches/poly/lttv/modules/gui/controlflow/processlist.h index 96ce1633..13af79c3 100644 --- a/ltt/branches/poly/lttv/modules/gui/controlflow/processlist.h +++ b/ltt/branches/poly/lttv/modules/gui/controlflow/processlist.h @@ -49,7 +49,7 @@ typedef struct _ProcessInfo { LttTime birth; guint trace_num; - gint height_cache; + // gint height_cache; } ProcessInfo; @@ -87,6 +87,10 @@ struct _ProcessList { guint number_of_process; gint cell_height_cache; + + ProcessInfo *current_process_info; + HashedProcessData *current_hash_data; + }; @@ -102,6 +106,7 @@ void processlist_clear(ProcessList *process_list); /* CPU num is only used for PID 0 */ int processlist_add(ProcessList *process_list, guint pid, guint cpu, guint ppid, LttTime *birth, guint trace_num, const gchar *name, guint *height, + ProcessInfo **process_info, HashedProcessData **hashed_process_data); // out : success (0) and height int processlist_remove(ProcessList *process_list, guint pid, guint cpu, -- 2.34.1