Skip to content

Speed up AppWindow.ProcessTitle#118

Open
daanzu wants to merge 2 commits into
kvakulo:masterfrom
daanzu:speed
Open

Speed up AppWindow.ProcessTitle#118
daanzu wants to merge 2 commits into
kvakulo:masterfrom
daanzu:speed

Conversation

@daanzu

@daanzu daanzu commented Jun 30, 2018

Copy link
Copy Markdown

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.

@elig0n

elig0n commented Jun 30, 2018

Copy link
Copy Markdown
Contributor

Neat. Did you get that delay every time you pressed the hotkey or just at the first time after launch ?
because 5 seconds sounds unreasonable, is your machine old ?

@daanzu

daanzu commented Jul 1, 2018

Copy link
Copy Markdown
Author

@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.

@milnak

milnak commented Aug 30, 2023

Copy link
Copy Markdown

FYI, I integrated this change into my fork

@coezbek

coezbek commented Nov 25, 2025

Copy link
Copy Markdown

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants