Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Official Improving iteration time on C# script changes

Discussion in 'Scripting' started by xoofx, Oct 18, 2021.

  1. CodeRonnie

    CodeRonnie

    Joined:
    Oct 2, 2015
    Posts:
    284
    Yes, you're right. I was using the term "assemblies" interchangeably, but at various points I was referring to precompiled dll assemblies, and at others was referring to asmdefs. That is confusing, and I admit I was confused because I was assuming that asmdefs automatically reference other asmdefs that are marked as auto reference, which was incorrect. I'm sorry for the confusion. I've gone back and added edits to my original post for clarification.

    If that is not the situation you've faced, that's fair. I was just trying to brainstorm suggestions for where some extra recompile times could be coming from.
     
    Last edited: Jun 12, 2023
  2. RobertOne

    RobertOne

    Joined:
    Feb 5, 2014
    Posts:
    257
  3. stonstad

    stonstad

    Joined:
    Jan 19, 2018
    Posts:
    599
    I can confirm the same behavior in 2022.2.12. While it isn't a permanent fix, clearing \library does decrease editor iteration time if the cache is old. Unfortunately, this is one possible solution among the many required to improve iteration time. Ultimately, Unity has to remain focused on improving iteration time.
     
    Last edited: Jun 28, 2023
    Unifikation likes this.
  4. stonstad

    stonstad

    Joined:
    Jan 19, 2018
    Posts:
    599
    Lahcene and Ryiah like this.
  5. DragonCoder

    DragonCoder

    Joined:
    Jul 3, 2015
    Posts:
    1,459
    Have you read the resolution note there?

    "
    RESOLUTION NOTE:

    I have filed several issues separately to fix particular parts of this that were slow. We have a Prism dashboard now to help monitor iteration times on a broader scale. The team are working on CoreCLR where we hope to make a big improvement to this issue, but we're unlikely to work on fixing this specific bug report."
     
    Lahcene likes this.
  6. Unifikation

    Unifikation

    Joined:
    Jan 4, 2023
    Posts:
    1,043
    Everyone has, and we're all familiar with this pattern, too:

    1. Problem too hard, promise a big new shiny thing in much time...

    2. ...delivery half arsed thing with more problems and promise to fix until it too problematic - goto 1
     
  7. runner78

    runner78

    Joined:
    Mar 14, 2015
    Posts:
    760
    In this case I would rather say the bug report is too generic.
    Unity has "improved" performance in many areas, however, these performance improvements have been offset by new features. Without these improvements, it would be even worse now.
    I think Unity with Mono has reached the limit of what is possible. In my opinion, CoreCLR will have a massive performance boost (once the editor runs on coreCLR and .NET 8)
     
    Last edited: Jul 5, 2023
    Lahcene and JesOb like this.
  8. pastaluego

    pastaluego

    Joined:
    Mar 30, 2017
    Posts:
    193
    Not to sound rude, but it's hard to take your opinion of it seriously when you don't even know how to spell it. But it appears we're still years away from CoreCLR. Even just a few months ago they said they're far away. At the rate Unity moves I'd think 2025.1 would be very optimistic.
     
    AshwinTheGammer and Unifikation like this.
  9. runner78

    runner78

    Joined:
    Mar 14, 2015
    Posts:
    760
    I am the master of twisted letters!

    I think CoreCLR will come with unity 2024.x for player build, editor as you say 2025.x. Unless the plans have changed and it's coming at the same time.
    As far as I remember, at first only CoreCLR will come, but the profile stays with .Net Standard 2.1, and only later .NET 8 when both player and editor are running on CoreCLR.

    I think it is now difficult to justify wasting enormous resources on optimizing things that are of little use in the end and are again obsolete with CoreCLR
     
    Lahcene, pastaluego and JesOb like this.
  10. peter_hall

    peter_hall

    Unity Technologies

    Joined:
    Sep 3, 2019
    Posts:
    14
    Hi there! Since I'm the person who closed it, I wanted to chime in on the discussion around this bug:

    https://issuetracker.unity3d.com/is...-script-in-editor-became-really-slow-in-trunk

    We did an investigation for this particular bug and found several issues that have been filed internally with other teams (for example - a source control plugin issue, an issue with Mono performance degrading during an Editor session, and issues with the number of packages and source files included by default with more recent versions of Unity). I've then closed this particular bug because the changes necessary to completely fix it are too big for a single bug-fixing task.

    All that said, I'd like to emphasize that we are continuing to work on improving iteration time (and this includes ongoing work around CoreCLR). Thank you for being patient with us while we work on it!
     
  11. RemDust

    RemDust

    Joined:
    Aug 28, 2015
    Posts:
    431
    I came for a solution, all i found is just depressing :)
     
  12. Ne0mega

    Ne0mega

    Joined:
    Feb 18, 2018
    Posts:
    702
    Well, I am somewhat relieved. I thought i had been wasting 5 seconds an iteration for years without knowing it could have been faster.

    But it isn't and hasn't. (Has it? Im on 2022.1.16f)

    Whew.

    I guess it will be what it will be until it isn't.

    In the meantime, I think it's time I rebuild my library folder. Its been six months or so...


    EDIT:. After deleting rebuilding my library folder, it went from 10Gb to 6, and script compilation went from about 7 seconds to about 4.
     
    Last edited: Jul 15, 2023
    DragonCoder and Lahcene like this.
  13. bdovaz

    bdovaz

    Joined:
    Dec 10, 2011
    Posts:
    1,015
  14. AshwinTheGammer

    AshwinTheGammer

    Joined:
    Sep 23, 2016
    Posts:
    68
  15. Tymac

    Tymac

    Joined:
    Nov 12, 2015
    Posts:
    10
    I don't know how many individuals experiencing this issue fall in the same group as me but what I found causing the vast majority of my slow compilation and reload times was a poorly designed custom editor script (10-15 seconds to over 2 minutes during a 24-hr period). I had the script attached to multiple prefab objects as I was refactoring and testing functionality. After looking through Editor.log and seeing issues in the asset importer window pointing to this editor script it gave me an idea on where to focus my efforts. After refactoring the custom editor code and removing redundant testing prefabs holding references to the underlying editor class my reload times have dropped below 10 seconds.

    I just wanted to let people know the issue is sometimes self-created or possibly from poorly designed 3rd party assets imported into your project. Reading through this topic might make some people believe it is 100% Unity's issue and there is nothing they can do about it. I thought that, but thankfully I took the effort to figure out it was my fault.
     
    Qriva, Luxxuor, Lahcene and 5 others like this.
  16. fernfreak

    fernfreak

    Joined:
    Jun 22, 2013
    Posts:
    1
    This affects completely new, empty projects without any 3rd party assets, which is why people correctly believe it's 100% unity's issue. The slow reload script assemblies issue is affecting many, but not all people, so the community is split into those who are unaffected and those who find development intolerable due to it.

    So many people are reporting this issue in forums all over, many of them veteran developers who have years of experience with unity: this is a genuine problem with the engine today and not due to user incompetence. In the past few years I have personally experienced it and seen my peers struggle with it, so it is disappointing that Unity continues to be unable or unwilling to address this.

    I have been a longtime proponent of Unity in the past, but I have since switched to other engines, as have many other developers I know. Unity is simply no longer usable and there has not been any action on this for years.
     
  17. spiney199

    spiney199

    Joined:
    Feb 11, 2021
    Posts:
    5,843
    They said 'sometimes' and not 'always'.

    Sometimes slow domain reloads are the result of some issue on the side of the user. It might be poorly written editor code, it might be their hardware is not up to snuff, it might be their project is running off a HDD (yes this has happened).

    But not always.

    Hence why it's important to profile the editor and see where the most time is spent during a domain reload. As someone who makes a lot of my own editor tools I do profile them to make sure I'm now bogging down my other projects that depend on them, and there have been multiple times where I needed to fix a performance issue.
     
  18. Lahcene

    Lahcene

    Joined:
    Jun 18, 2013
    Posts:
    55
    I am a day late, but I just came here to wish happy birthday to my comment,
    one year down, only two more to go, see you in 2025!
     
  19. Meta_Bird

    Meta_Bird

    Joined:
    Apr 25, 2020
    Posts:
    15
    Hi,
    Is anyone aware of any good tutorials on what users can do to improve domain reload times?
    I came across this article by John Austin, which is great, but I am looking for more / more detail.

    (For context, I currently have near instant script compiling but 15 to 40 second domain reloads. I've been looking at the Editor Iteration Profiler but I'm finding it a bit overwhelming. I've got Reload Domain on enter play mode turned off. I've looked at Hot Reload, which looks cool, but its not really the solution I'm looking for. And for what its worth, I'm making use of assembly definitions and running Unity on relatively competent hardware: intel i7-13700K, M.2 NVMe drives, 64gb ram.)
     
  20. Baste

    Baste

    Joined:
    Jan 24, 2013
    Posts:
    6,194
    Sebastian Schöner, who worked for Unity until just recently, posted this big blog post about this theme, it might be worth reading!
     
  21. Meta_Bird

    Meta_Bird

    Joined:
    Apr 25, 2020
    Posts:
    15
    The article was very helpful. Thank you!
     
  22. RobertOne

    RobertOne

    Joined:
    Feb 5, 2014
    Posts:
    257
    i need to admit, i didnt really cared about this problem anymore. i was stuck on an old project anyway that was using unity 2019 and there the compile times has been fine all the time. I started a new project today and evaluated a few versions and i must say. i am impressed with the latest LTS version of unity 2022!

    unity 2019LTS: Script compilation time:1.772s
    unity 2020LTS: Script compilation time:1.867s
    unity 2021: Script compilation time:3.235s
    unity 2022 LTS: 1.765sec

    these are the compile times for an empty project without any package.
    so. good job unity!
     
    Lahcene and valarus like this.
  23. valarus

    valarus

    Joined:
    Apr 7, 2019
    Posts:
    430
    Have you tried script compilation HDRP ?
     
    Lahcene likes this.
  24. RobertOne

    RobertOne

    Joined:
    Feb 5, 2014
    Posts:
    257
    2.5-2.8 seconds

    but i also (need to) have 11 packages now
     
    Lahcene likes this.