Opened 6 years ago

Closed 2 years ago

Last modified 7 months ago

#9826 closed enhancement (worksforme)

tor process priority in windows

Reported by: bolvan Owned by:
Priority: Medium Milestone: Tor: unspecified
Component: Core Tor/Tor Version: Tor: unspecified
Severity: Normal Keywords: priority, tor-relay windows win32 configuration needs-windows
Cc: Actual Points:
Parent ID: Points:
Reviewer: Sponsor:

Description

Due to recent botnet activity relay operators suffer from high cpu usage. When running on single and two core cpu's tor process can slow down other tasks. In some cases it is desired to have tor process priority lowered. Windows do not have built-in ways to set priority for services.
I implemented little mod for myself. It uses some torrc variable and calls SetPriorityClass API.
I think it would be great if official version had the same feature.

Child Tickets

Attachments (1)

tor-mod.diff (1.7 KB) - added by bolvan 6 years ago.
setting process priority in windows

Download all attachments as: .zip

Change History (11)

comment:1 Changed 6 years ago by arma

Did I miss any attachments here? Or (better) URLs to your git repo that implements the mod?

Sounds like it might be a worthwhile improvement (but I don't know Windows well at all).

comment:2 Changed 6 years ago by nickm

Keywords: tor-relay added
Milestone: Tor: unspecified

On unix, if you want to run a program with a other-than-usual priority, you use the program "nice" to launch it and control its priority setting. Does Windows not have one of those?

Changed 6 years ago by bolvan

Attachment: tor-mod.diff added

setting process priority in windows

comment:3 Changed 6 years ago by bolvan

I'm not pretending to be part of development but if you find my patch useful pls use it.
It's very easy.

Added torrc parameter "PriorityClass" (windows only).
Possible values :

IDLE_PRIORITY_CLASS
BELOW_NORMAL_PRIORITY_CLASS
NORMAL_PRIORITY_CLASS
ABOVE_NORMAL_PRIORITY_CLASS
HIGH_PRIORITY_CLASS

comment:4 in reply to:  2 Changed 6 years ago by bolvan

Replying to nickm:

On unix, if you want to run a program with a other-than-usual priority, you use the program "nice" to launch it and control its priority setting. Does Windows not have one of those?

In windows it's possible to start process with altered priority from cmd with "start" command.
From WinAPI point of view - you can set priority class in dwCreationFlags parameter of function CreateProcess().
However this technique does not apply to service (daemon) processes.
In unix launch of daemons is usually controlled by launch scripts in /etc/init.d. Its easy to write 'nice' there. In windows service processes are lauched by a system process holding SCM (service control manager).
Launch parameters for the service are in the registy : HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\<service_name>.
I'm not aware of any way to specify priority class there. If you know - pls share.

Also in the bundle tor is launched directly by vidalia, not by custom shell script, so there's also no way to alter priority.
IMHO the simpliest way to alter priority - inside the process itself.
This will work 100% no matter how tor.exe is launched.

comment:5 Changed 6 years ago by nickm

Milestone: Tor: unspecifiedTor: 0.2.5.x-final
Status: newneeds_review

comment:6 Changed 6 years ago by bolvan

I found universal way of specifying priority class for processes with given name.

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options\WorldOfTanks.exe\PerfOptions]
"CpuPriorityClass"=dword:<value>

This makes updating tor code unneeded.

comment:7 Changed 6 years ago by andrea

Keywords: 025-triaged added

comment:8 Changed 6 years ago by nickm

Milestone: Tor: 0.2.5.x-finalTor: unspecified

Okay; if this is something that users can do for themselves, I'm not so sure it belongs in Tor. Putting in Tor:unspecified milestone unless it turns out this is a great idea.

comment:9 Changed 2 years ago by nickm

Keywords: 025-triaged removed

remove an old triage keyword.

comment:10 Changed 2 years ago by nickm

Keywords: windows win32 configuration needs-windows added
Resolution: worksforme
Severity: Normal
Status: needs_reviewclosed

Closing as worksforme, since apparently this is something users can do for themselves without Tor modifications. Please reopen if that isn't true.

Note: See TracTickets for help on using tickets.