Bug 6616 - compiling with a 3rd party library takes extraordinarily long
Summary: compiling with a 3rd party library takes extraordinarily long
Alias: None
Product: iOS
Classification: Xamarin
Component: General ()
Version: 5.2
Hardware: PC Mac OS
: --- normal
Target Milestone: Untriaged
Assignee: Bugzilla
Depends on:
Reported: 2012-08-21 00:19 UTC by Tommy Fannon
Modified: 2012-08-21 08:21 UTC (History)
2 users (show)

Is this bug a regression?: ---
Last known good build:

monotouch project that reproduces the problem (865.53 KB, application/zip)
2012-08-21 00:19 UTC, Tommy Fannon

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.

Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:

Description Tommy Fannon 2012-08-21 00:19:46 UTC
Created attachment 2380 [details]
monotouch project that reproduces the problem

I am attempting to talk to Service Stack on Windows by using the dlls made especially for monotouch.

The build/compile step takes 33 seconds on a 2011 iMac.  Every time I change any code and want to debug,  there is a 33 second compile time.  In my mind this makes it very unusable.  

I have attached the project with a single service stack dll included.  You can reproduce by doing a simple build.
Comment 1 Sebastien Pouliot 2012-08-21 08:21:32 UTC
Simulator builds are quite fast. My 2012 iMac takes:

Debug|Simulator (Rebuild): Total time: 1333 ms

But I assume you're talking about device builds since the .NET code needs to be compiled to native ARM code (AOT compiler) and linked as extra steps (the simulator uses the JIT and skip those). That can take quite some time based on the size of your application. E.g. with my iMac:

Debug|iPhone (Rebuild): Total time: 24950 ms

In MonoTouch 5.3.x (soon to be 5.4 stable) we added object file caching. So unchanged files are not re-compiled (AOT'ed) every time a change is done.

E.g. I changed "foo" and "bar" strings in ServiceStackTestViewController.cs and did a new build.

Debug|iPhone (Build): Total time: 8846 ms

Also like I said the build time depends on the application size. You can reduce your application size by enabling the linker on your own code (default is SDK only). This does not help every projects (as user code often does not contain much _unneeded_ code) but projects including 3rd party code can get nice size reduction. What's more interesting, time wise, is that the (managed) linker is faster than the AOT compiler (so you win time by having less code to AOT compile). E.g.

Debug|iPhone (Rebuild) (Link all): Total time: 20112 ms

This gain is possible with MonoTouch 5.2.x but you'll need to ensure your application does not require code, e.g. thru reflection, that the linker could have removed (see [Preserve] attribute for details). Linking everything also helps with object caching (5.3.x). E.g. changing again the foo and bar strings.

Debug|iPhone (Build) (Link all): Total time: 6955 ms

A last note: the time to upload application to devices was cut by about 50% in MonoTouch 5.3.4+. So the edit|build|debug cycle feels even faster.

MonoTouch 5.4 should be available (as a stable release) shortly but you can try this using the latest beta releases: 5.3.5 today, soon to be 5.3.6 (in QA).