Skip to content

Commit

Permalink
review
Browse files Browse the repository at this point in the history
  • Loading branch information
metalgearsloth committed Nov 20, 2023
1 parent 56869a0 commit d1211c4
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
3 changes: 2 additions & 1 deletion Robust.Shared/CVars.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,10 @@ protected CVars()

/// <summary>
/// Size of the pool for Lidgren's array buffers to send messages.
/// Set to 0 to disable pooling.
/// </summary>
/// <remarks>
/// Set really high because it's probably constant across a server how much is getting used.
/// Higher just means more potentially wasted space and slower pool retrieval.
/// </remarks>
public static readonly CVarDef<int> NetPoolSize =
CVarDef.Create("net.pool_size", 512, CVar.CLIENT | CVar.SERVER);
Expand Down
11 changes: 10 additions & 1 deletion Robust.Shared/Network/NetManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -576,7 +576,16 @@ private NetPeerConfiguration _getBaseNetPeerConfig()
// ping the client once per second.
netConfig.PingInterval = 1f;

netConfig.RecycledCacheMaxCount = _config.GetCVar(CVars.NetPoolSize);
var poolSize = _config.GetCVar(CVars.NetPoolSize);

if (poolSize <= 0)
{
netConfig.UseMessageRecycling = false;
}
else
{
netConfig.RecycledCacheMaxCount = Math.Min(poolSize, 8192);
}

netConfig.SendBufferSize = _config.GetCVar(CVars.NetSendBufferSize);
netConfig.ReceiveBufferSize = _config.GetCVar(CVars.NetReceiveBufferSize);
Expand Down

0 comments on commit d1211c4

Please sign in to comment.