Big Dictionaries cause huge UI performance dip even with HideInInspector

Issue #313 open
Former user created an issue

Problem

Noticeable performance problem (changing simple int variable takes several seconds) appear when relatively big (3000+ keys) Dictionary is attached to MonoBehaviour. Problem gets much worse (can't work with 1000+ keys in dict) if Dictionary has custom objects as values, and not strings/ints.

How To Reproduce

Script below can help illustrate problem, where adding tens of thousands records to stringList doesn't affect anything, adding something like 4000-5000 records to intStringDictionary will make that MonoBehaviour unusable.

[HideInInspector]
public Dictionary<int, string> intStringDictionary = new Dictionary<int, string>();

[HideInInspector]
public List<string> stringList = new List<string>();


public int currentDictIndex = 0;
public int currentListIndex = 0;

[Button]
public void AddSomeToDict()
{
    for (int i = currentDictIndex; i < currentDictIndex + 200; i++)
    {
        intStringDictionary.Add(i, i.ToString());
    }

    currentDictIndex = currentDictIndex + 200;
}

[Button]
public void CleanDict()
{
    intStringDictionary = new Dictionary<int, string>();
    currentDictIndex = 0;
}

[Button]
public void AddSomeToList()
{
    for (int i = currentListIndex; i < currentListIndex + 200; i++)
    {
        stringList.Add(i.ToString());
    }

    currentListIndex = currentListIndex + 200;
}

[Button]
public void CleanList()
{
    stringList = new List<string>();
    currentListIndex = 0;
}

Comments (1)

  1. Bjarke Elias
    • changed status to open

    Hey, thanks for reporting, and sorry for the inconvenience.

    Our next major patch will contain major performance improvements across the board. Odin currently doesn't handle rendering objects containing large amounts of data too well. But we've optimized the heck out of it in the next major patch. There, you can throw as much data at it as you want. It'll make no difference to Odin - which is currently not the case.

    We're starting beta of the next patch hopefully this month. (Send us a message from sirenix.net/contact with your Odin invoice ID if you want to in on it)

    That being said, we can only optimize it as much as Unity allows us to. When inspecting an object in the inspector, Unity runs serialization each GUI frame, which we haven't been able to find a way around. So if there is a lot to serialize, it will lag because of that. But that is only the case in the Unity's inspector window. If you are viewing the object in any other window, it'll run smooth regardless of how much data it has. It'll may lag when you're changing values, as it'll trigger serialization.

  2. Log in to comment