FAQ Search Today's Posts Mark Forums Read
» Video Reviews

» Linux Archive

Linux-archive is a website aiming to archive linux email lists and to make them easily accessible for linux users/developers.


» Sponsor

» Partners

» Sponsor

Go Back   Linux Archive > ArchLinux > ArchLinux Pacman Development

 
 
LinkBack Thread Tools
 
Old 11-16-2009, 01:39 AM
Dan McGee
 
Default print installed packages

On Mon, Sep 7, 2009 at 4:43 PM, Xavier Chantry <shiningxc@gmail.com> wrote:
> Signed-off-by: Xavier Chantry <shiningxc@gmail.com>

I like the idea of this one, but it does have a pretty big performance
hit. Do we care?

I ran the following:
$ valgrind --tool=callgrind ./src/pacman/.libs/lt-pacman -Ss a >/dev/null

And then looked at the results in kcachegrind. 40% of the total time
was spent in print_installed() or below.

-Dan

> ---
> *src/pacman/sync.c | * 24 ++++++++++++++++++++++--
> *1 files changed, 22 insertions(+), 2 deletions(-)
>
> diff --git a/src/pacman/sync.c b/src/pacman/sync.c
> index 4f101f9..896d028 100644
> --- a/src/pacman/sync.c
> +++ b/src/pacman/sync.c
> @@ -274,6 +274,21 @@ static int sync_synctree(int level, alpm_list_t *syncs)
> * * * *return(success > 0);
> *}
>
> +static void print_installed(pmpkg_t *pkg)
> +{
> + * * * const char *pkgname = alpm_pkg_get_name(pkg);
> + * * * const char *pkgver = alpm_pkg_get_version(pkg);
> + * * * pmpkg_t *lpkg = alpm_db_get_pkg(db_local, pkgname);
> + * * * if(lpkg) {
> + * * * * * * * const char *lpkgver = alpm_pkg_get_version(lpkg);
> + * * * * * * * if(strcmp(lpkgver,pkgver) == 0) {
> + * * * * * * * * * * * printf(" [%s]", _("installed"));
> + * * * * * * * } else {
> + * * * * * * * * * * * printf(_(" [%s: %s]"), _("installed"), lpkgver);
> + * * * * * * * }
> + * * * }
> +}
> +
> */* search the sync dbs for a matching package */
> *static int sync_search(alpm_list_t *syncs, alpm_list_t *targets)
> *{
> @@ -330,6 +345,8 @@ static int sync_search(alpm_list_t *syncs, alpm_list_t *targets)
> * * * * * * * * * * * * * * * * * * * *printf(")");
> * * * * * * * * * * * * * * * *}
>
> + * * * * * * * * * * * * * * * print_installed(pkg);
> +
> * * * * * * * * * * * * * * * */* we need a newline and initial indent first */
> * * * * * * * * * * * * * * * *printf("
* *");
> * * * * * * * * * * * * * * * *indentprint(alpm_pkg_get_desc(pkg), 4);
> @@ -514,9 +531,12 @@ static int sync_list(alpm_list_t *syncs, alpm_list_t *targets)
>
> * * * * * * * *for(j = alpm_db_get_pkgcache(db); j; j = alpm_list_next(j)) {
> * * * * * * * * * * * *pmpkg_t *pkg = alpm_list_getdata(j);
> +
> * * * * * * * * * * * *if (!config->quiet) {
> - * * * * * * * * * * * * * * * printf("%s %s %s
", alpm_db_get_name(db), alpm_pkg_get_name(pkg),
> - * * * * * * * * * * * * * * * * * * * * * * * * * * * *alpm_pkg_get_version(pkg));
> + * * * * * * * * * * * * * * * printf("%s %s %s", alpm_db_get_name(db), alpm_pkg_get_name(pkg),
> + * * * * * * * * * * * * * * * * * * * * * * * alpm_pkg_get_version(pkg));
> + * * * * * * * * * * * * * * * print_installed(pkg);
> + * * * * * * * * * * * * * * * printf("
");
> * * * * * * * * * * * *} else {
> * * * * * * * * * * * * * * * *printf("%s
", alpm_pkg_get_name(pkg));
> * * * * * * * * * * * *}
> --
> 1.6.4.2
>
>
>
 
Old 11-16-2009, 01:20 PM
Xavier
 
Default print installed packages

On Mon, Nov 16, 2009 at 3:39 AM, Dan McGee <dpmcgee@gmail.com> wrote:
> On Mon, Sep 7, 2009 at 4:43 PM, Xavier Chantry <shiningxc@gmail.com> wrote:
>> Signed-off-by: Xavier Chantry <shiningxc@gmail.com>
>
> I like the idea of this one, but it does have a pretty big performance
> hit. Do we care?
>
> I ran the following:
> $ valgrind --tool=callgrind ./src/pacman/.libs/lt-pacman -Ss a >/dev/null
>
> And then looked at the results in kcachegrind. 40% of the total time
> was spent in print_installed() or below.
>

I think db_get_pkg is widely inefficient because our data structures suck.
And if it's a cold run, it's much worse because of the crappy
filesystem backend.

Anyway I am undecided. I don't even know what I care the least about
(the performance hit or this feature).

A compromise would be to not have this feature enabled by default.
either using a flag or an option.
 

Thread Tools




All times are GMT. The time now is 12:17 PM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright 2007 - 2008, www.linux-archive.org