Small Windows process-affinity and priority watcher.
Goal:
- keep performance impact low
- apply affinity and priority to already-running processes
- catch new matching processes after launch
- load rules from JSON
- optional startup registration for current user
- publish as NativeAOT
ptlimiter.json:
{
"pollIntervalMs": 1000,
"settleDelayMs": 200,
"startupEntryName": "PTLimiter",
"logFilePath": "C:\\Users\\Trym.Zimmer\\AppData\\Local\\PTLimiter\\ptlimiter.log",
"windowsEventLog": {
"enabled": false,
"sourceName": "PTLimiter",
"logName": "Application",
"manageEventSource": false
},
"rules": [
{
"processName": "cs2.exe",
"affinityMask": "0xFFFC"
},
{
"processName": "discord.exe",
"priorityClass": "Normal"
}
]
}Notes:
allowedProcessorsuses zero-based logical CPU indexes.affinityMaskcan be decimal or hex with0x.priorityClassaccepts Windows priority names:Idle,BelowNormal,Normal,AboveNormal,High,RealTime.- rules can set affinity, priority, or both.
- one rule per process image name.
- current implementation uses one Windows processor-group mask only. Practical limit: first 64 logical processors.
- default log file path is
%LocalAppData%\PTLimiter\ptlimiter.log. - Windows Event Log output is optional. If
manageEventSourceisfalse, the source must already exist. Creating a new Event Log source usually requires administrator rights.
Write example config:
dotnet run --project .\src\PTLimiter -- --write-exampleApply once:
dotnet run --project .\src\PTLimiter -- --config .\ptlimiter.json --onceWatch in foreground:
dotnet run --project .\src\PTLimiter -- --config .\ptlimiter.jsonInstall startup entry for current user:
dotnet run --project .\src\PTLimiter -- --config .\ptlimiter.json --install-startupRemove startup entry:
dotnet run --project .\src\PTLimiter -- --config .\ptlimiter.json --uninstall-startupRun tests:
dotnet test .\PTLimiter.slnxdotnet publish .\src\PTLimiter\PTLimiter.csproj -c Release -r win-x64NativeAOT on Windows needs Visual Studio C++ linker tools installed. If publish fails with "Platform linker not found", install Desktop development with C++ workload.
Fallback publish if you want low startup cost without full AOT toolchain:
dotnet publish .\src\PTLimiter\PTLimiter.csproj -c Release -r win-x64 /p:PublishAot=false /p:PublishReadyToRun=truePublished executable lands under:
src\PTLimiter\bin\Release\net11.0-windows\win-x64\publish\
If you run the non-published build output directly, install the matching .NET desktop runtime for the target framework first.
Use published PTLimiter.exe for startup. The app now builds as a WinExe, so it runs headlessly in the background without needing to hide a console window.