Re: [pacman-dev] [PATCH 4/4] pacman: speed up deptest

2019-10-06 Thread Allan McRae
On 9/9/19 7:45 am, morganamilo wrote:
> Try and find an exact match via pkgcache before iterating the entire
> localdb.
> 
> Gives a noticeable speed up for exact matches e.g. `pacman -T zlib`
> 

Thanks.  Applied.

> ---
> 
> Do note this fails for versioned exact matches. "zlib>1" will not take
> the faster route because alpm_db_get_pkgfromcache() does not work for
> versioned deps.
> 
> I do have a solution for this in an alternative patch which adds
> alpm_db_find_local_satisfier() "62 insertions(+), 7 deletions(-)"
> 
> But is that worth it just for a speed up on -T? Nowhere else really
> makes extensive use of searching the localdb.

Probably not worth the extra complexity given current usage of -T is
normally followed by a lot of compiling...

> ---
>  src/pacman/deptest.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/src/pacman/deptest.c b/src/pacman/deptest.c
> index 597eee42..76bf223e 100644
> --- a/src/pacman/deptest.c
> +++ b/src/pacman/deptest.c
> @@ -32,11 +32,13 @@ int pacman_deptest(alpm_list_t *targets)
>   alpm_list_t *i;
>   alpm_list_t *deps = NULL;
>   alpm_db_t *localdb = alpm_get_localdb(config->handle);
> + alpm_list_t *pkgcache = alpm_db_get_pkgcache(localdb);
>  
>   for(i = targets; i; i = alpm_list_next(i)) {
>   char *target = i->data;
>  
> - if(!alpm_find_satisfier(alpm_db_get_pkgcache(localdb), target)) 
> {
> + if(!alpm_db_get_pkg(localdb, target) &&
> + !alpm_find_satisfier(pkgcache, target)) {
>   deps = alpm_list_add(deps, target);
>   }
>   }
> 


[pacman-dev] [PATCH 4/4] pacman: speed up deptest

2019-09-08 Thread morganamilo
Try and find an exact match via pkgcache before iterating the entire
localdb.

Gives a noticeable speed up for exact matches e.g. `pacman -T zlib`

---

Do note this fails for versioned exact matches. "zlib>1" will not take
the faster route because alpm_db_get_pkgfromcache() does not work for
versioned deps.

I do have a solution for this in an alternative patch which adds
alpm_db_find_local_satisfier() "62 insertions(+), 7 deletions(-)"

But is that worth it just for a speed up on -T? Nowhere else really
makes extensive use of searching the localdb.
---
 src/pacman/deptest.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/src/pacman/deptest.c b/src/pacman/deptest.c
index 597eee42..76bf223e 100644
--- a/src/pacman/deptest.c
+++ b/src/pacman/deptest.c
@@ -32,11 +32,13 @@ int pacman_deptest(alpm_list_t *targets)
alpm_list_t *i;
alpm_list_t *deps = NULL;
alpm_db_t *localdb = alpm_get_localdb(config->handle);
+   alpm_list_t *pkgcache = alpm_db_get_pkgcache(localdb);
 
for(i = targets; i; i = alpm_list_next(i)) {
char *target = i->data;
 
-   if(!alpm_find_satisfier(alpm_db_get_pkgcache(localdb), target)) 
{
+   if(!alpm_db_get_pkg(localdb, target) &&
+   !alpm_find_satisfier(pkgcache, target)) {
deps = alpm_list_add(deps, target);
}
}
-- 
2.23.0