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. Voting for the Unity Awards are OPEN! We’re looking to celebrate creators across games, industry, film, and many more categories. Cast your vote now for all categories
    Dismiss Notice
  3. Dismiss Notice

Profiling Compilation Process possible? (long compilation times)

Discussion in 'Editor & General Support' started by _watcher_, Jul 24, 2018.

  1. _watcher_

    _watcher_

    Joined:
    Nov 7, 2014
    Posts:
    259
    Hi,

    My project takes too long to compile.

    Things i've tried:
    1) Incremental compiler (was extremely buggy for me / its still in preview)
    2) Convert C# scripts into Assembly Definition Files (had no effect on compilation time)
    3) Remove Library folder, and let Unity rebuild (had no effect on compilation time)
    4) Deep Profile + Editor Profile to see what's eating the most time during the compilation process - but this gave inconclusive results, sometimes Profiler would show the number of seconds it took, but only display one line in the Overview tab, like
    Code (CSharp):
    1. NumberBuffer.PackForNative()
    2. OR
    3. Buffer.Memcpy()
    4. OR
    5. Char.IsLatin1()
    6. OR
    7. Number.MatchChars()
    8. OR
    9. StringBuilder.ctor()
    10.  
    Target platform is Windows.

    Any suggestions how to see what is eating most of the compile time, so i can try removing such parts from the project? The project is quite big, with lots of dependencies, so just "testing" removal of different parts (like different 3rd party packages) would take a while.
     
    Last edited: Jul 24, 2018
  2. MartinTilo

    MartinTilo

    Unity Technologies

    Joined:
    Aug 16, 2017
    Posts:
    2,140
    What Unity version are you using?
    It looks like, while collecting data for that frame, the chunk of data grew too large to be send to the profiler. We're looking at ways to let you tweak this in a future version. In the mean time: have you looked at the BuildReporter API?
    Or you could try to use Profiler.enableBinaryLog, dump the data to file and load it from there.
    Also:
    Just trying to understand, what you did here: did you create one asmdef per C# file? Because I would've recommended using asmdef files, if you hadn't stated that you already tried. I'd assume with the right dependency setup between them, it should improve significantly but I've also not used them that extensively yet.
     
  3. _watcher_

    _watcher_

    Joined:
    Nov 7, 2014
    Posts:
    259
    Firstly, thank you for the feedback @MartinTilo !
    1) Unity version i'm using: 2018.1.6f1
    2) BuildReporter API & Profiler.enableBinaryLog - new to me, sounds awesome, will try this to profile the build process.
    3) asmdef - I've created asmdef files, yes, but not 1 per 1 C# script file, more like "1 per related folder structure full of C# script files". Then each 3rd party plugin has one too, etc. Structured it so that there are no cyclic dependencies or duplicate references, you know, the lot. Haven't converted 100% of the codebase, maybe 70%-80%. It might have helped a "little" (10% speed increase? If any. Hard to say.).

    I might have over-exagurated a bit :oops: saying it takes "too long", its about 5 seconds to enter PlayMode, then up to 5 seconds to get back to EditMode. I'm doing some fast prototyping now, and it got a bit annoying. I still want to find the culprit tho, find out what's taking most of the time and optimize (also for the future, hoping to learn something here, so i know where to look when it increases further).
     
  4. hgulgen

    hgulgen

    Joined:
    Nov 29, 2016
    Posts:
    50
    @_watcher_ Did you find any solution to compile time ? I have same problem :(
     
  5. _watcher_

    _watcher_

    Joined:
    Nov 7, 2014
    Posts:
    259