Date: Thu, 23 Aug 2012 23:33:13 +0200 From: Jilles Tjoelker <jilles@stack.nl> To: Kris Moore <kris@pcbsd.org> Cc: Jeremy Messenger <mezz.freebsd@gmail.com>, freebsd-current@freebsd.org, FreeBSD Ports <freebsd-ports@freebsd.org> Subject: Re: pkgng default schedule... registering a few reasons for rethinking the final implementation... Message-ID: <20120823213313.GA56606@stack.nl> In-Reply-To: <50368973.5040202@pcbsd.org> References: <1345739186.30848.YahooMailClassic@web111307.mail.gq1.yahoo.com> <50365F37.7040601@pcbsd.org> <CADLFttcOfBvH6rpyjTQrV12mRBCy1VKDbJJ0aYZW1bLm154v4Q@mail.gmail.com> <50368973.5040202@pcbsd.org>
next in thread | previous in thread | raw e-mail | index | archive | help
On Thu, Aug 23, 2012 at 03:50:11PM -0400, Kris Moore wrote: > Well, it was about time I got to doing a benchmark of this anyway :) > I did quick benchmark of how one of our utilities parses through a list > of 1k packages on a newer i5 system: > First test, using /var/db/pkg/<pkg> check we have been doing: > 0.178s 0:00.31 54.8% > 0.123s 0:00.26 61.5% > 0.099s 0:00.15 60.0% > Second test, using "pkg info <pkg>": > 5.347s 0:11.41 91.7% > 5.444s 0:11.52 91.3% > 5.878s 0:11.32 91.4% > The pkg info command is quite a bit slower in this case, but 5 seconds > isn't horrible. > [snip] > The only way around It I've found is to do a quick "pkg info" on the > entire DB, dump that to a list, then begin to grep through that list for > each item, but it still takes 10~ seconds on the atom. That may be what > I end up having to do, but it still stinks to go from a half a second > startup, to 10 seconds each time. Any other ideas on how to do this > faster with the new pkgng? Don't use grep: the list is not big enough to make it worth it. What should work fairly efficiently is to store a list of packages in a shell variable once and then check each sub-package without external programs. list=$(pkg query %n-%v) for pkgwithversion in ...; do case $'\n'$list$'\n' in *$'\n'"$pkgwithversion"$'\n'*) echo yes ;; *) echo no ;; esac done This does assume that the list does not change during the loop. Also, instead of pName=`echo $pkg | rev | cut -d "-" -f 2-25 | rev` try pName=${pkg%-*} and use arithmetic expansion ($((...))) instead of invoking expr where possible. -- Jilles Tjoelker
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20120823213313.GA56606>