Search Unity

Tips to reduce WebGL compile time?

Discussion in 'Web' started by JJJohan, Mar 15, 2018.

  1. JJJohan

    JJJohan

    Joined:
    Mar 18, 2016
    Posts:
    214
    Hello,

    I've been part of a team developing a complex enterprise WebGL application and we iterate over a large number of build iterations through Continuous Integration. While we've been pretty successful with tackling problems that have come up, one thing that's always been a bit tricky to deal with is the compile times.

    While it's no doubt a complex process to convert from IL to C++ and then for Emscripten to convert it again to asm.js/wasm, I'm still keen to search for some gains here and there.

    Currently we're looking at an average compile time between 8 and 12 minutes between two separate projects. While parallelising builds via Docker containers or Unity Cloud build are helpful to circumvent a large build queue, the actual build time itself remains a bit of a hurdle.

    So far:
    • We compile against the .Net 3.5 subset profile to minimize produced code.
    • We rip out every dependency and piece of code to again minimize code output that needs to be processed into the final JavaScript output.
    • We turn off anything we don't use (e.g. audio)
    • Continuous Integration builds currently retain the same Unity folders to try and benefit from any Il2CPP caching that happens in the Library folder.
    • I've tried manually building the latest snapshot of Emscripten and replacing Unity's own version - While it works, the compile times remain indifferent.

    Some questions that come to mind:

    • Is there any way of telling Emscripten to cache certain assemblies that we can guarantee do not change between builds? We currently do not use Unity's Assembly definition files - do these benefit at all compared to regular dlls (also containing unity code) in terms of caching / build times?
    • Are there any known build process changes currently planned in the future / internal roadmap?
    • Has anyone else got any tips?

    Cheers!
    Johan
     
    andrew_steeley and Laicasaane like this.
  2. Laicasaane

    Laicasaane

    Joined:
    Apr 15, 2015
    Posts:
    361
    The project I'm working on isn't large nor complicated but the compile time is significant long. Even when I used Assembly definition files, it wouldn't be faster. So what I'm doing is breaking it down into small and independent pieces to fasten the building + testing process. But the thing ahead at the release day is what I'm afraid the most.