Battery impact of flows

72 views
Skip to first unread message

Shari Shark

unread,
Aug 2, 2023, 12:26:03 PM8/2/23
to automa...@googlegroups.com
Hi, I like to understand if there's any impact on battery if I have more flows. 

What I have is a monitor block which monitors a directory for any file changes. There can be multiple files. Subsequently, upon detecting changes in each file, it'll fork a child process and loop back to the monitor block. 

IMG_20230803_000959.jpg

The advantage of this approach is there's only one monitor block and only 1 fiber, no matter the number of files. And hence, lesser battery usage. However, the disadvantage is that if there's multiple changes happening to multiple files within a few milliseconds apart, this can miss change events.

The alternative is to fork a monitor block for each file, so that each monitor will only monitor 1 file. Meaning if I have 100 files in the directory, 100 fibers will be forked. This will guarantee no files are missed.

IMG_20230803_001018.jpg

So, my question is, for the equivalent setup, is there impact on battery when there's more flows? 


Henrik "The Developer" Lindqvist

unread,
Aug 3, 2023, 4:42:17 PM8/3/23
to Automate
Forking is before doing any processing is almost always preferable.
This particular example is a bit misleading since only showing a notification often not the only action performed, also here it depends on how the File monitor is configured.

Shari Shark

unread,
Aug 3, 2023, 5:52:52 PM8/3/23
to automa...@googlegroups.com
yes the processing is much more than showing a notification. It was just an example, but the processing either both before forking or after forging is the same.

The file monitor in both before or after forking is configured to listen to only file modified event.

Yes, forking before processing would be preferable as the threads are dedicated. But does it cause higher battery consumption? 

--
You received this message because you are subscribed to the Google Groups "Automate" group.
To unsubscribe from this group and stop receiving emails from it, send an email to automate-use...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/automate-user/1318f87e-23dc-4b51-b3e2-32ac76a3690bn%40googlegroups.com.

Henrik "The Developer" Lindqvist

unread,
Aug 4, 2023, 7:43:43 AM8/4/23
to Automate
Generally a fork makes no difference in battery usage, but it depends on what event the fork awaits.
Specifically, e.g. a file monitor can watch an entire directory for file changes, instead of using multiple watchers, one for a each file. The former is probably more "efficient".

Shari Shark

unread,
Aug 4, 2023, 8:58:11 AM8/4/23
to automa...@googlegroups.com
Yes, using 1 monitor to watch multiple is moor efficient. But the trade-off is, if multiple events occur at the same time, the monitor block will miss certain events.

Thus it's a trade-off between efficiency and battery performance (if any). Hence my question. I'm not sure if I'm over optimising, that's why I like to know if there's any info on this. 

Henrik "The Developer" Lindqvist

unread,
Aug 6, 2023, 7:01:31 AM8/6/23
to Automate
If it's a 10s of files, then it doesn't matter, 100s or 1000s then Fork could become problem.
Reply all
Reply to author
Forward
0 new messages