Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[469c] Too many int files can blown game server #1218

Closed
SeriousBuggie opened this issue Mar 23, 2023 · 9 comments
Closed

[469c] Too many int files can blown game server #1218

SeriousBuggie opened this issue Mar 23, 2023 · 9 comments
Labels
enhancement Feature request high-prio We will try to resolve this issue before the next patch release UnrealScript This is an issue in the UnrealScript code
Milestone

Comments

@SeriousBuggie
Copy link
Collaborator

GameInfo.GetRules:

function string GetRules()
{
	local string ResultSet;
	local Mutator M;
	local string NextMutator, NextDesc;
	local int Num, i;

	ResultSet = "";

	if( EnabledMutators == "" )
	{
		for (M = BaseMutator.NextMutator; M != None; M = M.NextMutator)
		{
			Num = 0;
			NextMutator = "";
			GetNextIntDesc("Engine.Mutator", 0, NextMutator, NextDesc);
			while( (NextMutator != "") && (Num < 50) )
			{
				if(NextMutator ~= string(M.Class))
				{
					i = InStr(NextDesc, ",");
					if(i != -1)
						NextDesc = Left(NextDesc, i);

					if(EnabledMutators != "")
						EnabledMutators = EnabledMutators $ ", ";
					 EnabledMutators = EnabledMutators $ NextDesc;
					 break;
				}

				Num++;
				GetNextIntDesc("Engine.Mutator", Num, NextMutator, NextDesc);
			}
		}
	// utpg: mutator/browser fix begin
	}
	if(EnabledMutators != "")
		ResultSet = ResultSet $ "\\mutators\\"$EnabledMutators;
	// utpg: mutator/browser fix end
	ResultSet = ResultSet $ "\\listenserver\\"$string(Level.NetMode==NM_ListenServer)
						  $ "\\password\\"$string(GamePassword!="");

	return ResultSet;
}

Imagine EnabledMutators is empty and in System directory exists 50 .int files which not correspond any of your mutators.
And Imagine you use 10 mutators.

Any UDP packet, which request rules force your server do 500 calls of GetNextIntDesc.
Which expensive as hell. Your tick rate start floating and game goes totally unplayable.

As solution:

  1. Server must look more then 50 times for each mutator. It can be 200 or 500.
  2. If nothing found, it must be marked as result and not run again.
  3. Whole loop must be reworked. Currently it make same loop for each mutator. Which can be reduced to better loop.
@SeriousBuggie
Copy link
Collaborator Author

Possible solution:

function string GetRules()
{
	local string ResultSet;
	local Mutator M;
	local string TestList, NextMutator, NextDesc;
	local int Num, i;

	ResultSet = "";

	if (EnabledMutators == "")
	{
		TestList = " ";
		for (M = BaseMutator.NextMutator; M != None; M = M.NextMutator)
		{
			NextMutator = Caps(string(M.Class)) $ " ";
			if (InStr(TestList, " " $ NextMutator) == -1)
				TestList = TestList $ NextMutator;
		}
		
		if (TestList != " ")
		{
			Num = 0;
			NextMutator = "";
			GetNextIntDesc("Engine.Mutator", 0, NextMutator, NextDesc);
			while (NextMutator != "" && Num < 500)
			{
				i = InStr(TestList, " " $ Caps(NextMutator) $ " ");
				if (i != -1)
				{
					TestList = Left(TestList, i) $ Mid(TestList, i + 1 + Len(NextMutator));
					i = InStr(NextDesc, ",");
					if (i != -1)
						NextDesc = Left(NextDesc, i);
	
					if (EnabledMutators != "")
						EnabledMutators = EnabledMutators $ ", ";
					EnabledMutators = EnabledMutators $ NextDesc;
					if (TestList == " ")
						break;
				}
	
				Num++;
				GetNextIntDesc("Engine.Mutator", Num, NextMutator, NextDesc);
			}
		}
		if (EnabledMutators == "")
			EnabledMutators = " ";
	}
	// utpg: mutator/browser fix begin
	if (EnabledMutators != " ")
		ResultSet = ResultSet $ "\\mutators\\"$EnabledMutators;
	// utpg: mutator/browser fix end
	ResultSet = ResultSet $ "\\listenserver\\"$string(Level.NetMode==NM_ListenServer)
						  $ "\\password\\"$string(GamePassword!="");

	return ResultSet;
}

Known side effects:
Mutators order depends from int files order, not from actors chains in mutator list.

@SeriousBarbie
Copy link

Why not cache the result and renew it on every game start?

@an-eternity
Copy link

an-eternity commented Mar 23, 2023

It is good to iterate through int files once only, can also add a simple sorter loop then to restore a proper order...
But from the other hand it would be quite enough just to add a global flag that indicates that no description found for any mutator... (to not complicate the code).

Limit of 50 need to increase anyway, of course.

@SeriousBuggie
Copy link
Collaborator Author

Why not cache the result and renew it on every game start?

It already do that. But coded badly. If it not able resolve anything, then it not change anything, and try it again, like nothing happen and it is clean start. In my change I set Space as result of empty work, so it ensure for call it once.

@SeriousBuggie
Copy link
Collaborator Author

Solution above, already fix all set of problems described here.
It load more files, load once, even if no any results, iterate over int files only once, and only if need.

I think order of mutator names not really matter, so no point waste time try use order from actors. But anyway mention this as possible side effect.

@SeriousBuggie
Copy link
Collaborator Author

SeriousBuggie commented Mar 25, 2023

Workaround:
ServerActor for fix issue:
FixLagSpikes.zip
Add it to ServerActor. Not need to be listed in ServerPackages.

Used code:

function PostBeginPlay() {
	Level.Game.GetRules();
	if (Level.Game.EnabledMutators == "") {
		Log("Server not able make mutators list - fixed", Class.Name);
		Level.Game.EnabledMutators = "-";
	}
	Destroy();
}

@an-eternity
Copy link

I think order of mutator names not really matter, so no point waste time try use order from actors. But anyway mention this as possible side effect.

In some cases it does matter...
Even if it does not (or seems so), a way that keeps original behavior has to be preferrable.

@SeriousBuggie
Copy link
Collaborator Author

Depends how hard it implement.

@stijn-volckaert stijn-volckaert added high-prio We will try to resolve this issue before the next patch release enhancement Feature request UnrealScript This is an issue in the UnrealScript code fixed in the next patch labels Apr 30, 2023
@CacoFFF
Copy link

CacoFFF commented May 2, 2023

@SeriousBuggie lookup Core.Registry native class, you can rewrite a lot of unoptimized loops to use that instead now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Feature request high-prio We will try to resolve this issue before the next patch release UnrealScript This is an issue in the UnrealScript code
Projects
None yet
Development

No branches or pull requests

5 participants