Search Unity

  1. Unity 2018.3 is now released.
    Dismiss Notice
  2. The Unity Pro & Visual Studio Professional Bundle gives you the tools you need to develop faster & collaborate more efficiently. Learn more.
    Dismiss Notice
  3. We've updated our Terms of Service. Please read our blog post from Unity CTO and Co-Founder Joachim Ante here
    Dismiss Notice
  4. Want to provide direct feedback to the Unity team? Join the Unity Advisory Panel.
    Dismiss Notice
  5. Improve your Unity skills with a certified instructor in a private, interactive classroom. Watch the overview now.
    Dismiss Notice

Performance When Saving Prefabs

Discussion in 'Prefabs' started by noethis, Dec 13, 2018.

  1. noethis

    noethis

    Joined:
    Nov 11, 2013
    Posts:
    101
    With the new prefab improvements saving prefabs has become a huge issue for me. It takes over 20 seconds to save a prefab that has about 250 gameobjects in it and is used a handful of times in several scenes. This obviously makes Auto-Save not remotely viable and even just occasional saving has slowed down my workflow a lot compared to pre-2018.3.

    Is the performance still a work in progress? Are there things I can do to improve it?
     
  2. runevision

    runevision

    Unity Technologies

    Joined:
    Nov 28, 2007
    Posts:
    1,432
    Prefab saving in itself should not have gotten significantly slower for an object of that size. There might be slight decrease because Prefab now have to be imported whenever they are saved, but it should not approach anything near 20 seconds for 250 GameObjects.

    What might be happening is that a lot of other things are dependent on the Prefab you're saving. If the Prefab is used as a nested Prefab in many other Prefabs, or is the base of many Prefab Variants, then all of those Prefabs that are dependent on this one need to be re-imported as well. Obviously such a setup was not possible previously, since there was no nested Prefabs or Prefab Variants.

    If you see a performance decrease even for a Prefab with nothing that depends on it, then that's a real issue and we would appreciate a bug report about it. Particularly if you can show it with a Prefab from 2018.2 or earlier and compare the time for saving it there with how long it takes in 2018.3.

    Apart from that we're focused on performance in general and future improvements to Unity's Asset Database (which is actively in development as we speak) and handling of dependencies should eventually have a positive effect for Prefabs as well, but currently we're a bit constrained by the existing technology stack in Unity.
     
    SugoiDev likes this.
  3. noethis

    noethis

    Joined:
    Nov 11, 2013
    Posts:
    101
    Thanks for the response--I'll see if I can test it in 2018.2 vs 2018.3.
     
    runevision likes this.
  4. Ghat-Smith

    Ghat-Smith

    Joined:
    Aug 16, 2016
    Posts:
    11
    Hi. I also noticed longer saving time since 2018.3. Found the origin of the problem in my case, wanted to share it here.
    Some prefabs had a script with OnValidate method. OnValidate is called when saving the scene. It could slow down the saving.

    In my case, the problematic line was setting the light (realtime) intensity (or light color depending on cases). Even if the set value was the same as the current value. Just added an if case to compare current and new value, and set only if necessary. I guess it was forcing recalculating the light. Don't know if it should be considered as a bug or not.

    Will try to reproduce the problem in an empty project and send a bug report, in case of.
     
    Peter77 likes this.
  5. sarahnorthway

    sarahnorthway

    Joined:
    Jul 16, 2015
    Posts:
    19
    I also noticed an immediate increase in the time to save a scene in my project after upgrading to 2018.3. Even saving a blank empty unchanged scene took 3 seconds, with the cursor flashing between arrow and progress circle. Larger scenes were taking 5-6 seconds. All saving had been < 1 second before.

    Restarting Unity fixed the problem.

    I'd been working with several prefabs referenced ~50 times in one scene, including a nested one. I'm guessing Unity had them flagged as changed and was checking them over and over on every save? I haven't seen the issue since. In case other people have this issue, try restarting before you waste time debugging it.
     
  6. runevision

    runevision

    Unity Technologies

    Joined:
    Nov 28, 2007
    Posts:
    1,432
    This is problematic, but an increase in time in saving an empty scene without Prefabs is unlikely to be related to Prefabs. There are plenty of other changes in 2018.3.

    If you have larger scenes that do contain Prefabs and want to check how much of the time it takes to save them might be related to Prefab functionality, you could make a copy of the scene where you unpack all Prefabs completely, so there's the same amount of objects but no longer any Prefabs, and then save that for comparison.

    If you have a reliable slowdown between 100% comparable scenes in 2018.3 versus 2018.2, feel free to file a bug report (please attach the project prior to 2018.3 upgrade so we can open it in 2018.2 too) so our QA can have a look at it and send it to a relevant team as appropriate.