zebrunner / appium

Enhanced Appium for Elastic Selenium Grid/MCloud services
8 stars 3 forks source link

investigate benefits of `inotifywait` for video recording waiters #370

Closed vdelendik closed 5 months ago

vdelendik commented 6 months ago

https://unix.stackexchange.com/questions/185283/how-do-i-wait-for-a-file-in-the-shell-script until we migrate to the independent recorder container we could inject files creation on session startup inside appium log. Using inotifywait we could detect session startup effectively without sleeps and log file grep which use CPU...

the same about video recording finish, just wait until recording stop file appear and generate it by appium on finally when session destroyed, deleted, timed out etc.

vdelendik commented 6 months ago

notifywait vs while + sleep performance:

while :; do
  [ -f /opt/.stopped-ffmpeg-1234 ]
  sleep 0.1
done
\/\/\/
alpine:3.19.1 / while + sleep 0.1 / 100 threads

CONTAINER ID   NAME      **CPU %**     MEM USAGE / LIMIT     MEM %     NET I/O     BLOCK I/O    PIDS
2b6e9b37d557   testc     **160.06%**   47.55MiB / 31.07GiB   0.15%     876B / 0B   0B / 4.1kB   202
---
inotifywait -e create,moved_to,attrib --include '/opt/.stopped-ffmpeg-1234' -qq /tmp 
\/\/\/
alpine:3.19.1 / inotifywait / 100 threads

CONTAINER ID   NAME      **CPU %**     MEM USAGE / LIMIT     MEM %     NET I/O       BLOCK I/O     PIDS
60a92a2767ca   testc     **0.00%**     50.07MiB / 31.07GiB   0.16%     1.09kB / 0B   0B / 8.19kB   202
---
while :; do
  [ -f /opt/.stopped-ffmpeg-1234 ]
done
\/\/\/
alpine:3.19.1 / while / 100 threads

CONTAINER ID   NAME      **CPU %**     MEM USAGE / LIMIT     MEM %     NET I/O     BLOCK I/O    PIDS
1b19a34350b1   testc     **843.22%**   32.93MiB / 31.07GiB   0.10%     946B / 0B   0B / 4.1kB   102

confirmed inotifywait is much more efficient

vdelendik commented 5 months ago

closing as actual implementation tracked by #377