Improving iteration time on C# script changes

It is 2 generations old already though and you get a bundle with a board and ram for about 650$. That should be worth it for proper game dev…
Sure, people who are bound to a notebook have it tougher.

These are the modules during installation, but these are usually platform targets., packages are project-related.

We are talking about script iteration time here, right? Thats only singlecore. So a 12900k(s) or 7950x would be your best purchase for that

2 Likes

I just finished assembling an AIO-cooled AMD 7950x w/ PCIe 4.0 NVME and 32 GB of DDR-6000 RAM. I built this beast for one reason: Unity editor iteration time. It is a sad state of affairs to throw hardware at the problem… especially when we know that 2019.x had no iteration issues.

I’m reimporting project assets right now and what does one do while waiting on Unity? Check this thread! I always hope I’ll return and find that @xoofx and team has resolved script iteration issues.

1 Like

Same:
https://docs.google.com/spreadsheets/d/1A2laLkhK9qigmxlJd_QRNQGiAopaXvioycCwuay9oT0/edit?usp=sharing

I think the people saying that 2019 was the bee’s knee’s used the version before the flat redesign, it was noticeably faster.

A side story: 4.7 is 2x to 3x faster at domain reload so something happened. My guess is that editor code was moved from c++ to c#, creating many more states that now compete with our own code to be processed during domain reload.

1 Like

my guess is, if you switch from asset database v2 to v1 in unity 2019, you will see some waiting time improvements

Yes I read other people mentioning the same thing notably the packages.

Unfortunately they removed that option in the LTS of 2019 and I also read someone suspecting the issue originating from the transition from v1 to v2.

Either way reverting back to 2019 comes with other speed tradeoffs like significant import times, initial project opening speed and other in-editor speed improvements like selecting a large number of objects or say a large Light probes group not to mention API and other features.
So in my case I’d take the 9-13s iteration time over the mentioned tradeoffs and will keep testing the 2022.2 betas from times to times to check for any significant improvements in the meantime.

1 Like

Unity Technologies will not fix this because this is not a problem for their shareholders. ATM they are too busy making yet another hair tech demo.

12 Likes

Hello!

We were experiencing a huge degradation on iteration times when changing a line of code and switching back to the Editor, or after pressing the Play button, starting on 2020.3.30f1. After investigating and discussing with Unity, we found out that the cause was a a change in the Package Manager introduced in 2020.3.31 and that was made even worse on 2020.3.34. All Unity versions since then, have this problem.

This was specially noticeable if you are using a lot of packages or packages with lots of versions (for example, if you use a private npm repository like artifactory).

Now, Unity has released 2021.3.12f1 that fixes this problem. The backport to 2020 is coming soon. Give it a go and see if it improves things for you.

The relevant line in the official release notes:

  • Package Manager: Fixed an issue where having packages with a lot of versions increases domain reload time drastically. (UUM-12670)
10 Likes

In the bug report it says the package manager has to be open for the issue to occur. This isn’t the problem most of us are discussing here but thanks for the info regardless.

It is not true. The issue was happening regardless if the Package Manager window was open or not.

The important bit also is that this bug was impacting the Domain Reload, so the result is that you were seeing the Unity dialog “Reload Script Assemblies” for a long time after changing a script, pressing the Play button, etc.

Yeah, but I’m using 2021.3.12f currently and… no improvements for me…
It still feels like the same speed, but this might’ve only impacted bigger projects, which I currently don’t possess.

Same here, every change takes from 40s to ~1-2 mins even in small projects with code separated in diff assemblies

2 Likes

So now I need to ask how big your project is…
Because if your project is humongus then 40s makes sense…

Assembly Definitions don’t do sh*t about assembly reload time ( I know missleading name )

They only speed up compilation time, which is super fast ( sub-seconds ), BUT if you don’t do it you can easily get up to 5s of compilation time ( NOT assembly reload ) extra…
Also it forces you to structure your project :wink:

Thing is me personally I have about 6s for a small change in a script and multiple changes take more about 20s MAX…

I have to say I reinstalled windows a long time ago and if I’m remembering this correctly it was way worse before the reinstall ( maybe on a normal occurance 25-30s ish ), but this isn’t a viable solution for everyone or even businesses.:sweat_smile:

Oh and also this is nowhere close to what it used to be…

The sweet old days of literal millisecond reloads are over I guess… and it seems to be an issue with C# as a language not supporting ways to have precompiled binaries or hot reload or smth idk…

I heard though that all of this stuff so AOT and hot reload are being worked on in .NET 7 and Unity is trying to migrate to that .

We just have to wait super long :hushed:

Wow reading that thread, I wish we’d get as many proactive updates here. Seriously the devs over there pop up pretty regularly. Good on them. Been months since an update on this issue.

3 Likes

Do you have this also if you disable domain reload in the configuration?
https://docs.unity3d.com/Manual/DomainReloading.html

No… but this creates worse problems…

The whole point of reloading the assemblies is to unload any static instances/fields/vars, that are left which might cause unexpected behaviour. By doing what you’re suggesting, you’re disabling that as a whole, meaning I have to uninitialize every Singleton every static value and think about uninitializing it when writing code.

When I get a bug I need to remember that, that might be the cause, not to mention that alot of Unity Assets aren’t accustomed to disabling this option ( A* Pathfinding a couple months ago!!! now it’s fixed )

Also this seems to be a huge project that they’re working on…

I have turned off Auto Refresh and Directory monitoring, so when i change code it does not recompile. However, every time i delete a file, ti will recompile, which is very annoying when trying to clean up. Is it possible to disable this too?

For Singletons and static values use a script that has its event order set to -999 and initialize them all (aka force overwrite the static value) in the awake or even just start method.

The linked article provides info on how to cover more general cases.

On “small projects” it’s not a hassle. I did switch a project fairly late to this mode.