Search Unity

  1. Unity 2020.1 has been released.
    Dismiss Notice
  2. We are looking for feedback on the experimental Unity Safe Mode which is aiming to help you resolve compilation errors faster during project startup.
    Dismiss Notice
  3. 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

Scripts compilation/import extremely slow in 2019.3.xx

Discussion in '2019.3 Beta' started by lordnedox, Jan 17, 2020.

  1. lordnedox

    lordnedox

    Joined:
    Jan 7, 2016
    Posts:
    20
    Hi,
    I hope this wasn't already addressed but I've noticed since moving to the beta that my scripts are taking forever to get compiled/imported when I move from VS back to Unity.

    Indeed I have approx. 3,000 C# files in the project, so I've tried creating a new folder, with a single C# script and an assembly definition file. It was my understanding that changing/importing this script, being in its own assembly, should have been blazing fast.

    However, it still takes more than 10-12 seconds when i change the script and move back to Unity. Sometimes the "import xxxxx.cs" popup appears, something it just hangs with no UI.

    Tried both with 2019.3.0f1 and 2019.3.0f5.

    Older versions weren't super fast either, but I think at least 50% faster than the beta.

    Any suggestions? I'd be willing to update the project with assembly definition files, but if it takes 12 seconds to compile one script with 10 lines of code in it, seems more a waste of time to me.

    Cheers
     
  2. julian-moschuering

    julian-moschuering

    Joined:
    Apr 15, 2014
    Posts:
    404
    It's probably the Domain Reload not the compilation time? When the loading circle thingy in the lower right is rotating the editor is compiling, when it's hanging the domain reload is happening which involves serializing/deserializing loaded assets, disabling/enabling ExecuteInEditMode stuff and ScriptableObjects and doing a AssetDatabase refresh.
    Some AssetDatabase stuff is still slower in 2019.3.

    You can attach the profiler, do a recompile and stop the profiler when finished. This gives you a pretty good overview what too the time and maybe you can work around it. ReloadAssembly should be a huge spike.
     
    phobos2077 likes this.
  3. lordnedox

    lordnedox

    Joined:
    Jan 7, 2016
    Posts:
    20
    I really can't profile anything, as soon as I leave from VS 2017 and go back to Unity, the Editor hangs for about 12 seconds, sometimes the "Importing ******.cs" popup appears at the beginning, sometimes it briefly appears just before functionality is restored.
    There's no circle icon, it's just completely frozen.

    Indeed it's not compile time, if I clear the Scripts cache it takes a second to rebuild it right away, it's doing some crazy gigantic refresh which is totally useless.

    Am I the only one facing this issue?
     
    phobos2077 likes this.
  4. LeonhardP

    LeonhardP

    Unity Technologies

    Joined:
    Jul 4, 2016
    Posts:
    2,116
  5. lordnedox

    lordnedox

    Joined:
    Jan 7, 2016
    Posts:
    20
    Great, thanks. I just wanted to know it's something at least being notified by someone and it wasn't just me, I will follow that thread closely.
    Unfortunately it's a 15 GB project and can't really make it available. With small projects the problem is not really noticeable.
    However it seems to me that by adding assembly definition files there's no improvement at all while importing the new scripts.
     
  6. julian-moschuering

    julian-moschuering

    Joined:
    Apr 15, 2014
    Posts:
    404
    Open the profiler, start it then do a script change and go back to the editor. After it reacts again stop the profiler. There now should be a frame taking alot of seconds.
     
  7. phobos2077

    phobos2077

    Joined:
    Feb 10, 2018
    Posts:
    219
    I really hope something will be done with domain reload. A huge part of my work day is wasted waiting for Unity to "un-hang" itself. There should be at the minimum some kind of progress bar for this process. It can take 10 seconds or more on a relatively small project (several gigs, some packages).
     
    PhoenixAdvanced likes this.
  8. lordnedox

    lordnedox

    Joined:
    Jan 7, 2016
    Posts:
    20
    I'd be OK if at least assembly definitions would solve the issue, but I've tried one assembly with one script of 5 lines of code, and when I change it it takes the same time as any other assembly change (10-15 seconds).
    It's quite depressing, but let's hope something will come up soon :)
     
  9. Lorash

    Lorash

    Joined:
    May 6, 2019
    Posts:
    215
    Profile file sent, changed one line of C# in an asmdef'd setup, with a trivial scene of one biped and a bunch of cubes. Case 1213483.
     
    phobos2077, kryzodoze and Peter77 like this.
  10. devilhunterxl

    devilhunterxl

    Joined:
    Dec 19, 2018
    Posts:
    6
    Any progress on this story?
     
  11. sdb7

    sdb7

    Joined:
    Apr 8, 2013
    Posts:
    10
    second this..i have 2-5 second lag when return from visual studio..its just small project with dots package, hybrid renderer. my system is quad core i7 1.6Ghz, DDR3 12GB memory, external gpu with GT710 1GB DDR5
     
unityunity