ActivityWatch / aw-watcher-window

Cross-platform window watcher (for use with ActivityWatch)
Mozilla Public License 2.0
91 stars 53 forks source link

Run macos applescript in fork #65

Closed iloveitaly closed 1 year ago

iloveitaly commented 2 years ago

unfortunately, it's well-documented that applescript leaks memory like crazy:

It's not designed to be executed over and over by the same process. In our case, this resulted in massive memory usage over time. To work around this, this forks a process to run our applescript and kill it every so often to clean out it's memory usage.

It's not pretty, but neither is 1GB memory usage for the window watcher. @ErikBjare I'm curious your take on this approach and if I should clean it up for merging.

iloveitaly commented 2 years ago

@ErikBjare I just tried from source. I'll build the app and see it things continue to work.

Question for you: what are your thoughts on increasing poll time to 3s? Polling via applescript takes up a non-trivial amount of CPU time and 1s resolution doesn't get me anything vs 3s (or 10s in my case).

ErikBjare commented 2 years ago

Question for you: what are your thoughts on increasing poll time to 3s? Polling via applescript takes up a non-trivial amount of CPU time and 1s resolution doesn't get me anything vs 3s (or 10s in my case).

The 1s poll time was originally chosen on a whim as we weren't sure how much it would affect the data. Should probably run a testing instance parallel to my prod one and check the actual time diffs with 3s, 10s, etc, but that would be some work.

For now, we keep the 1s, but if we have good data suggesting that 3s makes little difference, we can switch to that (would yield a general performance improvement, as number of events would prob reduce by more than >3x).

iloveitaly commented 1 year ago

@ErikBjare with the new swift-based notifications in place, we won't need this. At some point we should rip out the python-based tracker for macOS as well.