From owner-freebsd-current Sun Jan 23 20:20:12 2000 Delivered-To: freebsd-current@freebsd.org Received: from tomts2-srv.bellnexxia.net (tomts2.bellnexxia.net [209.226.175.140]) by hub.freebsd.org (Postfix) with ESMTP id 1055015110 for ; Sun, 23 Jan 2000 20:20:06 -0800 (PST) (envelope-from hoek@FreeBSD.org) Received: from localhost.nowhere ([206.172.235.114]) by tomts2-srv.bellnexxia.net (InterMail vM.4.01.02.07 201-229-116-107) with ESMTP id <20000124042003.IEAZ26813.tomts2-srv.bellnexxia.net@localhost.nowhere>; Sun, 23 Jan 2000 23:20:03 -0500 Received: (from tim@localhost) by localhost.nowhere (8.9.3/8.9.1) id XAA86497; Sun, 23 Jan 2000 23:19:24 -0500 (EST) (envelope-from tim) Date: Sun, 23 Jan 2000 23:19:24 -0500 From: Tim Vanderhoek To: Warner Losh Cc: Brian Somers , current@FreeBSD.ORG Subject: Re: Please help spread the CVSup mirror load more evenly Message-ID: <20000123231924.A81831@mad> References: <200001231303.NAA01359@hak.lan.Awfulhak.org> <200001240156.SAA47712@harmony.village.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Mailer: Mutt 0.95i In-Reply-To: <200001240156.SAA47712@harmony.village.org>; from Warner Losh on Sun, Jan 23, 2000 at 06:56:39PM -0700 Sender: owner-freebsd-current@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG On Sun, Jan 23, 2000 at 06:56:39PM -0700, Warner Losh wrote: > > Each host gets a value of 1 (unless you go in and tweak it). Hosts > are tried in order of their values and in some unspecified order in [...] > Each time you successfully connect, you get a bonus of B. I think you need to keep an element of randomness to prevent "good enough" from defeating "best". Bonus B should be weighted by wire speed. I don't know how to make cvsup spit this out when in batch mode. This isn't exactly the algorithm you described. Finding differences is left as an exercise. Acceptability of the constants chosen for the algorithm varies with expected usage pattern of script. This is the type of thing that should really be done in cvsup itself, but I don't feel like learning Modula-3... :) I disclaim responsibility for any stupid errors. All subtle errors are completely my fault. PS: I don't believe this script will work under Linux. Oops. ;-) Sample cvshosts.dat file: 50 cvsup1.freebsd.org 50 cvsup2.freebsd.org 50 cvsup3.freebsd.org 50 cvsup4.freebsd.org 50 cvsup5.freebsd.org 50 cvsup6.freebsd.org 50 cvsup7.freebsd.org 50 cvsup8.freebsd.org And the script, #! /bin/sh DATFILE=cvshosts.dat if [ -z "$1" ]; then fairings=$( (while read -t 0 host do if [ "${host%%[ ]*}" -eq 0 ] then continue fi fairings="${fairings} $((${host%% *} * $(jot -r 1 5 9) + $(jot -r 1 1 3))) ${host#*[ ]}" done; echo "${fairings}") < ${DATFILE}) hosts=`echo "$fairings" | sort -rn | awk '{print $2}'` else hosts=$1 shift fi # Potential security problem, probably trap 'rm -f /tmp/cvshosts.dat.$$' 0 cp $DATFILE /tmp/cvshosts.dat.$$ echo "Will try hosts $(echo $hosts)" for host in $hosts do echo "Using host $host" if cvsup -1 -P m -s -g ~/bin/sup/fbsd-supfile -L 2 -h $host then # 1 works fairly well as a 2, also perl -pi -e \ 's/^(\d+)[ \t]+'"$host"'[ \t]*$/int (($a=$1+1)>100?10:$a) . "'" $host"'"/e' \ $DATFILE exit; else perl -pi -e \ 's/^(\d+)[ \t]+'"$host"'[ \t]*$/int (($a=$1-$1\/6)<1?1:$a) . "'" $host"'"/e' \ $DATFILE fi done mv /tmp/cvshosts.dat.$$ $DATFILE trap 0 -- Signature withheld by request of author. To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-current" in the body of the message