Search Unity

  1. Unity 2019.1 is now released.
    Dismiss Notice

Profiler in Editor File.Read taking up a huge amount of CPU

Discussion in 'Editor & General Support' started by GarrettVorhies, Apr 26, 2019.

  1. GarrettVorhies

    GarrettVorhies

    Joined:
    Apr 21, 2017
    Posts:
    4
    Opening up an empty scene in 2018.3.6f1 results in DataDeserializer File.Read taking up 10-70ms a frame. I've tested this on multiple machines and all have this same problem with different projects.

    Is there a way to fix this issue? It does not appear in builds, but still makes overall performance in the editor much lower than it should be and makes profiling difficult outside of builds.

    upload_2019-4-26_12-50-3.png
     
  2. alexeyzakharov

    alexeyzakharov

    Unity Technologies

    Joined:
    Jul 2, 2014
    Posts:
    229
    Try to use "Profile Editor" to see the Editor activities which are grayed out as "Editor Loop" sample on the main thread. File.Read on profiler thread is actually waiting on semaphore for the data. In 2019.2 it is explicitly marked with "Semaphore.WaitForSignal" marker.
     
  3. MartinTilo

    MartinTilo

    Unity Technologies

    Joined:
    Aug 16, 2017
    Posts:
    189
    Hello :)

    As @alexeyzakharov said, this sample does not prolong your frame time, it just happens to last as long as the frame while it is waiting.

    What is actually taking up most of your time is the EditorLoop, which in your screenshot is collapsed into that gray sample on the main thread. This might include Editor scripts and editor extensions you're using but is likely, to a good part, spending time to Calculate stuff for the Editor including rendering the Editor's UI, including the Profiler Window (which is sadly not the most lightweight window that we have, due to the sheer number of data points. Not saying that is isn't in always in need for more optimizations)

    This is a known pain point when profiling in the Editor. Additionally, there are all kinds of things going on in the editor that mean that performance will be quite different from a build, even if it is a standalone build, and even more so when targeting a non-Desktop platform. There are some things we can and will do to improve the experience and accuracy when profiling in the Editor (and/or to keep iteration loops tight) but profiling the Editor is always just going to be an approximation.

    The best practice when trying to optimize a product made with unity is to profile a build on the target device (ideally on the low end of the targeted spectrum). Data from these Profiling sessions should be used to identify areas that should be investigated further, either directly on the device where feasible, or in the editor. For tight iterations while optimizing, profiling the editor can be helpful but the end result should always be evaluated in a build on the target device.

    That said, if you want to find out, what the Editor is spending so much time on, you can switch on "Profile Editor" to see the entire frame of the Editor with the Player running within it.
     
  4. GarrettVorhies

    GarrettVorhies

    Joined:
    Apr 21, 2017
    Posts:
    4
    Thanks for your help @alexeyzakharov and @MartinTilo! I'm familiar with the profiler not being accurate in the editor vs builds, this is just to fix major performance issues we are having using the editor. Thanks for pointing out the "Profile Editor" button, it looks like SceneTracker is what's causing the major performance drop.

    In a brand new empty project:
    UnityProfilerNewProject.PNG

    Current project in an empty scene:
    UnityProfiler.PNG

    Something in our project is clearly causing SceneTracker to go haywire and there doesn't seem to be any documentation on it to resolve this issue. Can Plugins, Packages or something else inadvertently cause this to happen?
     
  5. GarrettVorhies

    GarrettVorhies

    Joined:
    Apr 21, 2017
    Posts:
    4
    After doing a Deep Profile we've figured out that PlayServicesResolver is causing the issue.

    upload_2019-4-29_13-33-18.png

    Deleting PlayServicesResolver makes the problem go away.
     
    Last edited: Apr 29, 2019
    MartinTilo and alexeyzakharov like this.