Search Unity

  1. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice
  2. Enter the 2020.2 Beta Sweepstakes for a chance to win an Oculus Quest 2.
    Dismiss Notice

Feedback (Case 1161371) Compiling empty project takes significantly longer

Discussion in '2019.3 Beta' started by Peter77, Jun 9, 2019.

  1. LeonhardP

    LeonhardP

    Unity Technologies

    Joined:
    Jul 4, 2016
    Posts:
    2,254
    The investigation of this report revealed a performance regression during domain reload related to the package manager window being open (floating or attached). Could you please try and see if the situation for you improves when the packman window is not loaded?
     
  2. SamOld

    SamOld

    Joined:
    Aug 17, 2018
    Posts:
    224
    I'm not the original poster but I can definitely say that the slow reloads that I experience are not dependent on the package manager being open, although I think that I may have experienced that additional slowdown too.
     
    Last edited: Sep 20, 2020
  3. aganm

    aganm

    Joined:
    Sep 25, 2019
    Posts:
    34
    It doesn't seem to be my issue. I have the package manager open and the time it takes to recompile 1 line change is still 5-10 seconds. This is with a blank new test project.
     
  4. darthdeus

    darthdeus

    Joined:
    Oct 13, 2013
    Posts:
    47
    I can definitely confirm that this issue is unrelated to the Package Manager window being open. It's just as slow when the window is not open as when it is. I'm really confused how reproducing this can be anything but trivial considering the huge number of people experiencing this, the amount of forum posts, and the number of votes on the issue.

    I don't mean to sound rude, but I often wonder if people at Unity actually use Unity to develop non-trivial things? There's even the "editor iteration profiler" from Unity (https://github.com/Unity-Technologies/com.unity.editoriterationprofiler) that can clearly show how time is being spent on asset reloads. In my case it takes roughly 1.2s to compile the Assembly-CSharp.dll and Assembly-CSharp-Editor.dll, and then about 20 seconds for the asset database reload - on a single line of code change. Everyone else here on the forums and in the issue seem to experience the same thing.

    But really I'm not sure what more we can do to help here. If you guys are still having trouble reproducing it, I'm more than happy to submit another bug report, but just to note, I'm the one who reported the issue (1270910) initially, and was told by the support (after some back and forth emailing) that they managed to reproduce the problem. Which is why it find weird you would now find it gets solved when the package manager window is closed, because using the same project I sent with the bug report, I still experience the issue even with the package manager window closed.

    One thing I don't understand is why is the whole asset database being refreshed on a single line of code change? I even have placed all of my assets under Plugins/, and am changing a single script outside the Plugins/ folder, but it still triggers the full reload.
     
    andreiagmu, DDaqes, jdtec and 3 others like this.
  5. dev_2051

    dev_2051

    Joined:
    Jul 25, 2013
    Posts:
    91
    In my case issue is there even with package manager window closed. So the main probable cause for this seems to be ADB V2, even 2019.3.X is faster as compared to 2019.4.X LTS with 2018.4.X LTS the fastest among all versions.

    Please resolve this issue as it's becoming really frustrating on daily usage basis with 2019.4.X LTS taking ~1min of time for each compilation and sometimes more than 2 mins of time to enter into playmode with editor in frozen state during this time.( Can't rollback as some of the asset plugins are using packages from 2019.4.X version)
     
  6. SamOld

    SamOld

    Joined:
    Aug 17, 2018
    Posts:
    224
    ADB V2 definitely made it a lot slower for me, but it was already slow with V1. I get the sense that there may be a number of compounding issues at fault here.
     
    aganm likes this.
  7. LeonhardP

    LeonhardP

    Unity Technologies

    Joined:
    Jul 4, 2016
    Posts:
    2,254
    I'm sorry for the confusion. I didn't mean to imply that the package manager window being open is the cause for the performance problems that you're experiencing. It's just one of the things that came up during the investigation so far and I wanted to gauge how many users in this thread were affected by it. We're still very much actively looking into other contributing factors.
     
  8. jdtec

    jdtec

    Joined:
    Oct 25, 2017
    Posts:
    184
    There probably is multiple things going on here. When I upgraded to 2019.3 and asset v2 my script compile time alone went to about ~10 seconds when inspected in the profiler (~13 seconds to enter playmode in total), whereas previously the entire time to enter playmode from a script change was around ~6-7 seconds.

    Hoping potential DOTs related compile time improvements mentioned in another thread might improve this in the future.
     
  9. SamOld

    SamOld

    Joined:
    Aug 17, 2018
    Posts:
    224
    I believe that I am, but this is completely unscientific. The reload times vary quite significantly - seemingly at random - so it's hard to be sure of the impact of individual factors for signal / noise reasons. However, at some point I developed a suspicion that the package manager being open was making things worse and began habitually closing it instead of leaving it as a tab.

    Again I don't have reliable data for this, but I believe that the use of assembly definitions may actually make things worse too.
     
  10. firstuser

    firstuser

    Joined:
    May 5, 2016
    Posts:
    53
    For me the bottleneck is currently ADB v2 on Mac (idk if it's better with directory watching feature that is windows only right now), compile time went down significantly after using asmdef and 95% of the time is spent waiting for ADB and related. Package Manger window seems to make no impact.
     
  11. LeonhardP

    LeonhardP

    Unity Technologies

    Joined:
    Jul 4, 2016
    Posts:
    2,254
    Hi everybody,

    Some updates:

    1. The package manager UI regression that I mentioned earlier is specifically related to gradually worsening script compilation / domain reload times. If your compile times are normal when you start the Editor but then get worse over time, it could be because of this bug.

      To check whether you are affected by this regression you will have to turn off the package manager window (remove it from your Editor UI layout) and then restart the Editor. Just turning the packman window off is not going to improve domain reload times on its own.

      We currently have a potential fix for this issue in review.

    2. @darthdeus we were able to narrow the cause of the domain reload regression that you're experiencing down to Console Pro. If there's lots of visible entries in Console Pro we have a degradation of domain reload time. Collapsing the entries resulted in bringing domain reload time back to ~2.7 seconds from ~23 seconds. Could you please check if collapsing the entries (or disabling the asset) improves the situation for you?

    To everyone else suffering from long domain reload times, please check if the above cases apply to you. If not, please submit bug reports with reproducibles attached to us so we can investigate your cases.
     
  12. SamOld

    SamOld

    Joined:
    Aug 17, 2018
    Posts:
    224
    I'm sceptical that this is what I was seeing, but I'll have to go back to do some tests to confirm. I don't remember specifically, so it's possible that I was always starting the editor with the package manager open then quickly closing it, so the package manager might be responsible for everything that I experienced.

    Does this issue that you found cause enough slow down to explain the 10 seconds to 1 minute times that people have been talking about here? How long would you expect the editor to have to be open to get to those kinds of performance drops? If it's 10 minutes then this is plausibly what I was seeing, but if it's 10 hours then it's definitely not!

    I definitely tried restarting the editor as a fix when this was bothering me, and concluded that that didn't help.

    What is the event that causes it to get slower? Does it slow down each second, each editor update, each domain reload, or something else? I would often leave the editor open in the background without using it - would you expect it to be continuing to slow down when not being used? What was the shape of the slow down - linear, exponential, etc?

    Please update in this thread when the potential fix is available somewhere so that we can all try it out ASAP!
     
  13. MartinBarrette

    MartinBarrette

    Unity Technologies

    Joined:
    Oct 22, 2019
    Posts:
    18
    The slowdown was over each domain reload, not only the Package Manager was causing this degradation, but it was the one with more impact in the projects which were submitted for our testing. The slowdown observed is linear in this case.

    The other use case of Console Pro was a lot more drastic.
    If you have other projects, configs which are displaying a slowdown please do report them so that we can investigate.
    Thank you!
     
    LeonhardP and SamOld like this.
  14. darthdeus

    darthdeus

    Joined:
    Oct 13, 2013
    Posts:
    47
    Thanks for the prompt reply, I tried removing Console Pro and restarting Unity without the Package Manager window open and there is indeed a noticeable difference. Now it seems roughly around 5-6s for a one line code change quite consistently.

    I've tried measuring repeatedly this on two different desktops with a bit different hardware (Ryzen 9 3900X 64GB RAM and i7 7700K 32GB RAM) and they have basically the exact same reload time (I guess this isn't super useful information, but maybe noteworthy).

    Overall I want to thank you for finding this, the improvement is definitely good and it brings Unity from unbearably slow to "slightly annoying but ok I guess" :) Though I still want to say that it seems that this is still worse than a couple of versions ago, since I don't remember ever having to wait for the editor, and while 6 seconds is good, it doesn't go unnoticed. But I guess this falls more into the original post by Peter77 in this thread, since that slowdown is not so drastic as the one caused by the Console Pro & Package Manager combination.

    To be completely honest I was a bit reluctant to reply to this acknowledging this improvement because I'm a bit worried that now that "my problem is fixed" the issue will just get closed, and all the other 78 people voting on the issue might not get any resolution.

    I'd also like to ask if the way you figured out it was caused by Console Pro is something we as users can reproduce ourselves, and if there are any additional diagnostic tools or techniques you could recommend? Or was it more of a case of just trying to remove things and seeing what works?

    edit: For the other people in this thread having this issue, are you also using Console Pro? It might be interesting to have a community maintained list of assets which cause major editor slowdowns.
     
  15. Baste

    Baste

    Joined:
    Jan 24, 2013
    Posts:
    5,099

    Have you tried the Editor iteration profiler? It's made for exactly this.
     
  16. darthdeus

    darthdeus

    Joined:
    Oct 13, 2013
    Posts:
    47
    I actually tried it before, but it didn't point me to Console Pro. It did help me think a bit about what might be taking time during reloads, but nothing really stood up. The reload time before was way over 20 seconds, but nothing really stood up in the profiler.

    Just testing it now, it's showing 16seconds for a script compilation, but unless I'm missing something it doesn't point to anything specific. I might be missing something, but with and without deep profile it doesn't point to a specific thing.

    upload_2020-9-24_11-14-1.png

    It also sometimes just shows ~600ms not showing anything (see second screenshot), despite the "Refreshing" modal still being up for at least a few seconds

    upload_2020-9-24_11-21-35.png
     
  17. LeonhardP

    LeonhardP

    Unity Technologies

    Joined:
    Jul 4, 2016
    Posts:
    2,254
    We're currently re-evaluating all submitted bug reports that were previously classified as duplicates of your case. We will update 1270910 with references to other similar issues we discover.

    Besides Console Pro, Odin Inspector is another asset that can trigger a degradation of domain reload times and slow domain load times. We've contacted the developers and reported an issue that we discovered. Besides the one we told them about yesterday, which can cause degradation, they're aware of other ones as well, mostly causing slow domain load times. Those are already fixed in their current 3.0 beta.

    If you're using Odin Inspector and are experiencing slow or degraded domain reload times, it might be worth a try to check out version 3.0 if possible.

    One of the primary triggers for degraded domain reload times are ScriptableObjects which are created on load, typically in the static constructor of a class with the [InitializeOnLoad] attribute or a method with [InitializeOnLoad] attribute. What is happening: ScriptableObject instances get restored and [InitializeOnLoad] gets called again causing an extra instance to be created and initialized.

    In 2020.1 and up one way to address this is to make the ScriptableObject a ScriptableSingleton. If you do not need this object to be a ScriptableObject another alternative is to use a plain old C# object.

    Be mindful of the initialization of those objects created on load as it will impact your domain reload times.
     
  18. LeonhardP

    LeonhardP

    Unity Technologies

    Joined:
    Jul 4, 2016
    Posts:
    2,254
    We've shared a blog post and started a dedicated thread to increase awareness of the primary causes for slow asset refreshes. We will use the thread to share additional known issues as they come to light and keep you updated about our progress on resolving related issues on our end.
     
    firstuser, jdtec and Peter77 like this.
  19. nasos_333

    nasos_333

    Joined:
    Feb 13, 2013
    Posts:
    8,656
    Hi,

    I have an issue with URP project, i have multiple shaders and scripts and after a while the project started to go very slow when I do any changes to any shader, it takes around 1.5 minutes for each little change, making it impossible to work with fast iterations after my changes, is this something similar to this issue ?

    Thanks
     
  20. LeonhardP

    LeonhardP

    Unity Technologies

    Joined:
    Jul 4, 2016
    Posts:
    2,254
    Yes, sounds related. Did you have a look at the list of known issues that we gathered here yet? If you think your scenario is not related to those problems, please submit a bug report with a reproduction project so we can investigate.
     
    nasos_333 likes this.
  21. nasos_333

    nasos_333

    Joined:
    Feb 13, 2013
    Posts:
    8,656
    Hi,

    I found the solution, posting it here for anyone that may have the same issue.

    The compilation time after changing the code in a shader was reduced from 1.5 minute to less than 2 seconds !! The difference means that something is bugged in the Async method i guess.

    I disabled the following option:
    Project Settings - Editor - Shader Compilation - Asyncronous Shader Compilation

    Also one source about slow build times i found while looking for a solution, also may be useful
    https://www.reddit.com/r/Unity3D/comments/brmu70/psa_are_your_builds_taking_hours_and_sitting_on/
     
    TextusGames, firstuser and valarus like this.
  22. TextusGames

    TextusGames

    Joined:
    Dec 8, 2016
    Posts:
    382
    This remembered me the bug with addressable system. Where if you load something asynchronously it takes much more time in comparison to synchronous loading.

    https://forum.unity.com/threads/iss...ime-in-android-1000-assets-17-seconds.757151/
     
    nasos_333 likes this.
unityunity