Disclaimer: This is completely unrelated to the recent update about the resource tick warning! This thread is related to server-side scripting.
Dear FiveM community
We recently enabled OneSync Infinity on our server. We still need to fix a few script migrations but are after some tweaking overall happy with what it provides to our community.
However, since then our server had some infrequent crashes (around 1-2 days apart) that had error messages like
fivem | [BigMode] Update thread loopTime: 12 ms (your server is lagging or updateThreadTimeThreshold is too low)
At some point it reached
fivem_1 | Error: Loop svMain seems hung! (last checkin 95 seconds ago)
fivem_1 | Warning: svMain watchdog stack: root
fivem_1 | Error: Loop svSync seems hung! (last checkin 137 seconds ago)
fivem_1 | Warning: svSync watchdog stack: root
fivem_1 | Error: Loop svNetwork seems hung! (last checkin 135 seconds ago)
fivem_1 | Warning: svNetwork watchdog stack: root
fivem_1 | Error: Loop default seems hung! (last checkin 130 seconds ago)
fivem_1 | Warning: default watchdog stack: root
So I assumed it’s a resource time problem. I remembered that there was the profiler
and recorded some ticks on the server.
What immediately catched my eye was the fact that there are 4 major performance eaters.
- PocceMod
- vMenu
- Hypnonema
- and our own resourcepack alternate-universe
They are all C# resources. All other resources are LUA and as you can see in the screenshot, they bare take any time to run.
I am aware that PocceMod and vMenu are not the most performant resources and we plan to merge their codebases into ours or rework these plugins, but this thread is not about 3rd-party resource support.
Our framework alternate-resources
however is still at the very beginning of development. Right now it only consists of a local chat function which is only using one command and events, no ticks. And still it somehow takes over 5 ms on it’s own to run per tick.
Our server is currently running artifact 3071 on Linux on a ZAP Hosting root server (not GSP). From some conversations on Discord I gathered that there is some overhead to C# resources due to AppDomain but I dont understand why it’s this bad for a practically empty resource. After all other users are using C# as well and since I can’t find any info about this issue elsewhere I assume we are doing something wrong.
I have tested this on a local windows server and observed the same results. C# resources took multiple ms on the server compared to <0.1ms LUA resources.
Also out of curiosity I profiled the client and didn’t see such a dramatic difference between client and server, even though our resource contains roughly the same amount of code on both sides.
Any help or suggestions for fixes or tests are greatly appreciated. Is the crash even related to the C# resources or could something else cause them? Still I’d like to know how to optimize C# resources server side so the are not that heavy on a tick.