microsoft / PowerToys

Windows system utilities to maximize productivity

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[Tracker] PowerLauncher cycles high CPU usage

WesleyM77 opened this issue · comments

PowerLauncher.exe keeps ramping up to ~60% CPU usage in task manager and then back down to 0%. It happens about every 2 seconds or so.

Environment

Windows [Version 10.0.18363.720]
PowerToys 0.18
PowerLauncher

Steps to reproduce

Start PowerToys.

Screenshots

Taskmgr_2020-05-19_16-10-54

I have the same problem. Moreover, it eats quite a lot of memory and almost continuously works with the disk.
obrazek

same here, using quite a bit more ram though
image

This is same as #3365, I also have almost 1GB of RAM usage.

I have a similar problem but it peaks usually at 20%. It will spike for about 10 seconds to 18%-20% then release for about 30 seconds, then repeat. I noticed it also then triggered Cisco AMP and System to spike at same time, causing my computer to often hit 100%.

Proactively monitoring it, yes, I'm starting to see it creep up as well. This could be one of two things off top of my head.

@crutkas I'm a bit suspicious of the file watchers here, particularly for settings. They trigger on changes within the directory. We should look at if we are updating a setting at a regular interval. It also could be triggered by changes in the program files directory which would cause us to reindex the applications, but that shouldnt happen at a regular interval.

The same thing here:
image
have to kill it, because computer really gets slow sometimes.

I'm having the same problem here, PowerLauncher spikes the cpu usage to 70% - 80% and it almost uses 50% of the cpu constantly
Screenshot (379)

Doesn't appear to happen for me.
image

PowerToys v0.18.2, AMD Ryzen 3900X non-oc'd, 32GB DDR4@3200MHz RAM.

Hi, I had the same problem today, noticed my PC fans were suddenly blowing quite a lot, so looked at the Task Manager, and PowerLauncher was using a lot of CPU (around 50% if I remember correctly). I believe it has happened before, but probably didn't catch my attention at that point. Disabled it for the time being.

Hi, I had the same problem today, noticed my PC fans were suddenly blowing quite a lot, so looked at the Task Manager, and PowerLauncher was using a lot of CPU (around 50% if I remember correctly). I believe it has happened before, but probably didn't catch my attention at that point. Disabled it for the time being.

@RensTillmann. Just trying to identify some potential causes. Do any of the following apply to you?

  1. Symbolic links in any of the directories that are being index.
  2. Something running on your machine that could be writing to the %ProgramFiles% directory (or subdirectories) frequently?
  3. Any cutomizations to the windows search settings as per below:
    image

@ryanbodrug-microsoft Thanks.

  1. Yes I do have a couple of symlinks inside the indexing directory
  2. Not that I know of but how can I determine this exactly? I just went over and looked at "Last modified column" there were only 2 folders which were modified yesterday. So I think that's a No. (?)
  3. Didn't change anything there.

I just want to flesh out some details of the processor usage spikes.

Looking at % Processor Time in PerfMon.exe, the spikes occur in roughly 30-second intervals.
Processor usage in performance monitor

Analyzing using Process Explorer

The PowerLauncher.exe process is only able to run because its threads are executing code. We can inspect which functions in various DLLs the threads are executing using Process Explorer created by the SysInternals team.

After opening Process Explorer, follow these steps to view the thread activity of PowerLauncher.exe:

  1. Double click PowerLauncher.exe in the list of processes
  2. Navigate to the threads tab

Initially, you can only see entries with a byte offset like +0x2d8374 on the end. The offsets are actually functions inside the DLL they are referencing, but you need to fetch the debug symbols from the symbol server to access the names. Mark Russinovich briefly shows it at 24:45 in this talk.

I recorded PowerLauncher.exe's thread activity over time. Thread activity spikes at the start of the video and 0:30.

Analyzing using Process Monitor

In order to measure the amount and type of operations PowerLauncher.exe is performing, we can use Process Monitor, also created by the SysInternals team.

After opening Process Monitor, follow these steps to view the list of operations PowerLauncher.exe is performing:

  1. Press Ctrl + L or go to Filter > Filter... to open the filter
  2. Filter by Process name begins with PowerLauncher, then click Add and OK
    Adding a filter

It's useful to know that monitoring means continuously capturing the operations (described in the next section) the process is performing, and can be toggled with Ctrl+E. Ctrl+X clears the list. You can alternatively use the buttons at the top.
Toggling capturing and clearing the list

Looking at the overall information I have gathered over a single spike (a time span of 3.7643472‬ seconds), there is a whopping 61 070 operations being carried out.

Amount Operation
15 573 RegQueryKey
14 741 RegOpenKey
12 506 RegCloseKey
10 987 RegQueryValue
1 443 ReadFile
1 374 CreateFile
1 089 CloseFile
575 RegEnumKey
506 RegSetInfoKey
506 RegCreateKey
496 QueryDirectory
496 QueryRemoteProtocolInformation
184 QueryStandardInformationFile
148 QueryNetworkOpenInformationFile
136 QueryAllInformationFile
136 QueryBasicInformationFile
136 QueryInformationVolume
22 FileSystemControl
11 DeviceIoControl
9 WriteFile
4 Thread Create
1 Thread Exit

Although I am far from knowledgeable enough to make any conclusions from the data, there are some interesting relations I see. Firstly, registry operations make up over 80% of all operations. Secondly, 1443 ReadFile and 1374 CreateFile operations are performed, in stark contrast to 9 WriteFile operations.

If you want to dig into the exact same data I have worked with, you can download this .pml file, open Process Monitor, press Ctrl+O or click the open icon in the top left corner, and open the .pml file.


Process Explorer and Process Monitor are great programs, it's incredible how much insight you can get from using them. Highly recommended to learn to use them for these kinds of scenarios. Watch the series "The Case of the Unexplained" by Mark Russinovich for more info on using both programs.

For whatever help this is worth, I had this installed on both a desktop machine and a laptop. The desktop had no issues, while the laptop exhibited these issues.

After turning off BitLocker on my laptop (not for the purpose of debugging this but for linux dual boot convenience), I noticed the CPU issues seem to have gone away. In fact a lot of processes seem to be running a little bit better since then, though there was nothing as extreme as these CPU spikes with other processes. I checked on my desktop and found that, sure enough, it was not running BitLocker either.

So, possibly something related to Bitlocker encryption?

For whatever help this is worth, I had this installed on both a desktop machine and a laptop. The desktop had no issues, while the laptop exhibited these issues.

After turning off BitLocker on my laptop (not for the purpose of debugging this but for linux dual boot convenience), I noticed the CPU issues seem to have gone away. In fact a lot of processes seem to be running a little bit better since then, though there was nothing as extreme as these CPU spikes with other processes. I checked on my desktop and found that, sure enough, it was not running BitLocker either.

So, possibly something related to Bitlocker encryption?

Maybe it also causes the problem, but I do not have bitlocker enabled and I have the issue.

if it was bitlocker, the entire PowerToy team would have seen it instantly.

commented

Same thing happens for me on Microsoft Windows [Version 10.0.19041.329] and PowerToys v0.18.2.

RAM usage for me is around 300-400 MB with 8GB installed in the laptop. I think the RAM usage is dependent on how much is installed in your system.

@lftrejo, you had almost 1GB used by the PowerLauncher process, how much RAM do you have installed in your system?

Ram usage and CPU I think are different things. For Ram, we believe we have at least one thing we can do to improve it.

Same thing happens for me on Microsoft Windows [Version 10.0.19041.329] and PowerToys v0.18.2.

RAM usage for me is around 300-400 MB with 8GB installed in the laptop. I think the RAM usage is dependent on how much is installed in your system.

@lftrejo, you had almost 1GB used by the PowerLauncher process, how much RAM do you have installed in your system?

Running on 32GB

Consumes crazy amounts of CPU for me too

still need to investigate further in 2007

Same thing happens for me on Microsoft Windows [Version 10.0.19041.329] and PowerToys v0.18.2.

RAM usage for me is around 300-400 MB with 8GB installed in the laptop. I think the RAM usage is dependent on how much is installed in your system.

@lftrejo, you had almost 1GB used by the PowerLauncher process, how much RAM do you have installed in your system?

i have almost the same problem... i have 8 gb ram and it sometimes consume up to 300 mb...

i used to think this problem would get solved in 0.18.2, however it turns out i'm wrong...

I also noticed that it does not happen all the time...sometimes when i check task manager, powerlauncher is fine, sometimes it is not fine...
Have you considered to make a "hotfix"? Let powertoy monitor the RAM, and if powerlauncher is consuming too much RAM(over a certain ratio), then stop indexing.
You can make this into setting to allow users to decide this ratio.

@dentistfrankchen we didn't address the issue in 18.2, .19 we have one item to slightly address it but think we figured out how to reproduce one of the RAM usage bugs.

Without knowing the root cause / having a repro, solutions are shots in the dark and can do more harm at times than good.

Same issue here. It just RANDOMLY spikes to using like 30% of cpu for a few moments then stops and repeats. Will text new version and update if it changes things

commented

I just tested the new v0.19, I still get the CPU issue. Also still around 300-400mb ram usage.

Type Version
ver Microsoft Windows [Version 10.0.19041.329]
PowerToys v0.19.0

We have a fix invoking for the RAM issue next week. CPU issue we need to figure out how to reproduce.

Right after I updated from 0.18 to 0.19, I found out the RAM occupation by run seems to get lower... It used to occupy 300MB, but now it occupies 160MB(I am using a 8GB RAM)

Had the same issue regarding CPU, every 5-10 seconds the usage went through the roof. Did some light debugging, it seems that the caused by re-indexing UWP apps.

The timer Microsoft.Plugin.Program.Main._timer was reactivated by Microsoft.Plugin.Program.Main._watcher all the time, because of changes in the Program Files folder caused by running MongoDB and Postgres services.

private void OnChanged(object source, FileSystemEventArgs e)
{
Log.Debug($"|Microsoft.Plugin.Program.Main|Directory Changed: {e.FullPath} {e.ChangeType} - Resetting timer.");
_timer.Stop();
_timer.Start();
}

private void FileWatchElapsedTimer(object sender, ElapsedEventArgs e)
{
Task.Run(() =>
{
Log.Debug($"|Microsoft.Plugin.Program.Main| ReIndexing UWP Programs");
IndexUWPPrograms();
Log.Debug($"|Microsoft.Plugin.Program.Main| Done ReIndexing");
});
}

Debug trace looked like this:

...
Debug||Microsoft.Plugin.Program.Main|Directory Changed: C:\Program Files\MongoDB\Server\4.2\data\diagnostic.data\metrics.interim Deleted - Resetting timer.
Debug||Microsoft.Plugin.Program.Main|Directory Changed: C:\Program Files\MongoDB\Server\4.2\data\diagnostic.data\metrics.interim.temp Created - Resetting timer.
Debug||Microsoft.Plugin.Program.Main|Directory Changed: C:\Program Files\MongoDB\Server\4.2\data\diagnostic.data\metrics.interim Deleted - Resetting timer.
Debug||Microsoft.Plugin.Program.Main|Directory Changed: C:\Program Files\PostgreSQL\12\data\pg_stat_tmp\global.tmp Created - Resetting timer.
Debug||Microsoft.Plugin.Program.Main|Directory Changed: C:\Program Files\PostgreSQL\12\data\pg_stat_tmp\global.stat Deleted - Resetting timer.
Debug||Microsoft.Plugin.Program.Main|Directory Changed: C:\Program Files\MongoDB\Server\4.2\data\diagnostic.data\metrics.interim.temp Created - Resetting timer.
Debug||Microsoft.Plugin.Program.Main|Directory Changed: C:\Program Files\MongoDB\Server\4.2\data\diagnostic.data\metrics.interim Deleted - Resetting timer.
Debug||Microsoft.Plugin.Program.Main|Directory Changed: C:\Program Files\MongoDB\Server\4.2\data\diagnostic.data\metrics.interim.temp Created - Resetting timer.
Debug||Microsoft.Plugin.Program.Main|Directory Changed: C:\Program Files\MongoDB\Server\4.2\data\diagnostic.data\metrics.interim Deleted - Resetting timer.
Debug||Microsoft.Plugin.Program.Main|Directory Changed: C:\Program Files\MongoDB\Server\4.2\data\diagnostic.data\metrics.interim Deleted - Resetting timer.
Debug||Microsoft.Plugin.Program.Main|Directory Changed: C:\Program Files\MongoDB\Server\4.2\data\WiredTiger.turtle.set Created - Resetting timer.
Debug||Microsoft.Plugin.Program.Main|Directory Changed: C:\Program Files\MongoDB\Server\4.2\data\WiredTiger.turtle Deleted - Resetting timer.
Debug||Microsoft.Plugin.Program.Main|Directory Changed: C:\Program Files\PostgreSQL\12\data\pg_logical\replorigin_checkpoint.tmp Created - Resetting timer.
Debug||Microsoft.Plugin.Program.Main|Directory Changed: C:\Program Files\PostgreSQL\12\data\pg_logical\replorigin_checkpoint Deleted - Resetting timer.
Debug||Microsoft.Plugin.Program.Main|Directory Changed: C:\Program Files\PostgreSQL\12\data\pg_stat\global.tmp Created - Resetting timer.
Debug||Microsoft.Plugin.Program.Main|Directory Changed: C:\Program Files\PostgreSQL\12\data\pg_stat_tmp\global.stat Deleted - Resetting timer.
Debug||Microsoft.Plugin.Program.Main|Directory Changed: C:\Program Files\PostgreSQL\12\data\postmaster.pid Deleted - Resetting timer.
...

@ryanbodrug-microsoft why is the program file watcher looking there?

@ryanbodrug-microsoft why is the program file watcher looking there?

@crutkas . This was done as a hack for a demo, initially the idea was to handle both uwp and win32 programs, but only uwp apps were reindexed. This will be fixed here: #4521. We don't need to reindex everything just add / remove the package. Sorry I didn't get this in before I went on vacation. I wasn't happy with the unit test coverage. I spent the day trying to get Microsoft Fakes working (which is now available in .netcore), but it doesn't seem to work. I think I will just fix the minor comments and look to capture this scenario with functional tests.

@jiripolasek. Thanks for this! I was quite suspicious of the file watcher, but wasn't aware of a reproducible scenario. Packaged apps are easy to detect install / delete, but this gives us scenarios to test when detecting win32 apps being installed / removed.

I also noticed two bugs:
1.Every time I use Run to search for something, it occupies more RAM. For example, when launcher starts, launcher occupies 77MB, one search later, 89MB. One more search later, 101MB...
2.Later, it suddenly consumes 16% of CPU, and RAM occupation soars to 200+MB...
(which is not the same with the 2s peak style, and also no release)

I also think you should focus more on the RAM problem instead of the CPU problem.
For my case, CPU problem is "rare", but the RAM problem appears all the time...

I also think you should focus more on the RAM problem instead of the CPU problem.
For my case, CPU problem is "rare", but the RAM problem appears all the time...

some people get each scenario. The issue for both is being able to reproduce stuff so we can track down root causes. We figured out one issue in 0.19.1 since we noticed the behavior that caused a spike

0.19.1 STILL have the problem I mentioned...
I do not understand why you program the launcher to run as a background process even after the search has finished?
To invoke powerlauncher, you could program like this: Create a new process of laucher.exe. After 30s(as I tested), let powertoy.exe kill the process of laucher.exe...
Then although the problem is not fixed, we can still decrease its impact by making it a "temporary problem"(Since the problem can be more serious as time flows, we can actually kill that buggy process in some seconds before it becomes buggy.)...
Here' s my idea(You can integrate this idea to help users who still have this problem)
steps:
1.disable run in powertoys;
2.write some code to monitor alt+space;
3.if pressed, create laucher.exe's process;
4.after 30 sec, kill it.

Here's my code(integrated into my program, using mrousavy's hotkey library to monitor):
(I allocate shift+p to call launcher)
var key_p = new HotKey(
ModifierKeys.Shift, //shift is more friendly to office than alt
Key.P, //using shift+s
this,
delegate
{

            Thread.Sleep(100); //this is necessary for shift+s to release
                               //MessageBox.Show("Ctrl + Alt + S was pressed!");
                               //me.Keyboard.KeyUp(VirtualKeyCode.MENU);
                               //me.Keyboard.KeyUp(VirtualKeyCode.VK_S);
                               //me.Keyboard.KeyPress(VirtualKeyCode.MENU);
            if (search == 0) //need to call
            {
                Process.Start("C:\\Program Files\\PowerToys\\modules\\launcher\\PowerLauncher.exe");
                Task.Run(() =>
                {
                    search = 1;
                    Thread.Sleep(30000);
                    Process[] ps = Process.GetProcessesByName("PowerLauncher");

                    foreach (Process p in ps)
                        p.Kill();
                    search = 0;
                });
            }
            else
            {
                Process.Start("C:\\Program Files\\PowerToys\\modules\\launcher\\PowerLauncher.exe");
            }
        });//to control powertoys

"search" is a public int
Sorry for being messy, however I am not a professional programmer, so that is what I can do...

I just updated to 19.1 and noticed it wasn't fixed. The funny thing is that I don't really use the launcher... or, window walker... I tried disabling it and the Keyboard mapper (I don't use it either), and the memory hasn't jumped backup to almost 1GB. I'll leave the machine on and see if it comes back with it disabled. If so, it's something else, if not... I'll be happy to test or dump as you request.

Thanks for your work on this. These are really good tools for the system.

I just updated to 19.1 and noticed it wasn't fixed. The funny thing is that I don't really use the launcher... or, window walker... I tried disabling it and the Keyboard mapper (I don't use it either), and the memory hasn't jumped backup to almost 1GB. I'll leave the machine on and see if it comes back with it disabled. If so, it's something else, if not... I'll be happy to test or dump as you request.

Thanks for your work on this. These are really good tools for the system.

@timbuckto when you say memory hasn't, what process are you referring to. Launcher runs as a diff process than other items.

@dentistfrankchen you would have first time load issues with your approach.

@dentistfrankchen you would have first time load issues with your approach.

To some extent, you are right.
But initially I set search to 0(which is not shown in this part of code) so there is no problem.
Although it is a bit laggy(i have to press shift p for at least two times since some unknown issue with the launcher.exe or my bad), finally the run window will appear as usual.
Btw: this is not integrated to Run code, it is in my project, which is used to allocate some hotkeys for my PC.

Marked as 'resolution-fix-committed' based on PR #4521 and feedback from users on 19.2

If we continue to see issues from 0.19.2 moving forward, please create new individual issues.

Just updated to 0.19.2 and after a little bit of processing at launch, PowerLauncher seems to be nice and steady at 0% CPU usage.

commented

Updated to v0.19.2, RAM issues are gone along with the CPU issues. CPU idling at 0%, RAM around 100-150MB

Came here to look into why the PowerLauncher was using so much CPU and RAM. I didn't see the update to v0.19.2 was released. It appears to have fixed my RAM issues with PowerLauncher as upon restarting after install I am at 0.2% CPU and 49 MB of RAM used. Thank you for making these tools so great and updating them based on feedback!

The same for me, CPU usage went down. Seems to be fixed for me.

We just released 0.20 and this should be resolved there. Please try it out.

I am running Windows 10 Build 19042.630 & PowerToys version 0.27.0 still it is using a lot of memory in my Surface Pro 6
image

@Abir-Tx, we're tracking that against #8378.

@Abir-Tx, we're tracking that against #8378.

Okay brother. Looking forward for the fix soon

I am still seeing this now where CPU usage @ near-constant 20-40%. Has there been any resolution yet?
Win10 Version: 10.0.19042 Build 19042
PowerToys: Release v0.35.0

Interestingly enough I couldn't open PowerToys so I tried running as admin. It then opened and when I checked CPU usage again it was negligible.

@Godsfunambulator I didn't face this issue again after upgrading to the latest version yet

I just experienced the same issue with the lastest version. Is there a solution for it ?

@TavDev please file a new issue as the root cause based on the data for this issue was deemed solved. Love to dive in and see what is causing the cpu usage but we need logs and what not.