Speed up AppWindow.ProcessTitle#118
Conversation
|
Neat. Did you get that delay every time you pressed the hotkey or just at the first time after launch ? |
|
@elig0n Delay happens first time after launch, and anytime after 1+ hour since last use, because the ProcessName cache entries have 1-hr eviction policy. My machine is fairly beefy, but I must confess to having a habit of keeping a possibly pathological number of windows/processes open. That just emphasized the shamefully quadratic original implementations. BTW, I like some of your PRs; if they don't get accepted, I might have to pull them. |
|
FYI, I integrated this change into my fork |
|
I investigated this as well and the optimized it to the point where running 500 windows doesn't bother Switcheroo anymore: https://github.com/coezbek/Switcheroo I put it a little utility into https://github.com/coezbek/Switcheroo/tree/master/WindowSpawnerUtil to spawn so many windows. |
AppWindow.ProcessTitle was contributing ~90+% of Switcheroo's CPU time whenever its cache was empty/invalidated, due to loading the whole fat Process object just to get the ProcessName, combined with absurdly inefficient implementations in SystemWindow.Process and Process.ProcessName. So, I implemented SystemWindow.ProcessId and SystemWindow.ProcessName directly, reducing my ~5sec time between hotkey & full display to effectively instant.