Editor is extremely slow after adding Assembly Definitions

I’ve just gone through my project adding Assembly Definition files, about 35 of them across all of my code, test code, and editors. This work was done on a branch, so I can compare the editor behavior before-and-after side by side. What I’m finding is that it now takes a VERY long time to perform certain common actions in the editor:

  • Add a new c# script
  • Delete a c# script
  • Move a script from one directory to another
  • Double-click a c# script to open it in Visual Studio
  • Double-click a console line to open a script in Visual Studio

In my non-ASMDEF version of the project, it takes maybe 2 seconds to do any of these things. Specifically, when adding a new script, there’s about a 2 second pause, during which time Unity is locked up, after which Unity is functional again, and begin compiling.

However, under my ASMDEF version of the same project, it now takes 15 seconds to do any of those tasks. During this time Unity Editor is maxing out just one CPU core (using about 18% of the total CPU), for 15 seconds, before anything begins to happen.

I’m not seeing anything in my log to indicate what’s going on. This is on Unity 2018.2.14.

Does anyone else experience this kind of huge slowdown after switching to using ASMDEF files? Using the Incremental Compiler doesn’t change this slowness either way.

Actually, I’m seeing this in the Editor log when I add a new c# script. This is the log entry starting when I press “enter” to choose the name of the script, right up until recompiling actually starts:

Updating Assets/Code/Controllers/SomeNewScript.cs - GUID: 9e320b17e2bb89c40959dd391ec75e83...
----- Compute hash for Assets/Code/Controllers/SomeNewScript.cs.
done. [Time: 147.977938 ms]
Updating Assets/Code/Controllers/SomeNewScript.cs - GUID: 9e320b17e2bb89c40959dd391ec75e83...
done. [Time: 6.415855 ms]
Disconnect from CacheServer
Refreshing native plugins compatible for Editor in 1.65 ms, found 16 plugins.
Preloading 3 native plugins for Editor in 0.32 ms.

----- Total AssetImport time: 20.854323s, AssetImport time: 15.353629s, Asset hashing: 0.000173s [0.6 KB, 3.150748 mb/s]
----- Cache Server detail: CacheServerIntegrate time: 0.000000s, CacheServer download: 0.006101s [0 B, 0.000000 mb/s]
----- Cache Server detail: Total assets requested: 1, Cached Assets: 0, Not available: 0, Not supported: 1.
----- Cache Server detail: CacheMove: 0.000000s, CacheDelete: 0.000000s.

- Starting compile Library/ScriptAssemblies/Gravia.Code.Controllers.dll

Total time to add the script is 20.8 seconds, with 15.3 spent on Asset Import? Does that make sense?

And interesting, this is what I get when I move a c# script from one directory to another (within a single Assembly Definition):

----- Total AssetImport time: 16.755038s, AssetImport time: 0.000000s, Asset hashing: 0.000000s [0 B, 0.000000 mb/s]

16.75 seconds total, but 0s for everything else… I’m not sure what’s up.

More on this. As a test, if I delete the 35 ASMDEF files, then the editor is instantly responsive again, and adding/removing a new script takes only a couple of seconds, as it did before.

So it really seems that using ASMDEF files results in extremely slow asset import times? It doesn’t seem like people would put up with this, so I still assume I might have something set up wrong…

I have pretty much the same results, I first split my dependencies into 20 asmdef files and it took forever to compile, and went back to only 2 asmdef files which is usable at the moment. Looking for solutions too.

Yeah, I ended up reverting all my ASMDEFs because of this, as Unity just became too slow. I submitted a bug on the topic as well:

https://fogbugz.unity3d.com/default.asp?1099327_hsdodu6qm33opv1b

1 Like