Search Unity

Bug LET'S DEMAND FASTER SCRIPT COMPILATION TIME !!!!!

Discussion in 'Editor & General Support' started by JiRo_Dev, Dec 22, 2023.

  1. JiRo_Dev

    JiRo_Dev

    Joined:
    Jun 8, 2018
    Posts:
    48
    While Unity is easy to use and full features, there are painful frustrations that I wish you'd pass to your developers, mainly how utterly slow the engine became over the years, it used to be lightning fast back in 2019 and 2018, right now script compile time is 10-15 times slower, build time is 5x slower, iteration time is utterly unacceptable which is pushing me to write hundreds of lines of code without testing and that requires crazy concentration just to avoid frequent code compilation, and beginners have no choice but to compile after 1 or 2 lines of code since they're new and generally wouldn't write more than 5 lines of code without testing.
    It takes 35 seconds to compile a simple change, which compounds to hours per day wasted. The iteration speed is simply atrocious and leads me to often check something else while waiting and getting distracted and losing focus.
    What's more bizarre to me is that you're well aware of how bad the iteration speed is (unless Unity devs don't use Unity) but you just don't want to fix it, "Hot Reload" an asset in Unity Assets Store does help reduce compilation time from 35 seconds to 200 milliseconds, why is a small team of 30 devs able to pull of what a 10 Billion dollars company can't do?
    It's about time we demand from Unity to seriously look at iteration speed, if a small team can make code compile in 0.2 seconds, Unity should be able to match that at the very least!
     
    tonytopper, Kas_ and Kurt-Dekker like this.
  2. marcoantap

    marcoantap

    Joined:
    Sep 23, 2012
    Posts:
    225
    Try this: go to Project Settings and disable Reload Scene, Reload Domain, Scene Backup and Optimize Mesh Data.

    Also Unity is way faster compiling on Linux than Windows.
     
    Last edited: Dec 22, 2023
  3. CodeSmile

    CodeSmile

    Joined:
    Apr 10, 2014
    Posts:
    5,882
    10-15 times? I assume you took the exact same 2018/2019 project after taking measurements, upgraded it to 2022 and took the same measurements again? If you did not do so with the exact same project, you are comparing Apples with Oranges.

    I recently tested two projects, taking them from 2017 all the way to 2023 and to be concise: 2019 had the slowest script compile time, 2023 was almost 50% faster than 2022 and twice as fast as 2019.

    35 seconds compile time … I wonder, what‘s your system spec? You do not run low on memory at any time? Your project is on a SSD? And how many scripts or lines of code do you have in there? How many assembly definitions? How many assets and packages installed?

    You may want to test how long it takes to compile a script change in a new, empty project. It should not take longer than about 3 seconds on decent hardware. If it does take longer you very likely have a hardware or software issue. If not, the issue is with the project you work on and can very likely be sped up by a lot.

    Note that if you create a 2017 project and create a 2022 project they will have different metrics than if you take a 2017 project and upgrade it to 2022 due to more and different packages being installed by default.

    You can shave off several seconds by removing all unneeded packages, assets and built-in modules and generally keep your project clean by removing assets not or no longer in use. In that regard a Unity project is like Windows - you can cripple the performance by just installing stuff and never cleaning up.

    Actually, it can be much worse for Unity. There are so many badly written editor scripts that modify a single asset and then guess what? Yes, they will save all (!) assets and then also refresh the AssetDatabase which means all „currently unused“ (cached) resources get unloaded.

    You may want to pull out the Profiler, put it in deep profiling and editor mode, an check where that time is spent. Quite likely you will find the odd Importer script doing crap as mentioned above, or just doing way too much like inspecting every asset (of a type). There is also an Asset Importer log window that helps to see what is being imported to help with debugging import delays.

    Such „programmed negligence“ is quite likely to cause such tremendous delays if the hardware itself isn‘t much of an issue and more so if one particular project is affected more than others.

    Btw, you need not demand this. It‘s long been on the roadmap, eventually assembly reload will go away entirely once Unity has fully adopted the latest .NET tech stack. If I remember correctly this should appear in 2024 or 2025.
     
    Last edited: Dec 22, 2023
    Ryiah likes this.
  4. Were you asleep under a rock or something? The entire forum is full of threads doing just that. Discussions about lags, speed, progress bar hold-ups, etc., sometimes deeper, sometimes just the mob-mentality level, discussion about the problems and sometimes about the solutions.

    And about this: they can't, they have the level of restriction Unity can't come out with. It's the Bakery-argument again. A developer can say they don't support AMD cards, Unity can not. A small studio can say, hey, here is a half-baked solution to hot reload, but it doesn't work in a big bunch of cases is fine. Unity can't do that.
     
    tonytopper and Ryiah like this.
  5. JiRo_Dev

    JiRo_Dev

    Joined:
    Jun 8, 2018
    Posts:
    48
    Where did they say that? And when you say 2024 is it safe to assume it'll be with Unity 6?
     
  6. CassClay

    CassClay

    Joined:
    Mar 21, 2020
    Posts:
    68
    I was hoping it's just my machine, I do remember years back Unity were running very smooth on it, while now it's pure drag for about anything.
     
    JiRo_Dev likes this.
  7. Ryiah

    Ryiah

    Joined:
    Oct 11, 2012
    Posts:
    21,141
    To be fair it can be both your machine and Unity. For my last major work project the worst case on my PC (5950X w/ 64GB RAM) was six seconds. For my Mac Mini (M1 w/ 16GB RAM) it was around triple that. Tests were ran on both the 2021 LTS and 2022 LTS.

    It wasn't an enormous project (30 GB source with builds between 5 and 10 GB depending on target platform) but it was targeting standalone and consoles, had a fair amount of code for its size, and wasn't using asmdefs.

    A completely empty project on those releases is around 3 seconds on my PC. For comparison of just how bad Unity has gotten an empty project in Unity 5.6 is a few hundred milliseconds (it appears to be almost instant to me).
     
    Last edited: Dec 25, 2023
  8. They said it in this thread. It probably won't be in Unity 6. Unless something extraordinary happens. Reportedly Unity employees are allowed to start talking about features extensively a year before the first release. They aren't talking about any concrete, formulated plan just yet, only vague "we're working towards this".
     
  9. Ryiah

    Ryiah

    Joined:
    Oct 11, 2012
    Posts:
    21,141
    That's fair. Just changing the license was already a very big endeavor. Adding features too might be difficult. :p
     
    Lurking-Ninja likes this.
  10. Hey, they changed the version number pattern as well! I hate to quote myself (well, it's a lie), but...
     
  11. JiRo_Dev

    JiRo_Dev

    Joined:
    Jun 8, 2018
    Posts:
    48
    Interesting, M1's single core performance is about the same that of a Ryzen 5950X, but 2x slower in multicore perf, since you found M1 to be slower means the compilation process perhaps is a multicore task...
     
  12. Ryiah

    Ryiah

    Joined:
    Oct 11, 2012
    Posts:
    21,141
    It's likely more complex than that. A Mac Mini M1 caps out at 16GB RAM and in my tests the system consistently uses half of that leaving only 8GB RAM and swap for Unity. On Windows Unity was consistently using 24GB RAM with very rare bursts to max memory (eg swapping build targets uses up all available RAM). It's why I'm on 64GB.

    A 5950X is 3x the multicore performance of the base M1. If you look at just the core count it might seem only 2x but it's an entirely performance core design whereas only 4 cores on the M1 are performance. It also has two threads per core, an enormous cache (>70MB), and boosts to almost 5GHz. Best purchase I ever made.

    https://www.cpubenchmark.net/compare/AMD-Ryzen-9-5950X-vs-Apple-M1-8-Core-3200-MHz/3862vs4104
     
    Last edited: Dec 25, 2023
  13. Yuchen_Chang

    Yuchen_Chang

    Joined:
    Apr 24, 2020
    Posts:
    126
    Unity is working hard on moving Unity's C# backend to CoreCLR recently, maybe that would result in a speed up in compiling too. (I have no knowledge about CoreCLR)