Search Unity

  1. Unity Asset Manager is now available in public beta. Try it out now and join the conversation here in the forums.
    Dismiss Notice

Feedback (Case 1185953) "Performance Improvements To Text Serialization" feedback

Discussion in '2019.3 Beta' started by Peter77, Sep 22, 2019.

  1. Peter77

    Peter77

    QA Jesus

    Joined:
    Jun 12, 2013
    Posts:
    6,619
    Unity 2019.3 comes with "Performance Improvements To Text Serialization In 2019.3":
    https://forum.unity.com/threads/performance-improvements-to-text-serialization-in-2019-3.661993/

    I used Unity 2019.3.0b3 to run a few tests that measure the time the editor requires to load and save a scene in edit mode.

    What is the test doing?
    • It captures the time before and after calling EditorSceneManager.OpenScene to calculate the duration to open or save a scene.
    • The test is repeated with different scenes, each containing a different number of either game objects or prefab instances (10.000, 20.000, 30.000, 40.000, 50.000).

    Observation
    1. This test shows that "load scene" and "save scene" improved slightly compared to earlier Unity versions.
    2. Loading prefab instances is more expensive than loading game objects.
    3. Saving prefab instances is significantly faster than saving game objects.
    4. The time Unity requires to load gameobjects or prefab instances does not scale linearily with the number of objects.
    5. The time Unity requires to save gameobjects does not scale linearily with the number of objects.

    Please see the attached images.

    load_scene.png

    save_scene.png

    load_scene_profiler.png

    save_scene_profiler.png


    Reproduce
    1. Open attached project
    2. Open Project Settings, select "Editor", set "Asset Pipeline Mode" to "Version 2" and "Asset Serializaiton Mode" to "Force Text"
    3. Open Scene "Transform_10000"
    4. Click from main menu "Test > Measure open scene" or "Measure save scene" depending on what you want to do
    5. Notice in the Console window "Open scene took 1.23 secs"
    6. Repeat this multiple times for the scene and take a sample that makes most sense.
    7. Repeat this for scenes Transform_20000, Transform_30000, Transform_40000, Transform_50000
    8. Repeat this for scenes Transform_Prefab_10000, Transform_Prefab_20000, etc...

    Actual
    • Load/save duration does not scale linearly with the number of objects.
    • Loading 10.000 game objects takes 1.8s, loading 5x the amount does not cost 5x more, but 43x more time (77ms)!

    Expected
    I expected the cost of loading and saving a scene scales linearly with the number of objects.
    If loading 10.000 objects costs 1.8s, then loading 50.0000 objects should cost 9s (1.8s*5) at most.

    Note
    Please reproduce this on hardware similar to the hardware I used to submit this bug-report with. The numbers are probably very different if you try to reproduce this on high-end hardware.

    I did that test for Unity 5.6 a while ago too, so we have numbers to compare:
    https://forum.unity.com/threads/5-6...e-of-open-savescene-and-enterplaymode.447500/


    Download
    For anyone interested in the test project:
    http://www.console-dev.de/bin/unity_case_1185856_no_scene_reload.zip
     
    Last edited: Sep 22, 2019
    mGMM, jamespaterson, Prodigga and 4 others like this.
  2. rastlin

    rastlin

    Joined:
    Jun 5, 2017
    Posts:
    127
    Fine job as usual Peter.

    However, I don't think that expectation for load times to be linear based on number of objects is a reasonable one. We can clearly see it's an exponential problem.

    The more objects you have, the more relationship between them there are - parenthood, references, prefab roots etc. It make sense in my opinion it takes longer the more objects you have.
     
  3. Baste

    Baste

    Joined:
    Jan 24, 2013
    Posts:
    6,338
    The example scenes doesn't have any parents or references. It's literally just 10k, 20k etc. empty game objects in the scene root. So you should for sure be able to expect the scaling to be near linear - it's just doing exactly the same parsing operation again and again, and writing the result into a list of objects in the scene.

    If the amount of objects causes your system to start running out of memory, it's natural to expect the times to not be linear anymore, but 50k GameObjects with nothing on them shouldn't do that- assuming they're a whooping 200 bytes large, that's still just 10 mb...
     
  4. AlkisFortuneFish

    AlkisFortuneFish

    Joined:
    Apr 26, 2013
    Posts:
    973
    As far as I know, the transform hierarchy is using pre-allocated memory memory blocks, since some point in the 5.x cycle. As a result, I do expect that at some point it is going to start hitting the limits of the allocated memory and have to perform copies. I would still expect it to perform in the usual list-like behaviour of doubling the capacity every time, the measurements should be able to show that if that is what the issue is.
     
  5. Peter77

    Peter77

    QA Jesus

    Joined:
    Jun 12, 2013
    Posts:
    6,619
    Will anyone look at this issue? QA didn't reply to the bug-report yet.
     
  6. harryr

    harryr

    Unity Technologies

    Joined:
    Nov 14, 2017
    Posts:
    38
    Hi Peter, sorry for the delay!
    Firstly thank you for providing this feedback, I've gotten in touch with the scene management team to try and work out if linear scene loading times is the correct expectation.

    Regarding my initial forum post this seems like the most relevant line
    Would you be able to provide any more specific details? (Mainly hoping for some timings and specific Unity versions tested)
     
  7. Peter77

    Peter77

    QA Jesus

    Joined:
    Jun 12, 2013
    Posts:
    6,619
    Thanks for your answer.

    I did the same test with Unity 5.6 and when I compare this with the recent 2019.3 test I posted here, it shows that 2019.3 is slightly faster.
    https://forum.unity.com/threads/5-6...e-of-open-savescene-and-enterplaymode.447500/

    However, the non-linear scene loading/saving behavior outweighs any possible speedups in (de)serialization. For example, lets assume deserialization is 1s faster, the optimization doesn't make much of a difference for me as an user, if the remaining things of the loading code take two minutes to complete.
     
    BTStone likes this.