Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Question Is there a way to prevent recompiling packages repeatedly?

Discussion in 'Package Manager' started by CPlusSharp22, Jul 27, 2020.

  1. CPlusSharp22

    CPlusSharp22

    Joined:
    Dec 1, 2012
    Posts:
    111
    In this thread [https://forum.unity.com/threads/2019-3-slow-build-times.929508/#post-6083562] I'm looking at long script compile times in my project. To summarize, the top libs are:

    Something like Unity.Mathematics I don't want to recompile every time I make a script change in my project, especially for unrelated code. If I add a line of debug logging, and do a script only compile, I have to wait roughly 7 seconds for Unity.Mathematics to compile despite no changes being made to it.

    I know caching different combinations of binaries can be complicated, but I was thinking of making my own system if this isn't supported by Unity directly. I rather not waste time if it exists though!
     
    MNNoxMortem and ImpossibleRobert like this.
  2. CPlusSharp22

    CPlusSharp22

    Joined:
    Dec 1, 2012
    Posts:
    111
  3. CPlusSharp22

    CPlusSharp22

    Joined:
    Dec 1, 2012
    Posts:
    111
  4. CPlusSharp22

    CPlusSharp22

    Joined:
    Dec 1, 2012
    Posts:
    111
  5. Shaunyowns

    Shaunyowns

    Joined:
    Nov 4, 2019
    Posts:
    328
    CPlusSharp22 likes this.
  6. CPlusSharp22

    CPlusSharp22

    Joined:
    Dec 1, 2012
    Posts:
    111
    Awesome, thank you so much! :)
     
  7. Shaunyowns

    Shaunyowns

    Joined:
    Nov 4, 2019
    Posts:
    328
    Hey there, have you checked out - https://docs.unity3d.com/Manual/ScriptCompilationAssemblyDefinitionFiles.html?

    Specifically: "Without Assembly Definitions, Unity compiles any C# scripts in your Project into one of the predefined, managed assemblies. Unity must then recompile every script in the entire Project when you change any script. This means that the length of time between making a code change and seeing that change in action grows longer as you add more scripts to the Project."

    Hopefully this helps!
     
  8. CPlusSharp22

    CPlusSharp22

    Joined:
    Dec 1, 2012
    Posts:
    111
    As my original post indicates, each one of those listed has their own assembly definition or else they would show up as only Assembly-CSharp.dll. @Shaunyowns

    Unity.Mathematics is unity's own official lib. And it has its own asmdef file. As do all the other packages in the list. So the link doesn't help unfortunately.
     
  9. CPlusSharp22

    CPlusSharp22

    Joined:
    Dec 1, 2012
    Posts:
    111
  10. Neto_Kokku

    Neto_Kokku

    Joined:
    Feb 15, 2018
    Posts:
    1,751
    With more and more of Unity moving to packages, seems we'll soon have to re-compile the entire engine every time we change a single line in a script.
     
    tonytopper and CPlusSharp22 like this.
  11. CPlusSharp22

    CPlusSharp22

    Joined:
    Dec 1, 2012
    Posts:
    111
    MNNoxMortem likes this.
  12. MNNoxMortem

    MNNoxMortem

    Joined:
    Sep 11, 2016
    Posts:
    723
    @Shaunyowns Unity does recompile stuff that it should never recompile more than once. As long as I have a package referenced, compiled and none of it's dependency changes there is zero reason to recompile it (edit: okay, there are situations you have to, e.g. change of defines, platform, ...) . However, Unity does it definetly in scenarios where nothing has changed that will affect this binary. This also is the case since .asmdef was introduced and I never saw it working correctly. In the beginning it sometimes recompiled the same asmdef multiple times in a row (because it was referenced multiple times -.-), nowadays there seem to be less triggers to cause it to recompile multiple times but it happens and it is a known issue and reported here.

    Edit: Just to prove what I am stating here. This pastebin shows my recompilation times. I run into those with every single update. Guess how many dlls I actually change each update - 1 up to 2, as all I am doing is updating "leave" assemblies. For sure I am not updating "Havok.Physics" or any dependency of it. A process that takes me seconds to minutes outside of unity does take me hours within unity. It is ridiculous. On top of that it does a AssetDatabase.Refresh which also takes some time, and I am sure there are other things I am waiting for but do not even watch out for anymore. And this is a tiny project.
     
    Last edited: Aug 18, 2020
    CPlusSharp22 likes this.
  13. Shaunyowns

    Shaunyowns

    Joined:
    Nov 4, 2019
    Posts:
    328
    MNNoxMortem likes this.
  14. T-Cube

    T-Cube

    Joined:
    Apr 3, 2021
    Posts:
    1
    Uh, it still ain't done
    Never will be ig
     
  15. kojagiri

    kojagiri

    Joined:
    Aug 9, 2022
    Posts:
    8
    Still suffering insufferable re-compile times and repeat compilation on every little event. Since we're close end-2022 is there a workaround at least?
     
  16. KingLlama

    KingLlama

    Joined:
    Jul 18, 2015
    Posts:
    199
    cheesepant likes this.
  17. kojagiri

    kojagiri

    Joined:
    Aug 9, 2022
    Posts:
    8
    No I think they gave up on this lol