From owner-freebsd-current@FreeBSD.ORG Thu Aug 23 21:33:16 2012 Return-Path: Delivered-To: freebsd-current@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 98FB5106566C; Thu, 23 Aug 2012 21:33:16 +0000 (UTC) (envelope-from jilles@stack.nl) Received: from mx1.stack.nl (relay04.stack.nl [IPv6:2001:610:1108:5010::107]) by mx1.freebsd.org (Postfix) with ESMTP id 301068FC17; Thu, 23 Aug 2012 21:33:16 +0000 (UTC) Received: from snail.stack.nl (snail.stack.nl [IPv6:2001:610:1108:5010::131]) by mx1.stack.nl (Postfix) with ESMTP id B50341DD5B8; Thu, 23 Aug 2012 23:33:13 +0200 (CEST) Received: by snail.stack.nl (Postfix, from userid 1677) id 90CA62847B; Thu, 23 Aug 2012 23:33:13 +0200 (CEST) Date: Thu, 23 Aug 2012 23:33:13 +0200 From: Jilles Tjoelker To: Kris Moore Message-ID: <20120823213313.GA56606@stack.nl> References: <1345739186.30848.YahooMailClassic@web111307.mail.gq1.yahoo.com> <50365F37.7040601@pcbsd.org> <50368973.5040202@pcbsd.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <50368973.5040202@pcbsd.org> User-Agent: Mutt/1.5.21 (2010-09-15) Cc: Jeremy Messenger , freebsd-current@freebsd.org, FreeBSD Ports Subject: Re: pkgng default schedule... registering a few reasons for rethinking the final implementation... X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 23 Aug 2012 21:33:16 -0000 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/ 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 ": > 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