Search Unity

Unity Introducing the Editor Iteration Profiler

Discussion in 'Profiler Previews' started by Rarepops, Jun 9, 2020.

  1. Rarepops

    Rarepops

    Unity Technologies

    Joined:
    Sep 5, 2019
    Posts:
    40
    Hi!

    First I would like to clarify My physical Stopwatch says "33,19 ms" -> ~33 sec and if you meant 33,190 ms :)

    Secondly, EIP uses data provided by the Profiler which does have some overhead. For example if you were to use Deep Profiling, those times would be even higher. There's also overhead from the windows themselves. As recommended in the original post, best results are achieved by closing most of the windows then checking out the data. You can also try exporting in HTML which will show you the % distribution of those timings (more useful to know the % of time it takes relative to everything else rather than the exact timing).

    If you want more accurate timings I would suggest you wrap your code with the StopWatch class and handle those yourself.

    Thirdly, as the Domain Reload takes multiple frames and steps it would be a bit difficult to reflect the real timing of it. What this tool provides is a way to identify frames that would be responsible for the majority of the time.
     
  2. Hannibal_Leo

    Hannibal_Leo

    Joined:
    Nov 5, 2012
    Posts:
    352
    Yes, it was a typo xD

    Talking about recompile time here - so I guess, it is not affected by the "Enter Play Mode Settings".

    So to be clear, the EIP does or does not include scene reloading (including Awakes/OnEnable of GameObjects in the Scene, set to [ExecuteAlways]) ?

    The difference is 15 seconds, so it has to be something quite big ...

    I know that all(?) Constructors of Scripts in the Scene and ScriptableObjects are called, while the old ones are thrown away, generating a lot of garbage and it takes some time for GC to clean it up..
    Maybe that's what is missing here? Or something else?
    That's what happens at domain reload "Backup, unload and recreate C# state", right?
     
  3. Rarepops

    Rarepops

    Unity Technologies

    Joined:
    Sep 5, 2019
    Posts:
    40
    Yes, info such as Awake/OnEnable info should be something EIP collects. This tool is more meant to help you as the user to identify problematic areas in your code which you could do something about. EIP simply uses data provided by the Profiler.

    We also report some timings for domain reload in the Editor Logs, maybe check these out too? I don't think the use case you are describing where you want to see for how long the Editor is non-interactible during a domain reload is supported as you would expect, unfortunately.
     
    Hannibal_Leo likes this.
  4. Bryan-Legend

    Bryan-Legend

    Joined:
    Sep 8, 2012
    Posts:
    71
    I've done a ton of optimization and now the majority of my enter/exit times are used in the backup/load scene code, as shown in the attached screenshot.

    The scene I'm working with has thousands of objects and saves to 56mb of YAML on an SSD with a 32 core CPU.

    1. Can your team spend some time optimizing this part of Unity? It would be of high value to everyone. Perhaps multi-threading it like Factorio talks about at the end of this blog post: Friday Facts #364 - 1.1 stable | Factorio

    2. How much performance is lost by using YAML vs. binary saving?

    3. Is there a way to flag a scene as Binary so that I can used mixed mode and not convert my entire project to binary serialization (which takes a few hours)?


    upload_2021-5-13_13-17-41.png
     
    Rarepops likes this.
  5. Bryan-Legend

    Bryan-Legend

    Joined:
    Sep 8, 2012
    Posts:
    71
    I was able to use mixed by saving a new copy of the scene. Switching to binary scene did not have much of an effect as shown here.
    upload_2021-5-13_13-31-38.png
     
    Rarepops likes this.
  6. liortal

    liortal

    Joined:
    Oct 17, 2012
    Posts:
    3,506
    Is this package still maintained? @Rarepops
    On GitHub, last update was around 8 months ago.
     
  7. Rarepops

    Rarepops

    Unity Technologies

    Joined:
    Sep 5, 2019
    Posts:
    40
    Hey! Unfortunately, no updates are planned anytime soon, but we're working on other tools that can help users in similar fashion.

    Also, it's basically just reusing the Profiler data such that you could still get this info, albeit manually.
     
    mariandev likes this.
  8. ARESGOW224

    ARESGOW224

    Joined:
    Oct 27, 2019
    Posts:
    3
    Hello! I made a not so obvious astronomical mistake somewhere during development which ended up causing about a 9 minute load time when exiting play mode. Found the event that is causing the huge chunk of time loss but I'm not sure how to modify the event. Its called "Prefabs.ApplyModificationsToObjects." Any advice would be greatly appreciated! :)
    upload_2021-6-13_20-4-5.png
     

    Attached Files:

  9. Rarepops

    Rarepops

    Unity Technologies

    Joined:
    Sep 5, 2019
    Posts:
    40
    Is it something consistent you're seeing?
     
  10. Rarepops

    Rarepops

    Unity Technologies

    Joined:
    Sep 5, 2019
    Posts:
    40
  11. ARESGOW224

    ARESGOW224

    Joined:
    Oct 27, 2019
    Posts:
    3
    Yes. Every time it takes about 9 minutes. What do you think could be affecting that event?
     
  12. Baste

    Baste

    Joined:
    Jan 24, 2013
    Posts:
    5,578
    Seems like you either have some very complicated prefab hierarchies, or there's something very bad in the prefab code.
     
  13. ARESGOW224

    ARESGOW224

    Joined:
    Oct 27, 2019
    Posts:
    3
    What would specifically make a prefab complicated? Amount of individual assets? Number of components? Because I do have moving platforms with a dozen or so additional assets attatched. Or perhaps the static flags? I just noticed almost all my static objects are flagged for every static selection. Occluder static, lightmap static, batch static etc...
     
    Last edited: Jun 14, 2021
  14. Baste

    Baste

    Joined:
    Jan 24, 2013
    Posts:
    5,578
    I don't know, but I assume prefab variants with a lot of overrides?

    Definitely sounds like you ought to send a bug report with the project attached, sounds like there's room for improvements that can help everyone.
     
    Rarepops likes this.
  15. AlienFreak

    AlienFreak

    Joined:
    Jul 2, 2012
    Posts:
    28
    Can someone update this to work with Unity 2021? Nothing prints in the window except errors, the JSON export can't be read by Chrome Tracing and the HTML is the only functional way of getting at the profile data but it's pretty painful to use.
     
  16. Rarepops

    Rarepops

    Unity Technologies

    Joined:
    Sep 5, 2019
    Posts:
    40
    Thanks for letting us know! I will take a look at it if time permits (pretty starved for bandwidth lately), right now it isn't maintained and hasn't been for over a year. The plan is to eventually have some better tool to replace this anyway.

    If you feel adventurous, you could attempt fixing the issues, I will review and accept Pull Requests :)
     
    Last edited: Aug 31, 2021
  17. ZenTeapot

    ZenTeapot

    Joined:
    Oct 19, 2014
    Posts:
    31
    unity 2020.3.16f
    after a simple code change, with deep profile on, the profier seems unable to report assembly reload related stats, with this error in the console

    ArgumentException: Could not find thread named 'Domain unloader'
    UnityEditor.EditorIterationProfiler.UnityProfiling.GetFrame (System.Int32 frameIndex, System.String threadName) (at Library/PackageCache/com.unity.editoriterationprofiler@e05c43da15/Editor/UnityProfiling.cs:86)
    UnityEditor.EditorIterationProfiler.ProfilerDataCollector.ReadProfilingData (UnityEditor.EditorIterationProfiler.IterationEventRoot iterationEventRoot, UnityEditor.EditorIterationProfiler.EventData parentEventData, UnityEditor.Profiling.HierarchyFrameDataView frameData, System.Int32 sampleId, UnityEditor.EditorIterationProfiler.EventDataFlags flags, System.Boolean parentHasSingleChild) (at Library/PackageCache/com.unity.editoriterationprofiler@e05c43da15/Editor/ProfilerDataCollector.cs:278)
    UnityEditor.EditorIterationProfiler.ProfilerDataCollector.ReadProfilingData (UnityEditor.EditorIterationProfiler.IterationEventRoot iterationEventRoot, UnityEditor.EditorIterationProfiler.EventData parentEventData, UnityEditor.Profiling.HierarchyFrameDataView frameData, System.Int32 sampleId, UnityEditor.EditorIterationProfiler.EventDataFlags flags, System.Boolean parentHasSingleChild) (at Library/PackageCache/com.unity.editoriterationprofiler@e05c43da15/Editor/ProfilerDataCollector.cs:298)
    UnityEditor.EditorIterationProfiler.ProfilerDataCollector.ReadProfilingData (UnityEditor.EditorIterationProfiler.IterationEventRoot iterationEventRoot, UnityEditor.EditorIterationProfiler.EventData parentEventData, UnityEditor.Profiling.HierarchyFrameDataView frameData, System.Int32 sampleId, UnityEditor.EditorIterationProfiler.EventDataFlags flags, System.Boolean parentHasSingleChild) (at Library/PackageCache/com.unity.editoriterationprofiler@e05c43da15/Editor/ProfilerDataCollector.cs:298)
    UnityEditor.EditorIterationProfiler.ProfilerDataCollector.ReadProfilingData (UnityEditor.EditorIterationProfiler.IterationEventRoot iterationEventRoot, UnityEditor.EditorIterationProfiler.EventData parentEventData, UnityEditor.Profiling.HierarchyFrameDataView frameData, System.Int32 sampleId, UnityEditor.EditorIterationProfiler.EventDataFlags flags, System.Boolean parentHasSingleChild) (at Library/PackageCache/com.unity.editoriterationprofiler@e05c43da15/Editor/ProfilerDataCollector.cs:298)
    UnityEditor.EditorIterationProfiler.ProfilerDataCollector.ReadProfilingData (UnityEditor.EditorIterationProfiler.IterationEventRoot iterationEventRoot, UnityEditor.EditorIterationProfiler.EventData parentEventData, UnityEditor.Profiling.HierarchyFrameDataView frameData, System.Int32 sampleId, UnityEditor.EditorIterationProfiler.EventDataFlags flags, System.Boolean parentHasSingleChild) (at Library/PackageCache/com.unity.editoriterationprofiler@e05c43da15/Editor/ProfilerDataCollector.cs:298)
    UnityEditor.EditorIterationProfiler.ProfilerDataCollector.ReadProfilingData (UnityEditor.EditorIterationProfiler.IterationEventRoot iterationEventRoot, UnityEditor.EditorIterationProfiler.EventData parentEventData, UnityEditor.Profiling.HierarchyFrameDataView frameData, System.Int32 sampleId, UnityEditor.EditorIterationProfiler.EventDataFlags flags, System.Boolean parentHasSingleChild) (at Library/PackageCache/com.unity.editoriterationprofiler@e05c43da15/Editor/ProfilerDataCollector.cs:298)
    UnityEditor.EditorIterationProfiler.ProfilerDataCollector.ReadProfilingData (UnityEditor.EditorIterationProfiler.IterationEventRoot iterationEventRoot, UnityEditor.EditorIterationProfiler.EventData parentEventData, UnityEditor.Profiling.HierarchyFrameDataView frameData, System.Int32 sampleId, UnityEditor.EditorIterationProfiler.EventDataFlags flags, System.Boolean parentHasSingleChild) (at Library/PackageCache/com.unity.editoriterationprofiler@e05c43da15/Editor/ProfilerDataCollector.cs:298)
    UnityEditor.EditorIterationProfiler.ProfilerDataCollector.ReadProfilingData (UnityEditor.EditorIterationProfiler.IterationEventRoot iterationEventRoot, UnityEditor.EditorIterationProfiler.EventData parentEventData, UnityEditor.Profiling.HierarchyFrameDataView frameData, System.Int32 sampleId, UnityEditor.EditorIterationProfiler.EventDataFlags flags, System.Boolean parentHasSingleChild) (at Library/PackageCache/com.unity.editoriterationprofiler@e05c43da15/Editor/ProfilerDataCollector.cs:298)
    UnityEditor.EditorIterationProfiler.ProfilerDataCollector.ReadProfilingData (UnityEditor.EditorIterationProfiler.IterationEventRoot iterationEventRoot, UnityEditor.EditorIterationProfiler.EventData parentEventData, UnityEditor.Profiling.HierarchyFrameDataView frameData, System.Int32 sampleId, UnityEditor.EditorIterationProfiler.EventDataFlags flags, System.Boolean parentHasSingleChild) (at Library/PackageCache/com.unity.editoriterationprofiler@e05c43da15/Editor/ProfilerDataCollector.cs:298)
    UnityEditor.EditorIterationProfiler.ProfilerDataCollector.ReadProfilingData (UnityEditor.EditorIterationProfiler.IterationEventRoot iterationEventRoot, UnityEditor.EditorIterationProfiler.EventData parentEventData, UnityEditor.Profiling.HierarchyFrameDataView frameData, System.Int32 sampleId, UnityEditor.EditorIterationProfiler.EventDataFlags flags, System.Boolean parentHasSingleChild) (at Library/PackageCache/com.unity.editoriterationprofiler@e05c43da15/Editor/ProfilerDataCollector.cs:298)
    UnityEditor.EditorIterationProfiler.ProfilerDataCollector.ProfilerNewFrame (System.Int32 connectionId, System.Int32 newFrameIndex) (at Library/PackageCache/com.unity.editoriterationprofiler@e05c43da15/Editor/ProfilerDataCollector.cs:220)
    UnityEditorInternal.ProfilerDriver.InvokeNewProfilerFrameRecorded (System.Int32 connectionId, System.Int32 newFrameIndex) (at /Users/bokken/buildslave/unity/build/Modules/ProfilerEditor/Public/ProfilerAPI.bindings.cs:308)
     
  18. ZenTeapot

    ZenTeapot

    Joined:
    Oct 19, 2014
    Posts:
    31
    Changing "unloader" to "Unloader" appears to fix the issue.
     
    Rarepops likes this.
  19. Rarepops

    Rarepops

    Unity Technologies

    Joined:
    Sep 5, 2019
    Posts:
    40
    mariandev likes this.
unityunity