From: Mike Frysinger Date: Sat, 9 Jun 2012 02:53:58 +0000 (-0400) Subject: improve parallel behavior X-Git-Url: https://git.wh0rd.org/?a=commitdiff_plain;h=b5092d38c0c6f84a2f45ca59515a4adef5cac209;p=home.git improve parallel behavior --- diff --git a/.bin/r b/.bin/r index 6771348..d204eb1 100755 --- a/.bin/r +++ b/.bin/r @@ -20,7 +20,7 @@ rebase) if [[ $1 == "all" ]] ; then shift if [[ $# -eq 0 ]] ; then - exec r forall -c 'r rb all .' + exec r forall -p -c 'r rb all .' fi branches=$(g b | awk ' @@ -37,7 +37,7 @@ rebase) [[ -z ${branches} ]] && exit 0 eval $(bash-colors --env) - echo "${GOOD}### ${PWD}${NORMAL}" + #echo "${GOOD}### ${PWD}${NORMAL}" for b in ${branches} ; do echo " ${HILITE}### $b${NORMAL}" g co -q $b || exit 1 @@ -64,7 +64,13 @@ sb-push) echo "pushing projects from ${root}" - pids=() + pipe=$(mktemp) + rm -f "${pipe}" + mkfifo "${pipe}" + exec {ctlfd}<>"${pipe}" + rm -f "${pipe}" + jobs=0 + rlist=$(r list) tcnt=$(echo "${rlist}" | wc -l) cnt=1 @@ -77,17 +83,20 @@ sb-push) ${#tcnt} $((cnt++)) ${tcnt} $(( cnt * 100 / tcnt )) ${proj} src="${sync_branch}" g l -1 ${src} >& /dev/null || src= - ( g push --force ${remote}/${proj} ${src}:refs/sandbox/${USER}/${sync_branch} >/dev/null ) & + ( + g push --force ${remote}/${proj} ${src}:refs/sandbox/${USER}/${sync_branch} >/dev/null + echo ${BASHPID} $? >&${ctlfd} + ) & # ssh servers do not like it when you hammer them :) # Received disconnect from 74.125.248.80: 7: Too many concurrent connections # fatal: The remote end hung up unexpectedly - pids+=( $! ) - if [[ ${#pids[@]} -eq 20 ]] ; then - wait ${pids[@]:0:3} - pids=( ${pids[@]:3} ) + : $(( ++jobs )) + if [[ ${jobs} -eq 16 ]] ; then + read -r -u ${ctlfd} pid ret + : $(( --jobs )) fi - done <<<"$(r list)" + done < <(r list) wait exit 0