Skip to content

Repository files navigation

PTLimiter

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

Config

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:

  • allowedProcessors uses zero-based logical CPU indexes.
  • affinityMask can be decimal or hex with 0x.
  • priorityClass accepts 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 manageEventSource is false, the source must already exist. Creating a new Event Log source usually requires administrator rights.

Commands

Write example config:

dotnet run --project .\src\PTLimiter -- --write-example

Apply once:

dotnet run --project .\src\PTLimiter -- --config .\ptlimiter.json --once

Watch in foreground:

dotnet run --project .\src\PTLimiter -- --config .\ptlimiter.json

Install startup entry for current user:

dotnet run --project .\src\PTLimiter -- --config .\ptlimiter.json --install-startup

Remove startup entry:

dotnet run --project .\src\PTLimiter -- --config .\ptlimiter.json --uninstall-startup

Run tests:

dotnet test .\PTLimiter.slnx

NativeAOT publish

dotnet publish .\src\PTLimiter\PTLimiter.csproj -c Release -r win-x64

NativeAOT 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=true

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

About

Windows utility to enforce CPU affinity and process priority rules for apps and games from JSON.

Topics

Resources

Contributing

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages