Branch: refs/heads/master Author: Colomban Wendling ban@herbesfolles.org Committer: Colomban Wendling ban@herbesfolles.org Date: Sun, 07 Feb 2016 03:32:58 UTC Commit: 297be8db19e805238e8962c75aa2d74bf3cd8bbf https://github.com/geany/geany-plugins/commit/297be8db19e805238e8962c75aa2d7...
Log Message: ----------- debugger: Greatly improve Stack Tree population speed
Appending elements to a TreeStore is very slow, while prepending them is fast. As we add all items at once, prepend elements in reverse order, which is a lot faster and does the same.
This leads to tremendous speedups with large stack traces. For example, showing a 105000 frames height trace (resulting from infinite recursion and thus stack exhaustion) used to take more than 105s, while it now takes less than 0.3s.
Modified Paths: -------------- debugger/src/debug.c debugger/src/stree.c debugger/src/stree.h
Modified: debugger/src/debug.c 6 lines changed, 1 insertions(+), 5 deletions(-) =================================================================== @@ -700,11 +700,7 @@ static void on_debugger_stopped (int thread_id)
/* get current stack trace and put in the tree view */ stack = active_module->get_stack(); - for (iter = stack; iter; iter = iter->next) - { - frame *f = (frame*)iter->data; - stree_add(f); - } + stree_add (stack); stree_select_first_frame(TRUE);
/* files */
Modified: debugger/src/stree.c 19 lines changed, 14 insertions(+), 5 deletions(-) =================================================================== @@ -430,20 +430,29 @@ GtkWidget* stree_init(move_to_line_cb ml, select_frame_cb sf) }
/* - * add frame to the tree view + * add frames to the tree view */ -void stree_add(frame *f) +void stree_add(GList *frames) { + GList *item; GtkTreeRowReference *reference = (GtkTreeRowReference*)g_hash_table_lookup(threads, (gpointer)active_thread_id); - GtkTreeIter frame_iter; GtkTreeIter thread_iter; GtkTreePath *path = gtk_tree_row_reference_get_path(reference); gtk_tree_model_get_iter(model, &thread_iter, path); gtk_tree_path_free(path);
- gtk_tree_store_insert_before(store, &frame_iter, &thread_iter, 0); + g_object_ref (model); + gtk_tree_view_set_model (GTK_TREE_VIEW (tree), NULL);
- gtk_tree_store_set (store, &frame_iter, S_FRAME, f, -1); + /* prepending is a *lot* faster than appending, so prepend with a reversed data set */ + for (item = g_list_last (frames); item; item = item->prev) + { + gtk_tree_store_insert_with_values (store, NULL, &thread_iter, 0, + S_FRAME, item->data, -1); + } + + gtk_tree_view_set_model (GTK_TREE_VIEW (tree), model); + g_object_unref (model); }
/*
Modified: debugger/src/stree.h 2 lines changed, 1 insertions(+), 1 deletions(-) =================================================================== @@ -31,7 +31,7 @@ GtkWidget* stree_init(move_to_line_cb ml, select_frame_cb sf); void stree_destroy(void);
-void stree_add(frame *f); +void stree_add(GList *frames); void stree_clear(void);
void stree_add_thread(int thread_id);
-------------- This E-Mail was brought to you by github_commit_mail.py (Source: https://github.com/geany/infrastructure).