-
FXServer version
FXServer-master SERVER v1.0.0.5181 win32
Running on Windows Server 2019 [10.0.17763.2300], running on Intel® Xeon® CPU E3-1270 v6 @ 3.80GHz -
What you expected to happen
The platform for handling server events should be efficient. -
What actually happens
The platform isn’t efficient and it kills server performance. -
Category of bug (eg. client, server, weapons, peds, native)
Platform / C# -
Reproducible steps, preferably with example script(s)
Add this code to a server with a substantial amount of players, then run the command.
public class PlatformBugTestScript : BaseScript
{
[Command("new-testing-command", Restricted = true)]
private void TestingCommand([FromSource] Player source, string[] args)
{
Debug.WriteLine("Test handler added.");
EventHandlers["entityCreating"] += new Action<int>(TestingTask);
}
[Command("new-testing-command-2", Restricted = true)]
private void Testing2Command([FromSource] Player source, string[] args)
{
Debug.WriteLine("Test handler removed.");
EventHandlers["entityCreating"] -= new Action<int>(TestingTask);
}
private void TestingTask(int param)
{
// Nothing at all here
}
}
I’ve chosen the entityCreating
event because it’s constantly run thousands of times by players. The video below uses the code above to demonstrate that the platform behind event handlers is not performing well.
The screenshot below shows the CPU usage of the FxServer running C# scripts containing lots of event handlers. CPU details can be found above.
I bet that solving this problem in the platform will remove all those “server thread hitch warnings” that my C#-based server is suffering from, and I am 100% willing to offer my help in creating a solution because it’s mainly in my interest and probably no other big C#-based servers exist.