PazerOP / tf2_bot_detector

Automatically detects and votekicks cheaters/bots in TF2 casual.
MIT License
400 stars 56 forks source link

Launches with "-high" option, leading to potential instability #332

Open GTcreyon opened 3 years ago

GTcreyon commented 3 years ago

Describe the bug By default, TF2BD attempts to load TF2 with high priority. This could cause issues with resource management, and shouldn't be used for long-running processes.

To Reproduce Open TF2 through TF2BD.

Expected behavior N/A (Not a bug, but a potential flaw. TF2 should be able to run without high priority.)

Desktop:

PazerOP commented 3 years ago

Many users are on computers that are resource constrained: 4 cores or less. In those situations, I find that running tf2 with high priority helps reduce issues with other programs (including tf2bd) taking up cpu time. That being said, I'll leave this on by default but add an option to turn it off.

GTcreyon commented 3 years ago

I think having it off by default would probably be safer, since not many users actually understand what it does enough to make an informed decision.

PazerOP commented 3 years ago

Could you elaborate on what kind of issues you are experiencing? I haven't heard of problems related to this from any other users.

GTcreyon commented 3 years ago

No issues personally, emphasis on "potential" instability. However, to clarify: https://docs.microsoft.com/en-us/windows/win32/procthread/scheduling-priorities

Use HIGH_PRIORITY_CLASS with care. If a thread runs at the highest priority level for extended periods, other threads in the system will not get processor time. If several threads are set at high priority at the same time, the threads lose their effectiveness. The high-priority class should be reserved for threads that must respond to time-critical events.

It's best to only use it if you need it for a specific purpose, for a short period of time.

PazerOP commented 3 years ago

It's true this is what the documentation says, however:

The high-priority class should be reserved for threads that must respond to time-critical events.

Such as game input, logic, and rendering ;)

GTcreyon commented 3 years ago

Fair! I can see the logic in that :P

mastercoms commented 3 years ago

Such as game input, logic, and rendering ;)

Later in the documentation, it says: "The important point is that a high-priority thread should execute for a brief time, and only when it has time-critical work to perform."

TF2 is not going to occupy 100% of your CPU for extended periods of time, or at all if you have more than ~4 cores.

You also say:

Many users are on computers that are resource constrained: 4 cores or less. In those situations, I find that running tf2 with high priority helps reduce issues with other programs (including tf2bd) taking up cpu time.

Could you clarify this information about <4 and >4 cores?

mastercoms commented 3 years ago

Also, I would argue that -high is out of the scope of TF2 Bot Detector. You could add an option for it, but realistically, this launch option is up for the user to add for their launch options in Steam. There's lots of arguably helpful launch options which improve the experience or performance, but obviously TF2 Bot Detector isn't trying to add all of those too.

Koi-TF2 commented 3 years ago

Also, I would argue that -high is out of the scope of TF2 Bot Detector. You could add an option for it, but realistically, this launch option is up for the user to add for their launch options in Steam. There's lots of arguably helpful launch options which improve the experience or performance, but obviously TF2 Bot Detector isn't trying to add all of those too.

I would tend to agree with what mastercoms is saying here, the -high launch option is entirely user dependent and unrelated to TF2BD. In my opinion there is not a solid enough reason to justify it being included by default, even as a toggle. It's just another option that any TF2 player can choose to add, similarly to changing resolutions, novid, etc. TL;DR it's not mandatory for TF2BD to run and therefore should not be included until there is strong enough evidence/reason to dispute the performance claims

PazerOP commented 3 years ago

It was added specifically in response to users on low-end CPUs complaining of reduced FPS while running tf2bd. That is the relevance. Users that are in unique and uncommon scenarios will be able to turn it off via the toggle, but for anyone else it should minimize the impact of running tf2bd alongside tf2.

UAVXP commented 3 years ago

I bet why don't they tried to lower the priority for the TF2BD itself

mastercoms commented 3 years ago

Yeah, I would think that setting the priority of the tool lower would be a better solution.

Tiagoquix commented 2 years ago

It was added specifically in response to users on low-end CPUs complaining of reduced FPS while running tf2bd.

@PazerOP In this case, it would be best to advise the user to use Steam Priority Launcher (or even advise them to use mastercomfig, and if they are already using it, to read its documentation). Making a toggle option for the program would be a waste of time.

getchoo commented 2 years ago

It was added specifically in response to users on low-end CPUs complaining of reduced FPS while running tf2bd.

@PazerOP i doubt a high thread priority would have any significant performance boost compared to an above normal priority or even normal. if you want to mess around with those kinds of startup options, a better method would be assinging core affinities and only selecting the highest boosting cores in the cpu - but that probably wouldn't do much considering the low-end pcs we're talking about.

Such as game input, logic, and rendering ;)

as @mastercoms said, microsoft's docs state that "a high-priority thread should execute for a brief time, and only when it has time-critical work to perform." game input, logic, and rendering are not considered time-critical when you're talking about both kernel space and user space (tf2 runs in the latter). from what i've read, high priorities are usually only used in kernel space and core os executables like dwm.exe, not in games that just suffer from bad optimization.

I have found that there are lots of background services, particularly from third parties, that like to run with above normal priorities.

would you be able to name a few? after a quick look through task manager, almost all of my background services are either at the default priority, set to below normal, or even low (this includes apps like discord and vibrancegui, utilities like msi afterburner/rtss, and even steam's own processes). if there are some occasional apps that for some reason default to high priority, i don't think it would be a good idea to follow that example, and users would be better off just lowering their priority manually.

if you do really want to mess with priorities though, i think @UAVXP's suggestion for lowering the priority of tf2bd would be the better choice. you could also suggest users install mastercomfig, close their extra background processes, and enable the 'sleep when unfocused' option for tf2bd.

for a super lazy and non-scientific example (that i think still has some ground), i took a quick look at task manager while tf2 was idle in the main menu and tf2bd was running, and i found that tf2bd had similar cpu usage to hl2.exe. could just be random, but after turning on 'sleep when unfocused,' cpu usage dropped to always being <1.5% and when i set the priority to below normal, cpu usage dropped even further, staying steady between 0%-0.7% usage.

default:

image

'sleep when unfocused' enabled, below normal priority:

image

overall, i think the argument for tf2 being launched with a high priority is a pretty weak one, especially when you consider microsoft's own guidelines for using it, along with opinions from community members like mastercoms and leo40git of steam priority launcher fame. furthermore, if cpu usage is the biggest worry here, i believe that lowering the cpu usage for tf2bd would be much more beneficial and stable compared to just slapping high priority on tf2 - and that seems to already be somewhat doable with my suggested method