Optimize default HandleCallbacks() loop

By using a LongRunning hint, our callback handler loop will most likely be scheduled to run in it's own thread instead of using threadpool threads.
With low amount of bots it doesn't matter - the amount of tasks is very small, and the amount of available threads provided by the runtime is usually really big, so scheduler is almost always running all the jobs at the same time without starvation whatsoever.
But with crapload of bots executing crapload of tasks at the same time, we might observe low-to-medium thread starvation and context switching, that might put our most important callbacks handling task together with all other tasks, which could render callback loop delays when ASF is under heavy load.
This small change is a hint to scheduler that this task should run on it's own thread and have highest 'priority' over all other normal tasks. This way our loop is never starved, and it also allows better tasks management.
It's purely cosmetic - even without it there is no observable degradation that could create any side-effects, but we know that this task will run for a very long period, and it's important to keep ASF bot responsive to Steam events, so it should have highest priority and it's own thread
This commit is contained in:
JustArchi
2017-01-29 01:55:26 +01:00
parent a3c5e8ab0c
commit c48f05f5cc

View File

@@ -2595,7 +2595,7 @@ namespace ArchiSteamFarm {
private async Task Start() {
if (!KeepRunning) {
KeepRunning = true;
Task.Run(() => HandleCallbacks()).Forget();
new Task(HandleCallbacks, TaskCreationOptions.LongRunning).Start();
ArchiLogger.LogGenericInfo(Strings.Starting);
}