Did some cache miss profiling with a large number of transient text objects

and found that reordering the evas list containing the font path list was
actually hurting cache performance. Frequent cache misses occurred in
evas_mempool_free in it's main loop. So removing the list node and re adding it
actually decreased cache performance in some cases. This would also cause memory
allocation bouncing if mempools were not used.

Added evas_list_promote_list to move a list node to the beginning of a list.
Changed reordering lists to use evas_list_promote_list.


SVN revision: 24387
This commit is contained in:
ningerso 2006-08-04 10:00:50 +00:00 committed by ningerso
parent 19ca0b0721
commit d85048c93f
5 changed files with 57 additions and 6 deletions

View File

@ -319,6 +319,7 @@ extern "C" {
EAPI Evas_List *evas_list_prepend_relative_list (Evas_List *list, const void *data, Evas_List *relative);
EAPI Evas_List *evas_list_remove (Evas_List *list, const void *data);
EAPI Evas_List *evas_list_remove_list (Evas_List *list, Evas_List *remove_list);
EAPI Evas_List *evas_list_promote_list (Evas_List *list, Evas_List *move_list);
EAPI void *evas_list_find (Evas_List *list, const void *data);
EAPI Evas_List *evas_list_find_list (Evas_List *list, const void *data);
EAPI Evas_List *evas_list_free (Evas_List *list);

View File

@ -151,8 +151,7 @@ evas_font_load(Evas *evas, const char *name, const char *source, int size)
{
if (size == fd->size)
{
fonts_cache = evas_list_remove_list(fonts_cache, l);
fonts_cache = evas_list_prepend(fonts_cache, fd);
fonts_cache = evas_list_promote_list(fonts_cache, l);
fd->ref++;
return fd->font;
}

View File

@ -403,6 +403,59 @@ evas_list_remove_list(Evas_List *list, Evas_List *remove_list)
return return_l;
}
/**
* Moves the specified data to the head of the list
*
* Move a specified member to the head of the list
* @param list The list handle to move @p inside
* @param move_list The list node which is to be moved
* @return A new list handle to replace the old one
*
* Calling this function takes the list node @p move_list and moves it
* to the front of the @p list.
*
* Example:
* @code
* extern Evas_List *list;
* Evas_List *l;
* extern void *my_data;
*
* for (l = list; l; l= l->next)
* {
* if (l->data == my_data)
* {
* list = evas_list_promote_list(list, l);
* break;
* }
* }
* @endcode
* @ingroup Evas_List_Promote_Group
*/
EAPI Evas_List *
evas_list_promote_list(Evas_List *list, Evas_List *move_list)
{
Evas_List *return_l;
if (!list) return NULL;
if (!move_list) return list;
if (move_list == list) return list;
if (move_list->next) move_list->next->prev = move_list->prev;
if (move_list->prev)
{
move_list->prev->next = move_list->next;
return_l = list;
}
else
return_l = move_list->next;
if (move_list == ((Evas_List_Accounting *)(list->accounting))->last)
((Evas_List_Accounting *)(list->accounting))->last = move_list->prev;
move_list->prev = NULL;
move_list->next = return_l;
return move_list;
}
/**
* @defgroup Evas_List_Find_Group Linked List Find Functions
*

View File

@ -66,8 +66,7 @@ evas_common_load_image_from_file(const char *file, const char *key)
{
if (evas_modules != l)
{
evas_modules = evas_list_remove_list(evas_modules, l);
evas_modules = evas_list_prepend(evas_modules, em);
evas_modules = evas_list_promote_list(evas_modules, l);
}
goto ok;
}

View File

@ -207,8 +207,7 @@ evas_module_find_type(Evas_Module_Type type, const char *name)
{
if (evas_modules != l)
{
evas_modules = evas_list_remove_list(evas_modules, l);
evas_modules = evas_list_prepend(evas_modules, em);
evas_modules = evas_list_promote_list(evas_modules, l);
}
return em;
}