Skip to content
Snippets Groups Projects
Commit 69d3fa54 authored by Danny Auble's avatar Danny Auble
Browse files

sview - speed up logic for large numbers of blocks

parent aa27e01b
No related branches found
No related tags found
No related merge requests found
...@@ -223,10 +223,8 @@ static char *_set_running_job_str(List job_list, bool compact) ...@@ -223,10 +223,8 @@ static char *_set_running_job_str(List job_list, bool compact)
return NULL; return NULL;
} }
static void _block_list_del(void *object) static void _block_info_free(sview_block_info_t *block_ptr)
{ {
sview_block_info_t *block_ptr = (sview_block_info_t *)object;
if (block_ptr) { if (block_ptr) {
xfree(block_ptr->bg_block_name); xfree(block_ptr->bg_block_name);
xfree(block_ptr->slurm_part_name); xfree(block_ptr->slurm_part_name);
...@@ -245,8 +243,16 @@ static void _block_list_del(void *object) ...@@ -245,8 +243,16 @@ static void _block_list_del(void *object)
/* don't xfree(block_ptr->mp_inx); /* don't xfree(block_ptr->mp_inx);
it isn't copied like the chars and is freed in the api it isn't copied like the chars and is freed in the api
*/ */
xfree(block_ptr); }
}
static void _block_list_del(void *object)
{
sview_block_info_t *block_ptr = (sview_block_info_t *)object;
if (block_ptr) {
_block_info_free(block_ptr);
xfree(block_ptr);
} }
} }
...@@ -485,43 +491,9 @@ static void _update_info_block(List block_list, ...@@ -485,43 +491,9 @@ static void _update_info_block(List block_list,
_update_block_record(block_ptr, _update_block_record(block_ptr,
GTK_TREE_STORE(model)); GTK_TREE_STORE(model));
else { else {
GtkTreePath *path = gtk_tree_path_new_first(); _append_block_record(block_ptr,
GTK_TREE_STORE(model));
/* get the iter, or find out the list is empty block_ptr->iter_set = true;
* goto add */
if (gtk_tree_model_get_iter(
model, &block_ptr->iter_ptr, path)) {
do {
/* search for the jobid and
check to see if it is in
the list */
gtk_tree_model_get(
model,
&block_ptr->iter_ptr,
SORTID_BLOCK,
&name, -1);
if (!strcmp(name,
block_ptr->bg_block_name)) {
/* update with new info */
g_free(name);
_update_block_record(
block_ptr,
GTK_TREE_STORE(model));
block_ptr->iter_set = 1;
break;
}
g_free(name);
} while (gtk_tree_model_iter_next(
model,
&block_ptr->iter_ptr));
}
if (!block_ptr->iter_set) {
_append_block_record(block_ptr,
GTK_TREE_STORE(model));
block_ptr->iter_set = true;
}
gtk_tree_path_free(path);
} }
} }
...@@ -588,6 +560,8 @@ static List _create_block_list(partition_info_msg_t *part_info_ptr, ...@@ -588,6 +560,8 @@ static List _create_block_list(partition_info_msg_t *part_info_ptr,
static List block_list = NULL; static List block_list = NULL;
static partition_info_msg_t *last_part_info_ptr = NULL; static partition_info_msg_t *last_part_info_ptr = NULL;
static block_info_msg_t *last_block_info_ptr = NULL; static block_info_msg_t *last_block_info_ptr = NULL;
List last_list = NULL;
ListIterator last_list_itr = NULL;
sview_block_info_t *block_ptr = NULL; sview_block_info_t *block_ptr = NULL;
char tmp_mp_str[50]; char tmp_mp_str[50];
...@@ -608,9 +582,10 @@ static List _create_block_list(partition_info_msg_t *part_info_ptr, ...@@ -608,9 +582,10 @@ static List _create_block_list(partition_info_msg_t *part_info_ptr,
return block_list; return block_list;
} }
list_flush(block_list); last_list = block_list;
} else }
block_list = list_create(_block_list_del);
block_list = list_create(_block_list_del);
if (!block_list) { if (!block_list) {
g_print("malloc error\n"); g_print("malloc error\n");
return NULL; return NULL;
...@@ -618,13 +593,31 @@ static List _create_block_list(partition_info_msg_t *part_info_ptr, ...@@ -618,13 +593,31 @@ static List _create_block_list(partition_info_msg_t *part_info_ptr,
last_block_info_ptr = block_info_ptr; last_block_info_ptr = block_info_ptr;
if (last_list)
last_list_itr = list_iterator_create(last_list);
for (i=0; i<block_info_ptr->record_count; i++) { for (i=0; i<block_info_ptr->record_count; i++) {
/* If we don't have a block name just continue since /* If we don't have a block name just continue since
ths block hasn't been made in the system yet. */ ths block hasn't been made in the system yet. */
if (!block_info_ptr->block_array[i].bg_block_id) if (!block_info_ptr->block_array[i].bg_block_id)
continue; continue;
block_ptr = xmalloc(sizeof(sview_block_info_t)); block_ptr = NULL;
if (last_list_itr) {
while ((block_ptr = list_next(last_list_itr))) {
if (!strcmp(block_ptr->bg_block_name,
block_info_ptr->
block_array[i].bg_block_id)) {
list_remove(last_list_itr);
_block_info_free(block_ptr);
break;
}
}
list_iterator_reset(last_list_itr);
}
if (!block_ptr)
block_ptr = xmalloc(sizeof(sview_block_info_t));
block_ptr->pos = i; block_ptr->pos = i;
block_ptr->bg_block_name block_ptr->bg_block_name
= xstrdup(block_info_ptr-> = xstrdup(block_info_ptr->
...@@ -706,6 +699,10 @@ static List _create_block_list(partition_info_msg_t *part_info_ptr, ...@@ -706,6 +699,10 @@ static List _create_block_list(partition_info_msg_t *part_info_ptr,
list_sort(block_list, list_sort(block_list,
(ListCmpF)_sview_block_sort_aval_dec); (ListCmpF)_sview_block_sort_aval_dec);
if (last_list) {
list_iterator_destroy(last_list_itr);
list_destroy(last_list);
}
return block_list; return block_list;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment