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

Drop debug allocs a lot #5638

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion Robust.Server/GameStates/PvsData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ namespace Robust.Server.GameStates;
/// </summary>
internal sealed class PvsSession(ICommonSession session, ResizableMemoryRegion<PvsData> memoryRegion)
{
#if DEBUG
public HashSet<NetEntity> ToSendSet = new();
#endif

public readonly ICommonSession Session = session;

public readonly ResizableMemoryRegion<PvsData> DataMemory = memoryRegion;
Expand Down Expand Up @@ -197,7 +201,7 @@ public void Validate(MetaDataComponent comp)
{
DebugTools.AssertEqual(NetEntity, comp.NetEntity);
DebugTools.AssertEqual(VisMask, comp.VisibilityMask);
DebugTools.AssertEqual(LifeStage, comp.EntityLifeStage);
DebugTools.Assert(LifeStage == comp.EntityLifeStage);
DebugTools.Assert(LastModifiedTick == comp.EntityLastModifiedTick || LastModifiedTick.Value == 0);
}
}
Expand Down
10 changes: 7 additions & 3 deletions Robust.Server/GameStates/PvsSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,9 @@ private void GetEntityStates(PvsSession session)
// Process all entities in visible PVS chunks
AddPvsChunks(session);

#if DEBUG
VerifySessionData(session);
#endif

var toSend = session.ToSend!;
session.ToSend = null;
Expand Down Expand Up @@ -332,11 +334,12 @@ private void GetEntityStates(PvsSession session)
session.Overflow = oldEntry.Value;
}

[Conditional("DEBUG")]
#if DEBUG
private void VerifySessionData(PvsSession pvsSession)
{
var toSend = pvsSession.ToSend;
var toSendSet = new HashSet<NetEntity>(toSend!.Count);
var toSend = pvsSession.ToSend!;
var toSendSet = pvsSession.ToSendSet;
toSendSet.Clear();

foreach (var intPtr in toSend)
{
Expand All @@ -360,6 +363,7 @@ private void VerifySessionData(PvsSession pvsSession)
|| data.LastSeen == _gameTiming.CurTick - 1);
}
}
#endif

private (Vector2 worldPos, float range, EntityUid? map) CalcViewBounds(Entity<TransformComponent, EyeComponent?> eye)
{
Expand Down
Loading