Search Unity

Do-It-Yourself Build Time

Discussion in 'Web' started by movra, Apr 5, 2015.

  1. movra

    movra

    Joined:
    Feb 16, 2013
    Posts:
    566
    I've tried building a project for the WebGL platform on my Win 7 PC and it takes a long time to finish. About an hour. The process is stuck with unity.exe being unresponsive and mono.exe capped at about 12% CPU usage.

    Then I got an idea: let's give Unity Cloud Build a whirl. Committed the same project to a BitBucket repository, added a new project to Unity Cloud Build and started the build. No more than 10 minutes later I received an e-mail that the build was finished. It was probably faster because I've set Thunderbird to check my inbox every 10 minutes. A couple of warnings and 1 error which I couldn't trace back in the log, but the build was successful. To verify I clicked the link which took me to a web player and sure enough it played as expected.

    I'm surprised!

    How is it possible that building a WebGL project takes so long on my PC and so fast with Unity Cloud Build? Is something wrong with my system or does the build process really benefit from parallelization that much?

    I'm almost beginning to think the Unity Editor is deliberately hampered to attract more Unity Cloud Build users ;)
     
  2. jonas-echterhoff

    jonas-echterhoff

    Unity Technologies

    Joined:
    Aug 18, 2005
    Posts:
    1,666
    1 hour is a very long time - I never have WebGL builds take that long. The only reason I can think of for builds to take that long is that you may have a low amount of memory on your system, so it starts paging like crazy? (Building for WebGL is a very memory-intensive task).
     
  3. De-Panther

    De-Panther

    Joined:
    Dec 27, 2009
    Posts:
    589
    Since when the Cloud build has WebGL option?
    Didn't check it in the last few weeks
     
  4. movra

    movra

    Joined:
    Feb 16, 2013
    Posts:
    566
    I'm now closely monitoring the Windows 7 x64 Resource Monitor while Unity 5.0.1 is building the WebGL project. It doesn't seem to be CPU bound (~13% use of an i7 920 @ 2.67 GHz) nor RAM bound (8390 of 16384 MB available).

    Maybe it's I/O bound though. This particular project is on a mechanical harddisk and I notice Unity is writing a lot of small files to it.



    Although it doesn't seem to reach the max throughput of the drive, I'll move the project to an SSD and try again.

    At this moment of the build process, 20 minutes in, the disk isn't doing anything related to Unity at all. All I'm seeing is mono.exe chugging away with 2 threads and 12% CPU. I'll try building an empty project too.

    edit: After 45 minutes I cancelled and/or mono.exe crashed. The temp folder 799 MB and contains 168221 files. For the record, the assets folder is 1.66 MB and contains 503 files.

    edit2: Empty project on SSD finished building within 2 minutes. This means Unity is definitely capable of building WebGL project fast on my system.

    edit3: Empty project on HDD also fast. Maybe the cause for the long build-time is not with the hardware, but related to the code in the project.
     
    Last edited: Apr 5, 2015
  5. akutruff

    akutruff

    Joined:
    Jul 24, 2009
    Posts:
    44
    I've been building webgl for 20 minutes now locally. opt.exe llvm.exe are going CPU crazy.

    What types of code constructs affect build times. I hope generics aren't the culprit. We use generics a ton.
     
  6. movra

    movra

    Joined:
    Feb 16, 2013
    Posts:
    566
    I'm getting the feeling that indeed it's caused by the code. The project that's causing the long build times is https://github.com/neuecc/UniRx (after removing UniRxTestSandbox.cs and fixing some broken references - and woops, I see I threw in Slinq too, which could be nasty) which relies heavily on generics and LINQ.

    Still I'm surprised Unity Cloud Build manages to finish that project in a few minutes whereas my system takes an hour.
     
    Last edited: Apr 5, 2015
  7. movra

    movra

    Joined:
    Feb 16, 2013
    Posts:
    566
    Eh, found the culprit: Slinq. The UniRx project without Slinq is built in a few minutes. I still don't know why Unity Cloud Build didn't choke on Slinq, or maybe it did but it's just too fast to notice. Now to investigate why Slinq doesn't gel with WebGL.
     
  8. movra

    movra

    Joined:
    Feb 16, 2013
    Posts:
    566
    Mystery solved.

    It's really embarrassing. I added Slinq for preliminary research about the feasibility and effectiveness of replacing Linq in UniRx with Slinq. I also wanted to see if there are any AOT problems building UniRx with IL2CPP.

    But I never added the Slinq folder in the project to the Git repository, so Unity Cloud Build simply never had the opportunity to choke on it. No eggnog for me.

    The last step to verify this theory would be to build a Slinq project with Unity Cloud Build, but I am not sure if you would appreciate it potentially blocking/crashing the servers.
     
  9. liortal

    liortal

    Joined:
    Oct 17, 2012
    Posts:
    3,562
    @jonas echterhoff can you confirm that WebGL build is available in Cloud Build ? I couldn't find that option anywhere...
     
  10. movra

    movra

    Joined:
    Feb 16, 2013
    Posts:
    566
    Hm, seems like I have mistaken Web Player for WebGL. I blame my rose tinted glasses. Anyway, this whole topic is not related to Unity Cloud Build anymore.
     
  11. akutruff

    akutruff

    Joined:
    Jul 24, 2009
    Posts:
    44
    I am submitting my project as a bug. It takes forever to build locally. Generics worked totally fine with mono AOT. I hope Unity sees this as high priority - a ton of code relies on generics.
     
  12. movra

    movra

    Joined:
    Feb 16, 2013
    Posts:
    566
    That's fine, they called for examples that show excessive build times.
    I submitted a bug report with such a project earlier today.