Re: pkgng default schedule... registering a few reasons for rethinking the final implementation...

From: Jilles Tjoelker <jilles_at_stack.nl>
Date: Thu, 23 Aug 2012 23:33:13 +0200
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
Received on Thu Aug 23 2012 - 19:33:16 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:40:30 UTC