Optimize regular expression performance

Started by login404, March 19, 2026, 09:01:27 PM

Previous topic - Next topic

login404

The performance is really poor when using multiple regular expression rules.
Every time a new process starts, ProcessGovernor.exe pegs one CPU core at 100% usage.

Here are the detailed rule configurations.

DefaultPriorities=/\\file(c|u)\.exe|filec\.exe.*conhost\.exe/,below normal,/\\listary(hookhelper.*|service)?\.exe/,below normal,*\baidunetdisk\*,idle,*\tencent*\*,idle,altsnap.exe,real time,audiodg.exe,real time,displaycal-apply-profiles.exe,below normal,ditto.exe,below normal,foobar2000.exe,real time,llama-server.exe,below normal,lucky.exe,below normal,magpie.exe,high,mpv.exe,high,novideo_srgb.exe,below normal,stranslate.exe,below normal,stuntraversal.exe,below normal,subs-check*.exe,idle,telegram.exe,idle,textify.exe,below normal,weaselserver.exe,below normal,/.*\\(gryphlink|krlauncher)\\app\\.*\.exe/,below normal
DefaultIOPriorities=/.*\\endfield\\app\\(?!endfield\.exe).*\.exe/,0,/.*\\wutheringwaves\\app\\(?:[^\,\\]+\\)*(?!client-win64-shipping\.exe)[^\,\\]+\.exe.*/,0,/.*\\(gryphlink|krlauncher)\\app\\.*\.exe/,0,/\\file(c|u)\.exe|filec\.exe.*conhost\.exe/,1,/\\listary(hookhelper.*|service)?\.exe/,1,*\baidunetdisk\*,0,*\tencent*\*,0,foobar2000.exe,3,mpv.exe,3,magpie.exe,3,telegram.exe,0,trafficmonitor.exe,1
DefaultGPUPriorities=/.*\\endfield\\app\\(?!endfield\.exe).*\.exe/,0,/.*\\wutheringwaves\\app\\(?:[^\,\\]+\\)*(?!client-win64-shipping\.exe)[^\,\\]+\.exe.*/,0,/.*\\(gryphlink|krlauncher)\\app\\.*\.exe/,0,*\baidunetdisk\*,0,*\tencent*\*,0,magpie.exe,4,mpv.exe,4,subs-check*.exe,0,telegram.exe,0
DefaultMemoryPriorities=subs-check*.exe,1,telegram.exe,1,*\tencent*\*,1,*\baidunetdisk\*,1
DefaultAffinitiesEx=/\\process(lasso|governor)\.exe|\\bitsumsessionagent\.exe/,0,12-19,/[^\\]+portable([^\\]{2\,3})?\.exe\,[0-9]/,60000,12-19,/\\file(c|u)\.exe|filec\.exe.*conhost\.exe/,0,12-19,/\\listary(hookhelper.*|service)?\.exe/,0,12-19,/\\(portable)?wincdemu(-x\.x)?\.exe/,0,12-19,/.*\\v2rayn\\.*|(xray|mihomo.*|sing-box)\.exe.*conhost\.exe/,10000,12-19,/.*\\endfield\\app\\(?!endfield\.exe).*\.exe/,0,12-19,/.*\\wutheringwaves\\app\\(?:[^\,\\]+\\)*(?!client-win64-shipping\.exe)[^\,\\]+\.exe.*/,0,12-19,/.*\\(gryphlink|krlauncher)\\app\\.*\.exe/,0,12-19,*\baidunetdisk\*,10000,12-19,*\encoders\*,0,0-19,*\msiafterburner\*,10000,12-19,*\tencent*\*,10000,12-19,*nopcontinue.exe,0,19,processbooster.exe,0,12-19,stuntraversal.exe,0,12-19,foobar2000.exe,0,0;2;4;6;8;10,displaycal-apply-profiles.exe,0,12-19,ditto.exe,0,12-19,gpu-z.exe,0,12-19,itzmxacceleratorui.exe,0,12-19,lowaudiolatency.exe,0,19,lucky.exe,0,12-19,hh.exe,0,12-19,novideo_srgb.exe,0,12-19,perfmon.exe,0,12-19,stranslate.exe,0,12-19,subs-check*.exe,0,12-19,systeminformer.exe,0,12-19,telegram.exe,10000,12-19,taskmgr.exe,0,12-19,textify.exe,0,12-19,trafficmonitor.exe,0,12-19,weaselserver.exe,0,12-19
CPUSets=/\\(chsime|explorer|runtimebroker|searchapp|startmenuexperiencehost|taskhostw|comppkgsrv)\.exe/,(12-19),/\\svchost\.exe(?!.*audioendpointbuilder)(?!.*-k localservicenetworkrestricted -p$).*/,(12-19),*\libreoffice\*,(12-19),services.exe,(12-19),everything.exe,(12-19),listaryhelper64.exe,(12-19),notepad++.exe,(12-19),systeminformer.exe,(12-19),trafficmonitor.exe,(12-19)
WatchdogRules2=/.*\\wutheringwaves\\app\\.*client-win64-shipping\.exe.*\.exe/;8;1;1.00;5000;0;3;1;..\..\portable\processcontroller.exe;-processid %1 -dscp 46;-;-,/\\svchost\.exe.*dnscache/;8;1;1.00;5000;0;3;1;..\..\portable\processcontroller.exe;-processid %1 -dscp 46;-;-,processlasso.exe;8;1;1.00;5000;0;3;1;..\..\stranslate\stranslate.exe;-;-;-,explorer.exe;8;1;1.00;5000;0;3;1;..\..\portable\volumeosd.exe;-;-;-,filec.exe;8;1;1.00;5000;0;3;1;..\..\portable\processcontroller.exe;-processid %1 -dscp 34;-;-,lucky.exe;8;1;1.00;5000;0;3;1;..\..\portable\processcontroller.exe;-processid %1 -dscp 34;-;-,qq.exe;8;1;1.00;5000;0;3;1;..\..\portable\processcontroller.exe;-processid %1 -dscp 40;-;-,stranslate.exe;8;1;1.00;5000;0;3;1;..\..\portable\processcontroller.exe;-processid %1 -working 1-100;-;-,stuntraversal.exe;8;1;1.00;5000;0;3;1;..\..\portable\processcontroller.exe;-processid %1 -dscp 34;-;-,v2rayn.exe;8;1;1.00;5000;0;3;1;..\..\portable\processcontroller.exe;-processid %1 -dscp 46;-;-,endfield.exe;8;1;1.00;5000;0;3;1;..\..\portable\processcontroller.exe;-processid %1 -dscp 46;-;-

Jeremy Collake

#1
We've made some improvements as of v18.0.0.29 BETA. If you try it, let me know how it goes!
Software Engineer. Bitsum LLC.

login404

No effect — when starting a new process, it still maxes out one core for several seconds.

Jeremy Collake

v18.0.0.31 BETA should show much more substantive improvements, but please let me know your experience!
Software Engineer. Bitsum LLC.

login404

The new version is working fine now; CPU usage is under 1%.

But I found another issue. 
After modifying the rules, the UI gets stuck for a few seconds, and during that time, the CPU usage of ProcessGovernor.exe and ProcessLasso.exe spikes very high.

Jeremy Collake

Quote from: login404 on March 20, 2026, 07:29:28 PMThe new version is working fine now; CPU usage is under 1%.

Great!

QuoteAfter modifying the rules, the UI gets stuck for a few seconds, and during that time, the CPU usage of ProcessGovernor.exe and ProcessLasso.exe spikes very high.

That is due to a one-time penalty from reapplying those Regular Expressions. We'll see what we can do!
Software Engineer. Bitsum LLC.

login404

Freezing seems to occur only after the rules are changed.
When running ProcessLasso for the first time or after a complete restart
Even with exactly the same rules, it wouldn't freeze.

Maybe after updating the rules, 
it would be better to compare the old and new rules to see the differences, 
and then apply only the new or modified ones?

Jeremy Collake

Yes, something along those lines is now implemented in 18.0.0.41 BETA. We are still assessing the performance improvement. Let me know how it goes if you try it out!
Software Engineer. Bitsum LLC.

login404

It's working great. The freezing's not happening anymore.
However, this optimization missed the Watchdog.

Jeremy Collake

Quote from: login404 on March 24, 2026, 06:07:36 PMHowever, this optimization missed the Watchdog.

I assume you mean that the Watchdog rules get reapplied every config save, not that the performance hit (process stall) is present with them. This is because the optimization we applied wasn't "ignore rules that didn't change", hence that continued behavior. Rather, the optimization was to not purge the RegEx cache on config reload, so unchanged rules persisted in it.

Reapplying the Watchdog rules on any config save was a design decision long ago and needs further consideration before we make an adjustment to it. I've created a ticket for it and we'll work on this, though it may be after v18.0... we'll see ;).
Software Engineer. Bitsum LLC.

login404

Running a WebView2 application with multiple processes simultaneously can still cause Process Lasso to freeze.
I'm not sure if this is a result of the last fix that extended the evaluation time for the first regular expression rule.
I can't find the download link for the old version to do testing.


Jeremy Collake

QuoteI'm not sure if this is a result of the last fix that extended the evaluation time for the first regular expression rule. I can't find the download link for the old version to do testing.

It may be. You can download older versions here.

In the case of the GUI, I think we can make these evaluations asynchronous and resolve the blocking effects you see. This may come after the v18.1 release though. I'll keep you posted!
Software Engineer. Bitsum LLC.

login404

I tested v18.0.0.68 and it also freezes.