zazu icon indicating copy to clipboard operation
zazu copied to clipboard

Resource usage

Open jlaffaye opened this issue 7 years ago • 5 comments

Expected Behavior

No resource usage when idle in the background

Actual Behavior

zazu 0.4 is consuming cpu, when no window is launched

Steps to reproduce the behavior

Disable every plugins but tinytacoteam/zazu-calculator, to be sure that no plugin is doing background tasks. Monitor zazu energy impact in activity monitor.

Versions

  • Zazu: 0.4
  • OS: MacOS 10.12.3

jlaffaye avatar Mar 14 '17 21:03 jlaffaye

maybe due to the setInterval in Notification.

jlaffaye avatar Mar 14 '17 22:03 jlaffaye

If you don't mind making a few custom builds, I'd love to try out a few things.

  1. Notification like you said does have a setInterval, so it would be interesting to remove that interval for a test. I think this is unlikely however, but if this is the case we could increase the interval to a higher number.

https://github.com/tinytacoteam/zazu/blob/b35090b75d481077585e701aeb667ced05c60f6a/app/lib/notification.js#L27-L31

  1. We "resize" the launch window every 125ms. We should take this out and try it as well. This will make zazu look a little off. The fix here is to either add more conditions before doing any javascript, or have the window communicate out that the size has changed instead of polling it constantly.

https://github.com/tinytacoteam/zazu/blob/1631cee39db3fdcde910fbedf962fbaae853b161/app/helpers/window.js#L19-L24

Lastly, If neither of these work it's possible to take a profile via the dev tools in zazu that could reveal what code is running.

bayleedev avatar Mar 15 '17 02:03 bayleedev

If I comment both setInterval, resource usage goes down significantly.

I think I can remove the setInterval in Notification and replace it by two call to tick() while keeping its functionality. Or I misunderstood the goal of the setInterval. Can you clarify that to me?

For the setInterval in windows.js, can we clearInterval() when the window is hidden ? and re activate it when zazu is visible ?

Also, how can I run the profiler (to get the eventual remaining spots for improvements) ?

jlaffaye avatar Mar 16 '17 15:03 jlaffaye

Yes, exactly they can both be reduced greatly. I like your idea for doing it in window only when the window is active. A simple open/close listener could do the trick.

Notifications can do something similar when we only have an interval when there is a queue. A pr would be appreciated! :D

bayleedev avatar Mar 19 '17 05:03 bayleedev

Not sure if I should start a new issue, but I have noticed excessive RAM usage when this is running in the background. I'm talking like 3GB.

SpaceOctopus avatar Sep 17 '17 23:09 SpaceOctopus