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

Unity Incremental C# Compiler - deprecated

Discussion in 'Entity Component System' started by Dom_Laflamme, Mar 28, 2018.

Thread Status:
Not open for further replies.
  1. ibyte

    ibyte

    Joined:
    Aug 14, 2009
    Posts:
    1,047
    Yeah I agree - these types of issues can eat up a lot of time - when it's got nothing to do with your core mission. Livin on the edge :D
     
    cxode likes this.
  2. cxode

    cxode

    Joined:
    Jun 7, 2017
    Posts:
    268
    I'd like to state that I have no problems using the incremental compiler to build for non-windows platforms. I've tested mac, linux, and webGL, which is notable since web was causing issues for you, @ibyte.
     
  3. ibyte

    ibyte

    Joined:
    Aug 14, 2009
    Posts:
    1,047
    @JimmyCushnie It is really odd then that I could build for windows without the error and you could not but you could build for Web and I could not. Mystifying ... I will also try the project in 2019.1a
     
  4. Vagabond_

    Vagabond_

    Joined:
    Aug 26, 2014
    Posts:
    1,148
    Hi, i tried a few time the incremental compiler - in different versions of Unity and a few preview versions of the compiler...

    Without it i am getting currently around 18-19 seconds to compile scripts when i make a simple change to any of if.
    I am getting however the same compilation time with the incremental compiler installed.

    I went through suggested steps - remove "ScriptAssemblies" folder and "Rebuild all" from the compiler settings

    upload_2018-11-12_8-27-22.png

    When i should see improvements in compilation time, and is it enough to only install the incremental compiler !?

    I am using Unity 2018.3b9 and Incremental compiler preview 0.0.42-preview.24 and have scripting runtime set like this


    upload_2018-11-12_8-24-55.png
     
  5. cxode

    cxode

    Joined:
    Jun 7, 2017
    Posts:
    268
    @Vagabond_ to get a performance boost with the incremental compiler you have to use assembly definition files. Without those, the only benefit of the compiler is C# 7 features.
     
  6. Vagabond_

    Vagabond_

    Joined:
    Aug 26, 2014
    Posts:
    1,148
    Hi, thanks, but are you sure they are actually needed !?
    Aren't these definitions actually for manual defining and managing assemblies ( which in general could speed compiling and does not need an incremental compiler ) ?
     
  7. filod

    filod

    Joined:
    Oct 3, 2015
    Posts:
    223
    Does anyone knows how to remove Incremental Compiler ?

    Remove it from package manager ui / manifest.json is not working.
    I even tried to delete whole `Library` folder and `*.csproj` files, still can't remove it.

    upload_2018-11-13_14-27-1.png


    FYI

    the reason why i want to remove Incremental Compiler is that, it brings no improvement but only more compile warnings to my project (like warnings from HDRP which should not pop up). And the key bottleneck of unity is Assembly Reload time (always about 10s even i simply call
    UnityEditorInternal.InternalEditorUtility.RequestScriptReload()
    ), i tested unity reload time in a empty project (no packages even package manager), it's about 1 second editor freezing time, far away from 500ms goal, really a shame.
    I digged unity reload behavior with process monitor, finds out unity will read/write all my package files/folders, this might be the true reload time killer.

    Now the only thing i just want to do is removing Incremental Compiler, but it haunts me like a ghost...
     
    Last edited: Nov 13, 2018
  8. UlyssesWu

    UlyssesWu

    Joined:
    Aug 28, 2017
    Posts:
    2
    Same here... I can open the project, but it's just so slow...

    Usually it costs at least 5 minutes to open the editor... and I decide to switch back to 0.0.42-preview.21.
    (Unity 2018.2.14f1)
     
    Last edited: Nov 14, 2018
  9. Deleted User

    Deleted User

    Guest

    Same here. Switching back to 0.0.42-preview.21 solves all of these problems.
     
    UlyssesWu likes this.
  10. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    It's likely you have other packages that require it to function, so no, you can't unless you remove those too.
     
  11. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    Getting this spam from the latest incremental compiler, disabling code analysis in prefs seems to fix it :p
     
    ibyte likes this.
  12. Ziplock9000

    Ziplock9000

    Joined:
    Jan 26, 2016
    Posts:
    360
    I'd like to know this too. I'm getting a 9 second compile time just by adding a new line to a fairly short script. 2018.3b9
     
    Last edited: Nov 15, 2018
  13. filod

    filod

    Joined:
    Oct 3, 2015
    Posts:
    223
    thx, this is helpful ! but i think this situation deserve a warning/error msg when you try to remove a package. (maybe not related to this thread)
     
  14. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    There is in 2019.1 (it has a feature in package manager that shows dependencies) but I can't find it in 2018.3. I must be going daft.
     
  15. 5argon

    5argon

    Joined:
    Jun 10, 2013
    Posts:
    1,555
  16. dgoyette

    dgoyette

    Joined:
    Jul 1, 2016
    Posts:
    4,193
    But how do you get around the performance degradation of merely having assembly definitions in your project? I've been asking about this for a while, but never seen a good response. (It's actually on the previous page in this thread.) Each additional ASMDEF causes an apparently linear slowdown in performing common operations in the Unity editor.

    So, it seems that with respect to the incremental compiler, I have two choices:
    • Use no ASMDEFs, and not really leverage much of a compilation performance boost from the incremental compiler since everything's still one one huge assembly.
    • Break project into ASMDEFs, and possibly improve compilation performance, but seriously degrade Editor performance when adding/deleting/moving/opening scripts.
     
  17. doctorpangloss

    doctorpangloss

    Joined:
    Feb 20, 2013
    Posts:
    270
    Problem compiling from command line using 0.0.42-preview.24 and later

    Summary: When specifying an "-executeMethod" from the command line, incremental compiler only builds player assemblies instead of editor assemblies.

    Issue first appears in 0.0.42-preview.26

    Issue does not occur in 0.0.42-preview.21 and 2018.2.9f

    Original problem: Recompilation is required for custom editor scripts to be rebuilt.

    - Versions: 2018.2.16f, IncrementalCompiler 0.0.42-preview.28
    - Goal is to use editor build scripts
    - First command line build worked
    - Second command line build with a different target broke with error:

    Aborting batchmode due to failure:
    executeMethod class 'BuildScripts' could not be found.
    Argument was -executeMethod Minionate.Editor.BuildScripts.BuildWin32

    This method is in an editor script walled off by an asmdef. When I open the project again, I observe that [MenuItem] methods in that class no longer appear.

    It appears from the standard out from the script, the assembly containing this method was rebuilt:

    (0,0): [11/20/2018 10:56:37.228 PM] SpellsourceEditor.dll: no prior compilation found in cache. Caller PID: 82261
    (0,0): [11/20/2018 10:56:37.239 PM] SpellsourceEditor.dll compiling...
    (0,0): [11/20/2018 10:56:37.300 PM] SpellsourceEditor.dll: emitting IL to : /Users/bberman/Documents/Spellsource-Client/Temp/SpellsourceEditor.dll
    (0,0): [11/20/2018 10:56:37.313 PM] SpellsourceEditor.dll compilation finished in 73ms source files re-parsed: 4 metadata reloaded: 1
    (0,0): [11/20/2018 10:56:37.323 PM] SpellsourceEditor.dll: session status updated to IncrementalCompilationStatus.Finished for Caller PID: 82261

    Then, going into the Compiler window and "Rebuild All" makes the [MenuItem] methods reappear.

    This is a new issue, everything was working fine with 2018.2.9f and IncrementalCompiler 0.0.42-preview.24. I upgraded my main Unity editor, which caused a problem with Rider (unicode byte order mark something something), which I fixed with 0.0.42-preview.26 and later.
     
    Last edited: Nov 25, 2018
  18. Xarbrough

    Xarbrough

    Joined:
    Dec 11, 2014
    Posts:
    1,188
    I’ve been using the incremental compiler and ran into the following issue: Apparently, the incremental compiler allows for more recent language features than the regular compiler (e.g. inline out variable declaration). I’m not sure if this is intended or a mistake, but using those newer features got others on my team into a deadlock. I added the incremental compiler package and updated some of my scripts. Then I comitted to the repository and others pulled my changes. On those other machines, when the incremental compiler package was already enabled, everything worked fine, however, if it wasn’t installed yet, Unity failed to do so because of compile errors on the regular compiler version (inline out variables). I could fix this by removing the offending code, then let Unity import the new packages, then reintroduce my code.

    This maybe sounds like a general problem with the package manager: if the project cannot compile because of missing packages, the package manager is unable to install them. This kind of deadlock should be prevented by compiling and applying changes from the package manager before compiling user assemblies, right?
     
    5argon, Ziplock9000 and dadude123 like this.
  19. dadude123

    dadude123

    Joined:
    Feb 26, 2014
    Posts:
    789
    We had the exact same problem here with our project(s) as well.
    It's really quite troublesome. I imagine the situation is worse for people new to unity, will take quite a few hours to figure this one out.

    I was under the impression that this is an obvious design flaw and would be fixed soon. But so far it doesn't seem like it :p
     
    Lars-Steenhoff likes this.
  20. hippocoder

    hippocoder

    Digital Ape

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    Unloading broken assembly Packages/com.unity.incrementalcompiler/Editor/Plugins/Unity.PureCSharpTests.dll, this assembly can cause crashes in the runtime

    Getting this in 2018.3 beta 11 now... And I can't remove incremental compiler due to dependencies so it would be nice if I can find a workaround - anyone have tips? :)

    Why is it an error and not a warning?
     
    luispedrofonseca likes this.
  21. SugoiDev

    SugoiDev

    Joined:
    Mar 27, 2013
    Posts:
    395
    Same issue here, @hippocoder

    Was just going to post here. Just tried with the latest .28 release and it's the same thing.

    I skipped b10 so I'm not sure it happens there.
     
  22. 5argon

    5argon

    Joined:
    Jun 10, 2013
    Posts:
    1,555
    Preview 28 is working in b10. (And I am now not going to update the beta..)
     
  23. SugoiDev

    SugoiDev

    Joined:
    Mar 27, 2013
    Posts:
    395
    Guess I'll be downloading b10 then.
    Too bad we can't install the previous beta directly from the hub.
     
  24. oLDo

    oLDo

    Joined:
    Mar 14, 2017
    Posts:
    55
    Hi.
    It's somewhere package repository preview to check which version is the newest?
     
  25. lorddanger

    lorddanger

    Joined:
    Aug 8, 2015
    Posts:
    103
    I have installed incremental compiler today 1st time, and it opens a new console window (.bin\csc.exe) .
    Is it suppose to do that its a error or bug?
     
  26. Antypodish

    Antypodish

    Joined:
    Apr 29, 2014
    Posts:
    10,753
    When this exactly happening?
    Can it be reproduced?
     
  27. dgoyette

    dgoyette

    Joined:
    Jul 1, 2016
    Posts:
    4,193
    Go to Preferences -> Compiler, and uncheck the option to show output in Console. "Console" in this case is a windows console window, not the Unity console.
     
    GarthSmith and lorddanger like this.
  28. Quatum1000

    Quatum1000

    Joined:
    Oct 5, 2014
    Posts:
    889
    On windows you can set the folder where the test scripts are inside to invisible. Then unity does ignore them completely. The Unity.PureCSharpTests.dll will not created. Works also with all files in folders to make Unity to ignore them.
     
  29. lorddanger

    lorddanger

    Joined:
    Aug 8, 2015
    Posts:
    103
    Thanks it worked
     
  30. lorddanger

    lorddanger

    Joined:
    Aug 8, 2015
    Posts:
    103
    upload_2018-11-28_3-32-31.png
    After Installing The Incremental Compiler when running the game I am getting this warning.. Any Help ??
     
  31. luispedrofonseca

    luispedrofonseca

    Joined:
    Aug 29, 2012
    Posts:
    938
    I'm also getting the error @hippocoder reported above:
    Code (csharp):
    1. Unloading broken assembly Packages/com.unity.incrementalcompiler/Editor/Plugins/Unity.PureCSharpTests.dll, this assembly can cause crashes in the runtime
    @Quatum1000 Can you please explain further? I didn't understand your workaround.
     
    Spy-Shifty likes this.
  32. Quatum1000

    Quatum1000

    Joined:
    Oct 5, 2014
    Posts:
    889
    The PureCSharpTests.dll based on the test scipts the dev team has wrote.

    These simple test c# scripts are compiled into the Unity.PureCSharpTests.dll... like all c# scripts are compiled into any dll as well. To prevent the compiler to compile them, delete them or invisible them. (most parent folder). Anywhere in your project or drive c: (win) you will find the test scripts.Use the search term *test*.cs , *tests*.cs, *pure*.cs or similar.

    You can also delete/invisible the Unity.PureCSharpTests.dll in you Project/packages/... folder, or in the Build, to prevent the error message.

    In the next update it will be fixed.
     
    luispedrofonseca likes this.
  33. luispedrofonseca

    luispedrofonseca

    Joined:
    Aug 29, 2012
    Posts:
    938
    Thanks @Quatum1000 that (almost) solved it. I no longer get the errors.

    Although I still get this (doesn't appear as an error, just a regular log):
    Code (csharp):
    1. SpritePacker failed to get types from Unity.PureCSharpTests, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null. Error: Exception of type 'System.Reflection.ReflectionTypeLoadException' was thrown.
    2. UnityEditor.Sprites.Packer:GetSelectedPolicyId()
    Any hints?
     
  34. aybeone

    aybeone

    Joined:
    May 24, 2015
    Posts:
    107
    Since I've installed the plugin, compilation warnings have simply vanished from Unity console.

    And they're also not visible when enabling the plain old console window option.

    Did I miss something in the process ?

    Thanks !

    Unity 2018.2.16f1
    IncrementalCompiler 0.0.42
    Visual Studio 2017 15.9.3
    Visual Studio Tools for Unity 3.9.0.3
     
    Last edited: Nov 30, 2018
  35. SugoiDev

    SugoiDev

    Joined:
    Mar 27, 2013
    Posts:
    395
    Isn't PureCSharpTests just a "hack" to get replace the normal compiler with the one from the Incremental Compiler? It's the same as @alexzzzz (and others) used to use to replace the normal compiler.

    Take a look here: https://github.com/SaladLab/Unity3D...-to-replace-a-builtin-compiler-with-a-new-one

    That dll isn't a test DLL, it is the actual entry point for the compiler. It just so happens (maybe) that the current normal compiler is up-to-date now, so the project will still compile even if you "disable" the Incremental Compiler. But it will compile as normal, not incrementally. Most people won't even notice unless you use a lot of asmdef files and have larger assemblies.
     
  36. 00christian00

    00christian00

    Joined:
    Jul 22, 2012
    Posts:
    1,035
    I think the old user made incremental compiler was faster, don't know what they were doing differently but I could see a better improvement there.
    https://github.com/SaladLab/Unity3D.IncrementalCompiler
    Too bad it's not maintained anymore and it's not working anymore since Unity 2017.
    I have no clue where to start, but if anybody have any compiler experience I think it should be a relatively easy fix.
    It could also be that my project has gotten bigger and not the incremental compiler fault, since that is not working anymore I can't compare it side by side.
     
    Last edited: Dec 1, 2018
  37. vanshika1012

    vanshika1012

    Joined:
    Sep 18, 2014
    Posts:
    48
    where can I find the manifest to update?
     
  38. chrisk

    chrisk

    Joined:
    Jan 23, 2009
    Posts:
    704
    Hi, what's the current status on the incremental compiler? My project is getting bigger and bigger and it's getting slower and slower to compile. Right now it takes about ~30s each time. I would like to use incremental compiler as soon as possible but reading few posts, it's seems like nowhere close being usable, beside it seems like it currently adds no benefits to compilations time.

    As a desperate potential user, I have a few questions regarding the incremental compiler.

    1. Is the goal(~500ms compilation time for simple changes) of incremental still the goal? It seems like a miracle if it can do that.
    2. What's keeping from achieving the goal? Are there any external issues?
    3. When is the expected release date? or roadmap? I don't think I heard anything on the lastes roadmap.
    4. If the release is not within a couple months, what can we do in the mean time to reduce the compile time? I know that we can create assembly definition to seperate modules but it would be difficult to do that for many 3rd party assets. Are there any helper that let you create assembly definitions files easily?

    Thank you very much.
     
  39. dgoyette

    dgoyette

    Joined:
    Jul 1, 2016
    Posts:
    4,193
    Watch out for those Assembly Definitions. I've mentioned it a couple of times in this thread without any good resolution, that each additional Assembly Definition in a project reduces editor performance by what looks like a linear amount. Any compiler gains you might achieve seem to be completely overshadowed by how long you'll have to wait to perform simple editor operations, like adding scripts, moving scripts, renaming scripts, and even just opening a script in Visual Studio. I spent a couple of days refactoring my project to use Assembly Definitions, in hopes of improving compiler speed, and then deleted every assembly definition due to the terrible performance problem they introduced.
     
  40. chrisk

    chrisk

    Joined:
    Jan 23, 2009
    Posts:
    704
    dgoyette, I can feel your pain. I would like to hear what Unity San has to say. ^^
     
  41. Kichang-Kim

    Kichang-Kim

    Joined:
    Oct 19, 2010
    Posts:
    1,008
    Hi, Will Incremental compiler package be deprecated (or integrated into unity core) in Unity 2018.3? I found that Unity 2018.3 can compile C# 7 source without Incremental compiler package, and its release note says:

    My current project uses Incremental compiler package with Unity 2018.2, and I want to know should I remove it when I upgrade to Unity 2018.3.

    Thanks.
     
  42. SugoiDev

    SugoiDev

    Joined:
    Mar 27, 2013
    Posts:
    395
    I'm also wondering that. It seems this project has received very little love after the initial release.
     
  43. 5argon

    5argon

    Joined:
    Jun 10, 2013
    Posts:
    1,555
    Since around middle of this year, when I do something "slightly advanced" about script files (like moving files between assemblies and rename some of them at the same time) I would randomly get 4-5 identical errors hanging in the console :

    When this happen
    - Pressing clear console will not clear them out. And of course I cannot enter play mode.
    - Right click and Reimport on the related .asmdef file will make the spinner spin and then finish with the same error.
    - Sometimes randomly do Reimport on unrelated files in some order works.
    - Moving some files cross-assembly again sometimes works.
    - Sometimes close and open Unity works, if it does not work, Reimport All will not work but close -> delete Library -> open again works but it takes time.
     
  44. Joachim_Ante

    Joachim_Ante

    Unity Technologies

    Joined:
    Mar 16, 2005
    Posts:
    5,203
    You should not be using incremental compiler when you are using Unity 18.3. In terms of compilation speed, 18.3 is very very close to Incremental compiler speed and a lot more robust.
     
    Roni92pl and optimise like this.
  45. Antypodish

    Antypodish

    Joined:
    Apr 29, 2014
    Posts:
    10,753
    Oh that is interesting.
    Is that means Incremental compiler is included? Or something relevant?
    So we can ditch IC previews now with 18.3+?

    What will happen, if I got IC installed on 18.3?
     
  46. Joachim_Ante

    Joachim_Ante

    Unity Technologies

    Joined:
    Mar 16, 2005
    Posts:
    5,203
    We have integrated an approach that shares some of the ideas but different approach than incremental compiler. It's nowhere near our state goal of 500ms iteration time. Neither incremental compiler, nor the current compiler does that.

    So we are taking a step back on where we want this to go in the long run and will come back when have something to share that actually gets us to our stated goal.

    For now just using builtin 18.3 C# compiler gives big improvements to compile time iteration time compared to 18.2.
     
    siggigg, z00n, optimise and 1 other person like this.
  47. Baste

    Baste

    Joined:
    Jan 24, 2013
    Posts:
    6,294
    Do you have any other thoughts to share on ways to reach that goal?

    Right now the biggest issue we have in helping you reach it is simply that it's very hard for us to measure what's taking time. The editor profiler loses a bunch of stuff that happens during code reload, so I'm not really clear on if the slowness is compilation, assembly reload, editor window reload, custom callbacks, etc.
     
    Antypodish likes this.
  48. dgoyette

    dgoyette

    Joined:
    Jul 1, 2016
    Posts:
    4,193
    Interesting, and thanks for the update. I was always curious what fell under the umbrella of the "500ms" goal, and whether it related much to how long it "feels" like it takes to make a code change. Compile time itself seems like a fairly small portion of the wait time I experience after making a code change and returning to Unity. Was the 500ms goal ever intended to factor in the actual wait time versus just compilation?
     
  49. 5argon

    5argon

    Joined:
    Jun 10, 2013
    Posts:
    1,555
    I have always been thinking that all my Entities toolchain depends on Incremental Compiler package, thinking that even if I remove the compiler package it would be referenced back by dependency so I didn't touch it. I guess it is time to remove it then.

    The spinner freeze time (assembly reload time?) takes up most of my day for sure especially when iterating on bugs. I can hang 2 cloths or wash 2 dishes on each script edit spinner to play mode button comes unpress, and it tempts me to check social when I have nothing more to do. I am developing a really bad habit.
     
  50. Joachim_Ante

    Joachim_Ante

    Unity Technologies

    Joined:
    Mar 16, 2005
    Posts:
    5,203
    We understand the problem better now and it requires putting a team full time on solving it. We'll get there, just have to schedule it against all the other things we are doing.

    Step 1 was shipped in 18.3 with signficantly faster C# compiler.

    Now our focus is on reducing domain reload time & enter play mode time and better showing / profiling where the time is actually spent. In many cases domain reload time is dominated by user code which shouldn't be there.
     
    joshcamas, filod, Roni92pl and 12 others like this.
Thread Status:
Not open for further replies.