norgepaul / TChromeTabs

Comprehensive Delphi implementation of Chrome's tab system
Other
215 stars 78 forks source link

Constant CPU load #92

Open IgitBuh opened 3 years ago

IgitBuh commented 3 years ago

This component creates a constant CPU load of 1-2% on one core, even if it isn't doing anything and even if it isn't visible at all (idle minimized application). Just run the demo together with Sysinternals Process Explorer and observe the CPU load. Note, that more cores result in a lowed value, because it represents the usage based on all available cores in total.

Apparently, the reason for this is the constantly running TThreadTimer in TTimerThread. Disabling the timer, stops this CPU load.

This timer seems to be used for animations, but if the application is in an idle state and there are no animations, then there should be no CPU load.

You might say that 1-2% CPU load on one core isn't much. Imagine, more components or other applications would do the same. Just 10 applications with this issue would cause 10-20% constant CPU load, draining a laptop battery and blowing fans.

Either the timer should be able to perform its idle tasks without any CPU load or the timer needs to be stopped and started when it is actually needed.

landrix commented 3 years ago

I don't see any CPU load when the application is minimized. I think a good AnimationTimerInterval is 100ms. For all other things I have no idea at the moment.

IgitBuh commented 3 years ago

Did you check with Process Explorer as described? (don't use the Task Manager as it might not be accurate enough if you have many powerful cores) I made sure that it is not just a thing on a specific device. It was confirmed on multiple laptops and on two different VMs. The less cores, the higher the total CPU load, because it runs in a single thread. The thing is, it performs all these animation tasks and checks all the time (10x per second), even if there is no interaction with the tabs or it isn't even visible at all. That doesn't seem right.

landrix commented 3 years ago

I changed something, can you test it?

landrix commented 3 years ago

I deactivated it again for now, too many side effects. Somebody has to take a closer look.

IgitBuh commented 3 years ago

I wasn't able to test it yet, because I cannot install any "nightly" builds on the productive dev system. I was going to set up an additional test dev system for this, but apparently you have already found problems.

But you have been able to reproduce the constant CPU load that I described, right?

landrix commented 3 years ago

yes i was able to reproduce it. But there are problems with my patch when the tab is on a panel.

you can check agains this commit

https://github.com/norgepaul/TChromeTabs/commit/1c7215a0afe171e900143dfaa1e40c04c4dbcf53