[pacman-dev] [PATCH 0/4] Package list find performance improvements

Allan McRae allan at archlinux.org
Tue Dec 14 18:00:07 EST 2010


On 15/12/10 04:46, Dan McGee wrote:
> This series of patches makes finding a package in our linked list
> implementation a whole lot faster, if that search is using the standard
> _alpm_pkg_find, which nearly all are (after the first patch).
>
> It does this by adding a hash function to util.c which is nothing too
> complicated and named after a publicly available algorithm. When packages are
> created, we fill in this hash value as soon as the pkgname is read. Finally,
> the _alpm_pkg_find function is rewritten to take advantage of this field,
> avoiding repeated strcmp() calls and only falling back to that if a hash is not
> available and to verify the hash value was not some sort of collision.
>
> Performance figures and numbers are available in the last patch. This actually
> speeds up operations by nearly 33%, so this is not a total waste of time to
> consider. :) Review and questions/comments/concerns welcome!
>

My only comment is more of a wondering whether would it be better to 
have an _alpm_pkg_set_name(pmpkg_t *) function that automatically 
updates the hash.  It is a tradeoff between having to always remember to 
update the hash after adjusting pmpkg_t->name (seems likely to get 
missed at some stage) and complexity that I am undecided on.

Allan


More information about the pacman-dev mailing list