Closed bottiger1 closed 1 year ago
This could help:
Game is TF2, I have too many plugins and extensions for you to narrow down.
I think it could be caused because I am hooking PrecacheModel with dhooks, and this extension doesn't seem to play nicely with it.
I'm looking at the code here and it I don't understand why these hooks are needed, it seems to do the same thing as the original function and running FlushDynamicModels every time a new one is registered seems like it would decrease performance as it's already called once per frame.
Would you be able to explain the optimizations?
Were the hooks disabled at one point? When DHooks and this extension detour the same function, trying to disable an already running detour will crash the server
PrecacheModel is detoured to somewhat speed it up when the model is already precached.
CModelInfoServer::RegisterDynamicModel functions are detoured to disable dynamic multithreaded model precache, used by economy items. With dynamic precache disabled, there is no need for somewhat expensive locks in model code.
They were not disabled. I tried loading the extension before or after the hook is installed and both resulted in crashes. I looked at the source code here and there are comments saying it does not support hooking the same function.
Would you be able to give a summary on how all the optimizations work? It would save a lot of time for me trying to understand them.
Also are you sure removing the mdl lock is safe? It looks like you removed multithreading on pack snapshot. Does that really speed things up? I would imagine it would be better to remove work from the game thread even if that results in higher cpu usage as an extra core is easier to come by compared to higher clock speed. And did you consider activating sv_parallel_sendsnapshot?
Hmm. Could you provide the entire setup as an archive so i can perform analysis on that. I removed multithreaded encode because the original purpose of the mod was to pack as many servers as possible, more that thread count on the host. With that thing in mind multithreaded load is mostly pointless. But i can try to reimplement threaded encode later.
My setup is too large to upload and contains passwords and api keys embedded in plugins. You should be able to just use this dhook example plugin.
I've also found a bug with the input optimization.
I have a func_breakble with a vscript that connects "OnHealthChanged" to a vscript function. When I hit the button, the function triggers but vscript complains that activator doesn't exist. The issue goes away when I turn off input optimization. It doesn't seem to save a noticeble amount of cpu.
function ShotButton()
{
EntFireByHandle(activator,"SetHealth","0",0.00,null,null);
}
self.ConnectOutput("OnHealthChanged","ShotButton");
AN ERROR HAS OCCURRED [the index 'activator' does not exist]
Can you provide a summary for all the optimizations? It is a bit time consuming trying to figure out how they all work, especially the ones in pure assembly.
I removed AcceptInput optimizations due to some vscript related change to it, so the error may no longer occur. Your plugin wrongly assumes CBaseEntity::PrecacheModel is not a static function, which is the reason why it crashes. Use cdecl callconv instead of thiscall and set this to ignore, and remove this parameter from the hook. Also written some more info about optimizations
Sorry, I copied the parameters for the test plugin incorrectly, it has been a while since I touched the code.
But I assure you I have the right hook parameters in the actual plugin and it works and doesn't crash when this extension isn't loaded. Anyway I will just compile a version without that model and lock hooks, it doesn't actually seem to drop the cpu usage by any noticeable amount.
Do you know if the slot expansion mod works with players and not just bots? And would you be able to say what the limitations are? Just at a glance it looks like lag compensation and voice chat are disabled for players above 33 slots, very strong limitations that makes me wonder if it's worth trying.
lag compensation yes, its disabled for slots > 33 (Would have to be re implemented manually). Voice chat has a limit of 64 players though
Are there any other major limitations for the slot increase? I'm assuming you tried implementing lag compensation already and it was too difficult or time consuming?
Has it been tested with actual players or only bots?
Update
I've also tested the optimizations and it looks like only sig_perf_sendprop_optimize reduces the cpu usage by any noticeble amount. I recorded average cpu usage with all optimizations on and again with all but sendprop optimization on, and the difference was less than 1%.
And if you disable sendprop optimization while the server is running the server will crash a minute later.
I'm testing the slot limit increase for players and can't get it to stop crashing after ~35-37 players.
Crash is at CCvar::FindCommandBase
const ConCommandBase *cmd = GetCommands();
for ( ; cmd; cmd = cmd->GetNext() )
{
if ( !Q_stricmp( name, cmd->GetName() ) ) // cmd vtable corrupted on call to GetName
Also here's a public plugin that causes crashes in random places due to one of the hooks conflicting with the player mod.
The extra slots are never designed to be used by non bot players, there are many issues that arise from it
I'm aware that there are some issues but for some game modes the downsides are acceptable and it seems like you've made some crash fixes for most of them and also have debug commands for this particular crash.
Are you not interested in fixing the remaining crashes?
no
ok then I'll close this issue and work on this myself then.
I tested the optimizations on a live server and the server crashed after 1-2 minutes.
Did not get a very useful crash dump, looks like memory corruption. I can offer you the core dump if you want privately.