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 > Gentoo > Gentoo Portage Developer

 
 
LinkBack Thread Tools
 
Old 02-08-2009, 04:21 AM
Brian Harring
 
Default equery: deprecate --category filtering in belongs

On Sun, Feb 08, 2009 at 02:07:08PM +0900, Douglas Anderson wrote:
> Hi, does anyone use --category filtering in equery belongs? I want to
> get rid of it, or at least deprecate it. My reasoning:
>
> * We use 'equery belongs' when don't know to what package a file
> belongs. Even if we have a suspicion, most users would have to look up
> the category of the package before typing it in.
> * Even if you happen to know the exact category of the package that
> installed the file (why are you using belongs?), typing
> --category=app-portage takes more time than is saved by filtering by
> category (about 5 seconds more by my unscientific test).
>
> Even in a script setting, I see no use for this. The time saved is minuscule:
>
> $ time equery belongs /usr/bin/equery --category app-portage
> [ Searching for file(s) /usr/bin/equery in app-portage... ]
> app-portage/gentoolkit-0.2.4.2-r1 (/usr/bin/equery)
>
> real 0m4.002s
> user 0m3.680s
> sys 0m0.076s
> $ time equery belongs /usr/bin/equery
> [ Searching for file(s) /usr/bin/equery in *... ]
> app-portage/gentoolkit-0.2.4.2-r1 (/usr/bin/equery)
>
> real 0m4.205s
> user 0m3.738s
> sys 0m0.102s

You should do profiling, and *verify* category actually works; it
should be able to make a world of difference. Case in point via
pkgcore-

ferringb@beast ~ $ time pquery --owns /usr/bin/equery
app-portage/gentoolkit-0.2.4.2-r1

real 0m1.162s
user 0m1.142s
sys 0m0.020s
ferringb@beast ~ $ time pquery --owns /usr/bin/equery 'app-portage/*'
app-portage/gentoolkit-0.2.4.2-r1

real 0m0.168s
user 0m0.156s
sys 0m0.011s


Yes it's not equery, but I *know* pkgcores implementation works thus
using it to point out the speed difference if implemented correctly.

It would probably help if the category support was enabled in the
code, also (quick check of equery shows the cat filtering is
disabled).

~harring
 
Old 02-08-2009, 05:30 AM
Brian Harring
 
Default equery: deprecate --category filtering in belongs

patch attached against 0.2.4.2-r1; rough stats follow;

full cold cache

[ Searching for file(s) /usr/bin/equery in *... ]
app-portage/gentoolkit-0.2.4.2-r1 (/usr/bin/equery)

real 0m10.320s
user 0m0.733s
sys 0m0.162s

[ Searching for file(s) /usr/bin/equery in app-portage... ]
app-portage/gentoolkit-0.2.4.2-r1 (/usr/bin/equery)

real 0m8.512s
user 0m0.315s
sys 0m0.124s

That particular cold cache is a *full* cold cache; not the best test
imo since most users have at least some chunks of portage
configuration/python cached.


Cold cache, with equery --help primer to warm the cache; CONTENTS
(what belongs operates on) is still out of the cache however making
this a bit more likely use scenario.

[ Searching for file(s) /usr/bin/equery in *... ]
app-portage/gentoolkit-0.2.4.2-r1 (/usr/bin/equery)

real 0m2.335s
user 0m0.670s
sys 0m0.050s

[ Searching for file(s) /usr/bin/equery in app-portage... ]
app-portage/gentoolkit-0.2.4.2-r1 (/usr/bin/equery)

real 0m0.391s
user 0m0.248s
sys 0m0.046s

Pretty heavy difference, no?


hotcache:
[ Searching for file(s) /usr/bin/equery in *... ]
app-portage/gentoolkit-0.2.4.2-r1 (/usr/bin/equery)

real 0m0.710s
user 0m0.661s
sys 0m0.047s

[ Searching for file(s) /usr/bin/equery in app-portage... ]
app-portage/gentoolkit-0.2.4.2-r1 (/usr/bin/equery)

real 0m0.291s
user 0m0.237s
sys 0m0.053s


Mind you this isn't multiple runs, so the numbers are rough
approximations- that said they're fairly representative.

Strongly suggest y'all keep category support (although I'll keep on
using pquery instead .

Cheers,
~harring
--- /usr/bin/equery 2009-02-07 13:16:51.000000000 -0800
+++ /home/ferringb/equery 2009-02-07 14:15:52.000000000 -0800
@@ -345,7 +345,7 @@
need_help = 1
break
elif x in ["-c", "--category"]:
- opts["category"] = args[i+1]
+ opts["category"] = args[i+1].rstrip("/")
skip = 1
elif x in ["-e", "--earlyout"]:
opts["earlyOut"] = 1
@@ -383,16 +383,14 @@
die(2, "The query '" + pp.regexpquery(q) + "' does not appear to be a valid regular expression")

# Pick out only selected categories
- cat = opts["category"]
- filter_fn = None
- if cat != "*":
- filter_fn = lambda x: x.find(cat+"/")==0

+ cat = opts["category"]
if not Config["piping"] and Config["verbosityLevel"] >= 3:
print_info(3, "[ Searching for file(s) " + pp.regexpquery(",".join(query)) + " in " + pp.cpv(cat) + "... ]")

matches = portage.db["/"]["vartree"].dbapi.cpv_all()
- #matches = gentoolkit.find_all_installed_packages(filter_fn)
+ if cat != "*":
+ matches = (x for x in matches if x.startswith(cat))

found = 0
 

Thread Tools




All times are GMT. The time now is 07:34 AM.

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