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`
- default field size are 64k lines. You can adjust it with LOLFIELDSIZE:
`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`
- Adjust the speed with FRAMETICKTIME in seconds: `FRAMETICKTIME=0.03 LARGE=true ./pixelfloot.sh floot images/shaking_cat.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 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
$ ./pixelfloot.sh help

View File

@ -24,7 +24,7 @@ SHUFMODE="$3"
FLOOTSRUNNING=0
test -z "$FLOOTFORKS" && FLOOTFORKS="2"
test -z "$FLOOTFORKS" && FLOOTFORKS="1"
test -z $X_MAX && X_MAX=800
test -z $Y_MAX && Y_MAX=600
@ -37,6 +37,8 @@ YDIR=0
test -z "$BOUNCESTEP" && BOUNCESTEP=2
## end bounce
OFFSET_SHM="/dev/shm/pxlflt-offset"
## ANIMATION
# convert -coalesce animation.gif target.png -> produces target1.png, target2.png, ..
# /dev/shm/foo to store frame counter
@ -346,18 +348,30 @@ flootworker()
while true
do
if [ $LARGE ]
# set offset
if [ $SYNCFLOOTWORKER ]
then
if [ $iFLOOTWORKER == 1 ]
then
xymode
echo "$OFFSET" > $OFFSET_SHM
fi
echo "$(<${OFFSET_SHM})"
else
xymode
echo "$OFFSET"
fi
if [ $LARGE ]
then
for i in $(seq 0 $1 | shuf)
do
echo "${LOL[$i]}"
done
elif [ $ANIMATION ]
then
xymode
echo "$OFFSET"
#~ xymode
#~ echo "$OFFSET"
echo "${LOL[$(<${FRAMETOPICK_SHM})]}"
#~ i=0
#~ while [ $i -le $1 ]
@ -366,9 +380,7 @@ flootworker()
#~ i=$(($i+1))
#~ done
else
xymode
echo "$OFFSET
${LOL[$1]}"
echo "${LOL[$1]}"
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"
}
@ -435,7 +447,7 @@ loadLOL() {
do
if [ -z "$ALPHACOLOR" ]
then
message "shuffle pixels for [worker ${YELLOW}${i}${ENDCOLOR}}"
message "shuffle pixels for [worker ${YELLOW}${i}${ENDCOLOR}]"
LOL[$i]="$(echo "$LOL_org" | shuf)"
else
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"
if [ -n "$SYNCFLOOTWORKER" ] && [ $FLOOTFORKS -gt 1 ]
then
message "SYNCFLOOTWORKER is enabled, all worker use OFFSET from [worker ${YELLOW}1${ENDCOLOR}]"
fi
while true
do
@ -659,7 +675,7 @@ case $1 in
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 "RESIZE(int), ALPHACOLOR(hex), BOUNCESTEP(int), LARGE(bool), LOLFIELDSIZE(int)"
echo "ANIMATION(bool), FRAMETICKTIME(float)"
echo "ANIMATION(bool), FRAMETICKTIME(float), SYNCFLOOTWORKER(bool)"
exit 1
;;