This object is in archive! 

[1.194] horrible performance due to assertions causing increased load times from 6 to over 20 mins.

LordTylus shared this bug 4 years ago
Solved

Hello there,

I developed a ShipFixer plugin for torch servers which basically cuts and pastes a ship if the player demands it to fix some clang behavior.

Today I got the report that it seems to cause LONG server freezes. And even crashes due to threads being frozen for too long.


I decompiled a bit and found

    public static void AddEntityWithId(IMyEntity entity)
    {
      MyDebug.Assert(entity != null, "Adding null entity. This can't happen.");
      MyDebug.Assert(!MyEntityIdentifier.EntityList.ContainsKey(entity.EntityId), "Entity with this key (" + (object) entity.EntityId + ") already exists in entity list! This can't happen.");
      MyDebug.Assert(!MyEntityIdentifier.EntityList.ContainsValue(entity), "Entity is already registered by different ID. This can't happen.");
      if (MyEntityIdentifier.EntityList.ContainsKey(entity.EntityId))
        throw new DuplicateIdException(entity, MyEntityIdentifier.EntityList[entity.EntityId]);
      MyDebug.Assert(MyEntityIdentifier.InEntityCreationBlock || MyUtils.MainThread == Thread.CurrentThread, (string) null);
      MyEntityIdentifier.EntityList.Add(entity.EntityId, entity);
    }
in MyEntityIdentifier

Assertions seem to be new compared to the previous version. And I also noticed a brutal decrease in startup performance of our servers. So I did some testing

My Testworld has 1,224 Grids, with 387,606 blocks total.


Basic VRage.Game.dll

22:30:30.7040 -> Server crashed at 22:49:59.5117 >> 19 minutes 29 seconds

(frozen thread check by torch noticed no responce for 60 seconds and killed it)

Since the ContainsValue call in the assertion is a very bad idea. (and the ContainsKey calls is made twice I decompiled the VRage.Game.dll removed the Assertions and recompiled it.


Modified VRage.Game.dll (remove all Assertions)

23:26:05.6689 -> Game Ready message at at 23:33:46.7108 >> 6 minutes 41 seconds


public static void AddEntityWithId(IMyEntity entity)
{
    if (MyEntityIdentifier.EntityList.ContainsKey(entity.EntityId))
    {
        throw new DuplicateIdException(entity, MyEntityIdentifier.EntityList[entity.EntityId]);
    }
    MyEntityIdentifier.EntityList.Add(entity.EntityId, entity);
}

Please fix this ASAP as its basically totally game breaking. Spawning in a simple NPC ship can freeze up big servers for minutes.

Thank you

Replies (2)

photo
3

Hi,

We are aware of this issue and working on the fix. Thanks for the report.

photo
1

Since Assertions have been removed from the Build again Ages ago you may close this Issue

Replies have been locked on this page!