F2 / F2s-sourcemod-plugins

F2's SourceMod plugins for competitive Team Fortress 2
14 stars 8 forks source link

are the http requests run in the background to avoid stutter? #22

Closed tommy-mor closed 1 year ago

tommy-mor commented 1 year ago

in the sourcemod built in sql plugin, it allows for running the queries in the background to avoid stutters.

https://wiki.alliedmods.net/SQL_(SourceMod_Scripting)#Threading

If your database server is remote or requires a network connection, queries can cause noticeable gameplay lag, and supporting threading is often a good idea if your queries occur in the middle of gameplay.

in the mgemod source, all of the sql queries take callbacks, as they are executed in background, avoiding stutters.

logs upload method http req does have a callback, but i'm not sure if it's running the request in a different thread. I don't understand cpp/sp enough to say if the steamworks http lib runs the thread in the background.

In some matches with the default rgl config, there is a noticeable stutter as a client to the server, as well as the stv on round end. From the stv, this is undesirable as it spoils the result of the upcoming last push. Is a synchronous http request from logstf_midgameupload 1 the culprit? LMK if i'm missing something

sapphonie commented 1 year ago

image

F2 commented 1 year ago

The stuttering is not related to uploading, since that is indeed done in a background thread. It is related to some of the file operations being done by the plugin. I am looking into splitting the workload into smaller chunks, to avoid stutters.

sapphonie commented 1 year ago

you could probably just make a timer to do all the work + 5 seconds after the game_over event lol

that would make it take 90 seconds to get logs uploaded but also like, whatever? definitely an easier solution than setting up threads or async bullshit in sourcepawn, you would have a better time doing it in C++ as an extension

sapphonie commented 1 year ago

alternatively you could write (flush) the log every x seconds but i dont know if that would actually be a good idea, might introduce microstutters

tommy-mor commented 1 year ago

I'm not sure the stutters are still happening. Last match I watched I couldn't find them. Would be worth recreating them to make sure that it's a real thing still

F2 commented 1 year ago

you could probably just make a timer to do all the work + 5 seconds after the game_over event lol

This doesn't solve mid-game uploads. If we wait 90 seconds, it would lag for the players on the server.


you would have a better time doing it in C++ as an extension

Unless there is a default extension which can already do this, it would require every server owner to install an extra extension. I would rather not require that. (And besides, I wouldn't want to develop and maintain an extension.)


alternatively you could write (flush) the log every x seconds but i dont know if that would actually be a good idea, might introduce microstutters

The issue is not writing the log, but the file operations happening at the time of upload.


I'm not sure the stutters are still happening. Last match I watched I couldn't find them. Would be worth recreating them to make sure that it's a real thing still

The stutters have always been there, and it is easy for me to recreate them on my own machine.

I have worked on a fix that will reduce the risk of stutters. Here you can see it in action - there is a clear stutter 1 second into the video, which is not visible with the new plugin.

Once I have finished testing, I will release it. (#24)

sapphonie commented 1 year ago

phenomenal work