如何加快 MonoTouch 编译时间? [英] How to speed up MonoTouch compilation time?

查看:31
本文介绍了如何加快 MonoTouch 编译时间?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


(来源:xamarin.com)

阅读更多内容并了解如何在 Rolf 的帖子中启用增量构建.

Evolve 2013 视频

可以在 高级 iOS 构建机制 我在 进化 2013.

原答案

影响构建速度的因素有很多.但是,其中大多数对设备构建的影响更大,包括您提到的托管链接器的使用.

托管链接器

对于设备链接所有是最快的,其次是链接 SDK 和(最后)不要链接.原因是链接器可以比 AOT 编译器更快地消除代码(净增益).此外,较小的 .app 将更快地上传到您的设备.

对于模拟器 Don't link 总是更快,因为没有 AOT(使用 JIT).除非您想测试它们,否则不应使用其他链接选项(它仍然比构建设备要快).

设备技巧

  • 构建单一架构(例如 ARMv7)比 FAT 二进制文件(例如 ARMv7 + ARMV7s)更快.更小的应用程序也意味着上传到设备的时间更少;

  • 默认 AOT 编译器(单声道)比使用 LLVM 编译器快得多.但是后者会生成更好的代码并且还支持ARMv7s、Thumb2;

  • 如果您的 .app 中捆绑了大量资产,那么将它们部署/上传(每次都必须经过签名)与您的应用程序一起部署/上传需要时间.我写了一篇博客文章,介绍如何解决此问题 - 如果您愿意,它可以节省大量时间拥有大量资产;

  • 对象文件缓存在 MonoTouch 5.4 中实现.有些构建会快很多,但其他构建不会(当必须清除缓存时)更快(但永远不会更慢;-).更多信息为什么经常发生这种情况这里).

  • 调试构建需要更长的时间,因为符号,运行 dsymutil 并且,由于它最终变得更大,上传到设备的额外时间.

  • 默认情况下(您可以将其关闭),发布版本将执行程序集的 IL 条带.这只需要一点时间 - 在将(较小的 .app)部署到设备时可能会恢复.

模拟器技巧

  • 如前所述,尽量避免链接,因为这会花费更多时间并且需要复制程序集(而不是符号链接它们);

  • 使用原生库会比较慢,因为在这种情况下我们无法重用共享的 simlauncher 主可执行文件,并且需要让 gcc 为应用程序编译一个(这很慢).

终于有疑问的时候了!我的意思是您可以将 --time --time 添加到您的项目 extra mtouch arguments 以查看每个操作后的时间戳:-)

It is well known that

If compiling takes even 15 seconds, programmers will get bored while the compiler runs and switch over to reading The Onion, which will suck them in and kill hours of productivity.

Our MonoTouch app takes 40 seconds to compile on Macbook Air in Debug/Simulator configuration.

We have about 10 assemblies in the solution.
We're also linking against some native libraries with gcc_flags.

I'm sure there are ways to optimize compilation time that I'm not aware of, which might have to do with references, linker, whatever.

I'm asking this question in hope that someone with better knowledge than me will compile (no pun intended) a list of tips and things to check to reduce MonoTouch compilation time for debug builds.

Please don't suggest hardware optimizations or optimizations not directly related to MonoTouch.

解决方案

Build Time Improvements in Xamarin.iOS 6.4

Xamarin.iOS 6.4 has significant build time improvements, and there is now an option to only send updated bits of code to the device. See for yourself:


(source: xamarin.com)

Read more and learn how to enable incremental build in Rolf's post.

Evolve 2013 Video

An updated and expanded version of this content can be seen in the video of the Advanced iOS Build mechanics talk I gave at Evolve 2013.

Original Answer

There are several factors affecting build speed. However most of them have more impact on device builds, including the use of the managed linker that you mentioned.

Managed Linker

For devices then Link all is the fastest, followed by Link SDK and (at the very end) Don't link. The reason is that the linker can eliminate code faster than the AOT compiler can build it (net gain). Also the smaller .app will upload faster to your devices.

For simulator Don't link is always faster because there's no AOT (the JIT is used). You should not use other linking options unless you want to test them (it's still faster than doing a device build).

Device tricks

  • Building a single architecture (e.g. ARMv7) is faster than a FAT binary (e.g. ARMv7 + ARMV7s). Smaller applications also means less time to upload to device;

  • The default AOT compiler (mono) is a lot faster than using LLVM compilers. However the later will generate better code and also supports ARMv7s, Thumb2;

  • If you have large assets bundled in your .app then it will take time to deploy/upload them (every time since they must be signed) with your app. I wrote a blog post on how you can workaround this - it can save a lot of time if you have large assets;

  • Object file caching was implemented in MonoTouch 5.4. Some builds will be a lot faster, but others won't be (when the cache must be purged) faster (but never slower ;-). More information why this often happens here).

  • Debug builds takes longer because of symbols, running dsymutil and, since it ends up being larger, extra time to upload to devices.

  • Release builds will, by default (you can turn it off), do a IL strip of the assemblies. That takes only a bit of time - likely gained back when deploying (smaller .app) to the device.

Simulator tricks

  • Like said earlier try to avoid linking since it will take more time and will require copying assemblies (instead of symlinking them);

  • Using native libraries is slower because we cannot reuse the shared simlauncher main executable in such cases and need to ask gcc to compile one for the application (and that's slow).

Finally whenever in doubt time it! and by that I mean you can add --time --time to your project extra mtouch arguments to see a timestamp after each operation :-)

这篇关于如何加快 MonoTouch 编译时间?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆