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
  2. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  3. Unity support for visionOS is now available. Learn more in our blog post.
    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:
    3,132
    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:
    333
    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
    wlwl2 likes this.
  3. aganm

    aganm

    Joined:
    Sep 25, 2019
    Posts:
    114
    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.
     
    wlwl2 likes this.
  4. darthdeus

    darthdeus

    Joined:
    Oct 13, 2013
    Posts:
    76
    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.
     
    NotaNaN, andreiagmu, dudleyhk and 4 others like this.
  5. dev_2051

    dev_2051

    Joined:
    Jul 25, 2013
    Posts:
    92
    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:
    333
    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:
    3,132
    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:
    302
    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:
    333
    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:
    147
    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:
    3,132
    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:
    333
    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:
    26
    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:
    76
    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:
    6,294

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

    darthdeus

    Joined:
    Oct 13, 2013
    Posts:
    76
    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:
    3,132
    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:
    3,132
    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.
     
  19. nasos_333

    nasos_333

    Joined:
    Feb 13, 2013
    Posts:
    13,288
    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:
    3,132
    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:
    13,288
    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 valarnur like this.
  22. TextusGames

    TextusGames

    Joined:
    Dec 8, 2016
    Posts:
    429
    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.
  23. aganm

    aganm

    Joined:
    Sep 25, 2019
    Posts:
    114
    I still have this issue.

    When I do a script change, this is what happens:



    I tried every thing proposed here and in the new blog post. The only thing that has worked for me is reverting to Unity 2018. In Unity 2018, a script change takes about 500ms to refresh if not less (in a 5gb project). Compared to almost 15 seconds in newer unity versions for an even smaller project.
     
    Last edited: Nov 20, 2020
  24. Baste

    Baste

    Joined:
    Jan 24, 2013
    Posts:
    6,294
    The editor iteration profiler seems to not find or show AssetImport or AssemblyReload data when it's not in deep profiling. You're compiling the code, there should be at least 1 assembly that reloads, and at least 1 asset (the script) that imports.

    @LeonhardP we're seeing similar things - though just 4-6 seconds total, not 10. But I fear it'll grow. Do you think it's viable to send the project as a bug report and have it looked at?
     
    wlwl2 likes this.
  25. bluescrn

    bluescrn

    Joined:
    Feb 25, 2013
    Posts:
    642
    I guess I've just got used to slow script recompiles (I used to work with C++, so it's still fairly quick in comparison), but I found this threat after getting extremely frustrated at a 30sec+ AssetDatabase.Refresh wait for every small edit to a trivial shader, something that used to be effectively instant.

    Is this normal now? Or have I got a plugin doing something bad?

    (edit: Eventually solved by deleting \library and reimporting the entire project)
     
    Last edited: Feb 26, 2021
  26. nasos_333

    nasos_333

    Joined:
    Feb 13, 2013
    Posts:
    13,288
    Unity is broken now i think, they did some parallelization it seems which is now default, but not working fast and can be extremely slower. With no option to turn off in latest versions i think.
     
    Last edited: Feb 26, 2021
  27. aganm

    aganm

    Joined:
    Sep 25, 2019
    Posts:
    114
    Indeed. Right now, it's either endure the painfully slow compile times, or revert to 2018.
     
  28. nasos_333

    nasos_333

    Joined:
    Feb 13, 2013
    Posts:
    13,288
    Unity, if see this, please give us option to use single thread for the compilation, this is the only solution, as the parallelized code is not working in general case, maybe working in some specific tests on your side, but not for everyone and can be exponentially slower, which is the main issue.

    Is not just a little slower, is minutes comparing to seconds slower.
     
  29. Murad009

    Murad009

    Joined:
    Apr 2, 2021
    Posts:
    1
    i did so much things as i remember i downloaded and instelled the "Windows6.1-KB3063858-x64", and for dornet... i downloaded "dotnet-sdk-5.0.202-win-x64" but nothing changed but i think after i downloded this "windowsdesktop-runtime-5.0.5-win-x64" also nothing "LOL". actually v5.0.5 of dotnet was not well instelled on my desktop, until i moved two files of paths; 1- "5.0.5" = C:\Program Files\dotnet\templates\5.0.5, 2-"5.0.202" = C:\Program Files\dotnet\sdk, to the path of "C:\Windows\Microsoft.NET\Framework". i hope your issue get solved best regards
     
  30. nasos_333

    nasos_333

    Joined:
    Feb 13, 2013
    Posts:
    13,288
    Hi,

    So that solved the issue and compilation became faster ?
     
  31. The_Dark_Swordsman

    The_Dark_Swordsman

    Joined:
    May 16, 2020
    Posts:
    6
    I know this is an old thread, but I figured I'd just post here since it was #1 on my search result.

    All I can say is that I have 2 C# scripts in a project that just has materials and assets, nothing else. I do have a lot of packages, but they are necessary in one form or another, and generally aren't doing anything. This is more specifically with the VRChat SDK so I can create content with 2019.4.

    Anytime I save a C# script, it takes 20+ seconds to compile. It is mind boggling that this is even a thing. 1 or 2 seconds? Sure. But 20+ seconds?

    It doesn't help either that I'm relatively new to the Unity APIs and, so far, compared to my experience working with JavaScript libraries and APIs, Unity's API is unnecessarily complicated, and even the intellisense is unhelpful, if not actively working against my ability to write code quickly and smoothly.