[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[abcde] [patch] Improve parallelism on SMP systems
The following patch is a first stab at fixing abcde 2.0.2 so that it makes
better use of SMP systems when MAXPROCS > 1.
The basic problem with stock 2.0.2 is that ENCODELOCATIONS gets constructed
with MAXPROCS %local% tokens. When abcde tries to figure out if there is a
free encoding resource, it sees that one %local% is already encoding a
track, and goes into a sleep loop.
This patch fixes this by using %local1%, %local2%, etc., up to the setting
of MAXPROCS. As long as there are available tracks waiting to be encoded,
it will spawn up to MAXPROCS encoders. The encoding process is always
backgrounded (not just for remote encoders), as well, so the main process
has a chance to loop around and start the next track if it can.
The only problem that I've found with this is that the output of the
encoders, once loud output is enabled, will get mixed up on-screen. If I
come up with a clever way to fix this, I'll send another patch.
Feedback would be appreciated.
--- /usr/local/bin/abcde Fri Jan 25 19:01:45 2002
+++ bin/abcde Fri Jan 25 19:20:55 2002
@@ -261,26 +261,32 @@
run_command '' echo "Encoding track $1 of $TRACKS: $TRACKNAME..."
case "$OUTPUTTYPE" in
mp3)
- if [ "$2" = "%local%" ]; then
+ case "$2" in
+ %local*%)
case "$ENCODERSYNTAX" in
lame|gogo) run_command encodetrack-$1 nice
$ENCNICE $ENCODER $ENCODEROPTS "$IN" "$OUT" ;;
bladeenc) run_command encodetrack-$1 nice $ENCNICE
$ENCODER $ENCODEROPTS -quit "$IN" ;;
l3enc|xingmp3enc) run_command encodetrack-$1 nice
$ENCNICE $ENCODER "$IN" "$OUT" $ENCODEROPTS ;;
mp3enc) run_command encodetrack-$1 nice $ENCNICE
$ENCODER -if "$IN" -of "$OUT" $ENCODEROPTS ;;
esac
- else
+ ;;
+ *)
run_command encodetrack-$1 $DISTMP3 $DISTMP3OPTS
"$2" "$IN" "$OUT" >/dev/null 2>&1
- fi
+ ;;
+ esac
;;
ogg)
- if [ "$2" = "%local%" ]; then
+ case "$2" in
+ %local*%)
case "$ENCODERSYNTAX" in
vorbize) run_command encodetrack-$1 nice $ENCNICE
$ENCODER $ENCODEROPTS -w "$OUT" "$IN" ;;
oggenc) run_command encodetrack-$1 nice $ENCNICE
$ENCODER $ENCODEROPTS -o "$OUT" "$IN" ;;
esac
- else
+ ;;
+ *)
run_command encodetrack-$1 $DISTMP3 $DISTMP3OPTS
"$2" "$IN" "$OUT" >/dev/null 2>&1
- fi
+ ;;
+ esac
;;
esac
# Only remove .wav if the encoding succeeded
@@ -1182,7 +1188,7 @@
if [ "$MAXPROCS" != "0" ]; then
for NUM in $(seq 1 "$MAXPROCS")
do
- ENCODELOCATIONS="$ENCODELOCATIONS %local%"
+ ENCODELOCATIONS="$ENCODELOCATIONS %local$NUM%"
done
fi
# Strip whitespace
@@ -1239,44 +1245,25 @@
TRACKNAME=$(grep ^TTITLE$CDDBTRACKNUM= "$CDDBDATA" | head
-1 | cut -f2 -d= | tr -d \[:cntrl:\])
splitvarious
fi
- if [ "$LOCATION" = "%local%" ]; then
- if [ "$DOENCODE" = "y" ]; then
- if checkstatus readtrack-$UTRACKNUM; then
- if checkstatus encodetrack-$UTRACKNUM; then
:; else do_encode $UTRACKNUM $LOCATION; fi
- fi
- fi
- if [ "$DOTAG" = "y" ]; then
- if checkstatus encodetrack-$UTRACKNUM; then
- if checkstatus tagtrack-$UTRACKNUM; then :;
else do_tag $UTRACKNUM; fi
- fi
- fi
- if [ "$DOMOVE" = "y" ]; then
- if checkstatus tagtrack-$UTRACKNUM; then
- if checkstatus movetrack-$UTRACKNUM; then
:; else do_move $UTRACKNUM; fi
- fi
- fi
- else
- # You can't tag a file before it's finished encoding -
- # thus all of this is backgrounded together
- # (This is a copy of the above with a "( ) &" wrapped
around it)
- (
- if [ "$DOENCODE" = "y" ]; then
- if checkstatus readtrack-$UTRACKNUM; then
- if checkstatus encodetrack-$UTRACKNUM; then
:; else do_encode $UTRACKNUM $LOCATION; fi
- fi
+ # You can't tag a file before it's finished encoding -
+ # thus all of this is backgrounded together
+ (
+ if [ "$DOENCODE" = "y" ]; then
+ if checkstatus readtrack-$UTRACKNUM; then
+ if checkstatus encodetrack-$UTRACKNUM; then :; else
do_encode $UTRACKNUM $LOCATION; fi
fi
- if [ "$DOTAG" = "y" ]; then
- if checkstatus encodetrack-$UTRACKNUM; then
- if checkstatus tagtrack-$UTRACKNUM; then :;
else do_tag $UTRACKNUM; fi
- fi
+ fi
+ if [ "$DOTAG" = "y" ]; then
+ if checkstatus encodetrack-$UTRACKNUM; then
+ if checkstatus tagtrack-$UTRACKNUM; then :; else
do_tag $UTRACKNUM; fi
fi
- if [ "$DOMOVE" = "y" ]; then
- if checkstatus tagtrack-$UTRACKNUM; then
- if checkstatus movetrack-$UTRACKNUM; then
:; else do_move $UTRACKNUM; fi
- fi
+ fi
+ if [ "$DOMOVE" = "y" ]; then
+ if checkstatus tagtrack-$UTRACKNUM; then
+ if checkstatus movetrack-$UTRACKNUM; then :; else
do_move $UTRACKNUM; fi
fi
- ) &
fi
+ ) &
done
# Go through it again and make sure there's no distmp3 stragglers, otherwise
# we'll delete the files they're working on
--
Steve Madsen <steve@moonglade.com>
To unsubscribe: echo unsubscribe | mail abcde-request@whimsica.lly.org