twinkle-tray icon indicating copy to clipboard operation
twinkle-tray copied to clipboard

Reduce CPU load in background (Windows)

Open Armin2208 opened this issue 2 years ago • 2 comments

Hello, for my liking the background task of Twinkle Tray consumes a little bit too much CPU performance, for an app which is designed to always in background. It regularly appears on task manager with a load of 0,1% up to 1% cpu.

Interesting is the fact, that the cpu load depends on my mouse movement. If I don't move my mouse, Twinkle Tray seems to never use more cpu than 0,00%. But as soon I start to fastly shake my mouse, it goes up to 0,8%..

I've disabled following options:

  • Tray icon scroll shortcut
  • Idle detection
  • overlay
  • Analytics

With all these options disabled, there shouldn't be an impact with moving mouse on twinkle tray.

I would be pretty thankful if you investigate in this issue. Sure, you could say "it's just one percent". If you use multiple background apps, which all take 0,5% load it stacks up. Especially if you game you want as little background load as possible. It's not convinient to always close twinkle tray and re-open it.

Screenshot of Task Manager: Twinkle Tray CPU Load

Armin2208 avatar Jul 26 '22 15:07 Armin2208

@Armin2208 The reason is my global-mouse-events module. Even with the "Tray icon scroll shortcut", it's still in use to help track when the user clicks in a way that should hide the flyout/overlay but isn't caught by normal "blur" events. I can add an option to disable it entirely, but this may cause some UI bugs. I'll see if I can do something to further reduce CPU usage. I assume you're using a mouse with a high polling rate (ex. 1000hz)?

xanderfrangos avatar Jul 26 '22 18:07 xanderfrangos

Good to know @xanderfrangos!

That's true, my mouse has a polling rate of 1.000 Hz. An extra option would be cool, but this seems like a setting for an advanced mode/config file. Because it's really a niche thing. Too irrelevant for implementing a toggle in user interface.

Can you enable and disable the mouse event dynamically? What about only running it while the menu is opened?

Armin2208 avatar Jul 26 '22 22:07 Armin2208

Hi @Armin2208, I've made a post over on this Issue that's relevant to yours. Take a look and let me know if either of the builds posted there help.

Thanks!

xanderfrangos avatar Aug 14 '22 21:08 xanderfrangos

Hey, sorry I didn't answer yet. I've installed one of these two versions but hadn't a chance to test it carefully, because I had much work to do etc. But I've seen you pushed some new stable releases and I tested the newest one v1.14.6. Now the CPU usage in Background is pretty much 0% all the time. Thanks for your and @djsweet work, you solved it. I'm happy now.

Btw "Updated "Get Current Brightness" option to also refresh DDC/CI list." is also a nice addition. Because Twinkle Tray had sometimes trouble to display my connected Monitor right after system start :)

Armin2208 avatar Aug 31 '22 13:08 Armin2208