implement SYNCFLOOTWORKER so worker can be set to use all the same OFFSET or calculate their own

This commit is contained in:
Marcus 2024-01-06 19:55:56 +01:00
parent ca35351114
commit 2ceb1c42f3
2 changed files with 38 additions and 11 deletions

View file

@ -26,8 +26,19 @@ pixelfloot was built during the 37c3. in its actual state, its just a mess. I ho
- for drawing big areas, like 1280x720, use LARGE mode: `LARGE=true ./pixelfloot.sh floot images/xphg.jpg` - for drawing big areas, like 1280x720, use LARGE mode: `LARGE=true ./pixelfloot.sh floot images/xphg.jpg`
- default field size are 64k lines. You can adjust it with LOLFIELDSIZE: - default field size are 64k lines. You can adjust it with LOLFIELDSIZE:
`LOLFIELDSIZE=16000 LARGE=true ./pixelfloot.sh floot images/xphg.jpg` `LOLFIELDSIZE=16000 LARGE=true ./pixelfloot.sh floot images/xphg.jpg`
- drawing an gif file with proper animation: `LARGE=true ./pixelfloot.sh floot images/dancing_banana.gif` - drawing an gif file with proper animation: `ANIMATION=true ./pixelfloot.sh floot images/dancing_banana.gif`
- Adjust the speed with FRAMETICKTIME in seconds: `FRAMETICKTIME=0.03 LARGE=true ./pixelfloot.sh floot images/shaking_cat.gif` - Adjust the speed with FRAMETICKTIME in seconds: `FRAMETICKTIME=0.03 ANIMATION=true ./pixelfloot.sh floot images/shaking_cat.gif`
## tuning
You can play around with some env vars to optimize your throughput. Most
obvious one is FLOOTFORKS whichs defines how many worker fors are
spawning / tcp sessions you use. Default is 1.
When using more then one worker, it also worth to have a look to
SYNCFLOOTWORKER. This env var (bool) defines if all worker calculate
their own OFFSET or use all the same from `[worker 1]`.
```shell ```shell
$ ./pixelfloot.sh help $ ./pixelfloot.sh help

View file

@ -24,7 +24,7 @@ SHUFMODE="$3"
FLOOTSRUNNING=0 FLOOTSRUNNING=0
test -z "$FLOOTFORKS" && FLOOTFORKS="2" test -z "$FLOOTFORKS" && FLOOTFORKS="1"
test -z $X_MAX && X_MAX=800 test -z $X_MAX && X_MAX=800
test -z $Y_MAX && Y_MAX=600 test -z $Y_MAX && Y_MAX=600
@ -37,6 +37,8 @@ YDIR=0
test -z "$BOUNCESTEP" && BOUNCESTEP=2 test -z "$BOUNCESTEP" && BOUNCESTEP=2
## end bounce ## end bounce
OFFSET_SHM="/dev/shm/pxlflt-offset"
## ANIMATION ## ANIMATION
# convert -coalesce animation.gif target.png -> produces target1.png, target2.png, .. # convert -coalesce animation.gif target.png -> produces target1.png, target2.png, ..
# /dev/shm/foo to store frame counter # /dev/shm/foo to store frame counter
@ -346,18 +348,30 @@ flootworker()
while true while true
do do
if [ $LARGE ] # set offset
if [ $SYNCFLOOTWORKER ]
then then
if [ $iFLOOTWORKER == 1 ]
then
xymode
echo "$OFFSET" > $OFFSET_SHM
fi
echo "$(<${OFFSET_SHM})"
else
xymode xymode
echo "$OFFSET" echo "$OFFSET"
fi
if [ $LARGE ]
then
for i in $(seq 0 $1 | shuf) for i in $(seq 0 $1 | shuf)
do do
echo "${LOL[$i]}" echo "${LOL[$i]}"
done done
elif [ $ANIMATION ] elif [ $ANIMATION ]
then then
xymode #~ xymode
echo "$OFFSET" #~ echo "$OFFSET"
echo "${LOL[$(<${FRAMETOPICK_SHM})]}" echo "${LOL[$(<${FRAMETOPICK_SHM})]}"
#~ i=0 #~ i=0
#~ while [ $i -le $1 ] #~ while [ $i -le $1 ]
@ -366,9 +380,7 @@ flootworker()
#~ i=$(($i+1)) #~ i=$(($i+1))
#~ done #~ done
else else
xymode echo "${LOL[$1]}"
echo "$OFFSET
${LOL[$1]}"
fi fi
done > /dev/tcp/$IPFLOOT/$FLOOTPORT || message warn "[worker ${YELLOW}$iFLOOTWORKER${ENDCOLOR}] transmission ${RED}failed${ENDCOLOR} - maybe you need to decrease ${YELLOW}FLOOTFORKS${ENDCOLOR} or expand/tune your uplink" done > /dev/tcp/$IPFLOOT/$FLOOTPORT || message warn "[worker ${YELLOW}$iFLOOTWORKER${ENDCOLOR}] transmission ${RED}failed${ENDCOLOR} - maybe you need to decrease ${YELLOW}FLOOTFORKS${ENDCOLOR} or expand/tune your uplink"
} }
@ -435,7 +447,7 @@ loadLOL() {
do do
if [ -z "$ALPHACOLOR" ] if [ -z "$ALPHACOLOR" ]
then then
message "shuffle pixels for [worker ${YELLOW}${i}${ENDCOLOR}}" message "shuffle pixels for [worker ${YELLOW}${i}${ENDCOLOR}]"
LOL[$i]="$(echo "$LOL_org" | shuf)" LOL[$i]="$(echo "$LOL_org" | shuf)"
else else
message "remove aplha color ${YELLOW}${ALPHACOLOR}${ENDCOLOR} and shuffle pixels for [worker ${YELLOW}${i}${ENDCOLOR}]" message "remove aplha color ${YELLOW}${ALPHACOLOR}${ENDCOLOR} and shuffle pixels for [worker ${YELLOW}${i}${ENDCOLOR}]"
@ -541,6 +553,10 @@ floot() {
message "starting ${YELLOW}${FLOOTFORKS}${ENDCOLOR} worker" message "starting ${YELLOW}${FLOOTFORKS}${ENDCOLOR} worker"
if [ -n "$SYNCFLOOTWORKER" ] && [ $FLOOTFORKS -gt 1 ]
then
message "SYNCFLOOTWORKER is enabled, all worker use OFFSET from [worker ${YELLOW}1${ENDCOLOR}]"
fi
while true while true
do do
@ -659,7 +675,7 @@ case $1 in
echo "SIZE(int), TEXT(string), FONTSIZE(int), BGCOLOR(hex), COLOR(hex)" echo "SIZE(int), TEXT(string), FONTSIZE(int), BGCOLOR(hex), COLOR(hex)"
echo "BORDERCOLOR(hex), X(int), Y(int), X_MAX(int), Y_MAX(int), H(int), W(int)" echo "BORDERCOLOR(hex), X(int), Y(int), X_MAX(int), Y_MAX(int), H(int), W(int)"
echo "RESIZE(int), ALPHACOLOR(hex), BOUNCESTEP(int), LARGE(bool), LOLFIELDSIZE(int)" echo "RESIZE(int), ALPHACOLOR(hex), BOUNCESTEP(int), LARGE(bool), LOLFIELDSIZE(int)"
echo "ANIMATION(bool), FRAMETICKTIME(float)" echo "ANIMATION(bool), FRAMETICKTIME(float), SYNCFLOOTWORKER(bool)"
exit 1 exit 1
;; ;;