为什么X codebuild和X code 4.2这么慢? [英] Why are xcodebuild and Xcode 4.2 so slow?

查看:150
本文介绍了为什么X codebuild和X code 4.2这么慢?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的一个比较大的项目(code的几十千行)x code 4.2,这是可怕的慢。编辑是好的,但每当我试图编译该项目(在X code,或者在命令行x codebuild),我的机器(四核i7的MacBook Pro,4 GB RAM)抓取停顿。我注意到,启动X codebuild后直接,它产生超过8铛流程,而不启动真正的编译过程。没有X codebuild输出是迄今为止看到粗壮。我试过<一个href=\"http://stackoverflow.com/questions/5417835/how-to-modify-the-number-of-parallel-compilation-with-x$c$c\">reducing并行构建进程的数量,但还是很多的铛过程都在开始推出。该项目采用6或7的直接依赖外部项目,拥有120可能的源文件。在X code 3.2的项目中使用可以迅速的编译。发生了什么?我怎样才能使X code快速一遍吗?

I am using Xcode 4.2 on a relatively large project (a few ten thousand lines of code) and it is horribly slow. Editing is ok, but whenever I try to compile the project (in Xcode, or with xcodebuild on the command line), my machine (quad core i7 MacBook Pro, 4 GB RAM) crawls to a halt. I have noticed that directly after starting xcodebuild, it spawns more than 8 clang processes, without the "real" compile processes starting. No xcodebuild output is so far seen on stout. I've tried reducing the number of parallel build processes, but still lots of clang processes are launched at the beginning. The project uses 6 or 7 direct dependent external projects and has maybe 120 source files. Under Xcode 3.2 the project used to be compiled very quickly. What's happening? And how can I make Xcode fast again?

推荐答案

我们中的大多数都有三个主要选项:

Most of us have three primary options:


  • 恢复于X code 3的日常开发。

  • 在它扔更多的硬件。

  • 更改项目的结构和应用的大规模开发技巧(即使20-30 KSLOC并不大)。

最简单的办法是恢复到XC3。是的,XC4需要的很多的比XC3以上;内存,CPU和磁盘空间和I / O。您必须确定您的最大问题是降低它会影响您的金额。

The easiest solution is revert to Xc3. Yes, Xc4 requires a lot more than Xc3; memory, CPU, and disk space and I/O. You will have to determine where your biggest problems are to reduce the amount it affects you.

我最近买了新MBP的两倍物理核心和物理内存的两倍,升级到狮子,并在同一时间升级XC4。在编译时间的没有的改善,但大部分剩下的实际上是慢,更耗资源。这不是在所有什么人会从IDE也不允许多个打开的项目,还采用了统一的工作区视图期待。

I recently bought a new MBP with twice the physical cores and twice the physical memory, upgraded to Lion and upgraded Xc4 at the same time. The compilation times did improve, but much of the rest is actually slower, and far more resource hungry. That's not at all what one would expect from an IDE which also disallows multiple open projects and also uses a unified workspace view.

以上所有以下几类翻了一番我的硬件需求,这一举措狮子+ XC4:

The move to Lion + Xc4 more than doubled my hardware demands in all of the following categories:

内存

4GB现在太少了使用XC4和狮子最平凡的项目。你仍然可以减少这一点。我有8GB和10GB在我的主要2台,XC4消耗的这一切很容易(但我的项目比你的更复杂,除非你写reeaeaaaally排长队)。不管怎么说,你可以减少这种问题:

4GB is now too little for most nontrivial projects using Xc4 and Lion. You can still reduce this. I have 8GB and 10GB on my main 2 machines, Xc4 consumes it all quite easily (but my projects are more complex than yours, unless you write reeaeaaaally long lines). Anyways, You can reduce this problem by:


  • 购买更多的内存。

  • 如果您正在构建以x code大项目禁用索引。这样也可以的减半的X code'S内存消耗。

  • 运行X code在32位。这并不适用于所有人的一个选项,因为它会在较大的项目超过4 GB。

  • (再次)降低构建过程的数量。

  • 重新启动X $ C $Ç常(它没有这样做了很好的工作后自己清理)。

  • 使用铛为你的编译器。在比苹果的GCC 4.2内存一般少用铿锵的实例。

  • 减负不经常改变依赖的目标。例如:你不需要每天重建第三方库在大多数情况下

  • Buying more memory.
  • Disable indexing if you are building out huge projects in Xcode. This can halve Xcode's memory consumption.
  • Running Xcode in 32 bit. This is not an option for everyone, because it will exceed 4 GB in larger projects.
  • Reduce the number of build processes (again).
  • Restarting Xcode often (It doesn't do a very good job cleaning up after itself).
  • Use clang as your compiler. Clang instances in general use less memory than Apple's GCC 4.2.
  • Offload dependent targets which do not change often. Example: You will not need to rebuild third party libraries daily in most cases.

CPU

X $ C $的C 4采用了全新的(更准确)完成解析器。

Xcode 4 uses a new (more accurate) completion parser.


  • 削减了你的从属图,和依赖。这是很容易使用的OBJ-C,因为每一个对象 - 比如是一个指针。例:删除松散的框架依赖从你的头文件包含

  • 分离你的依赖和模块正常。开发库,但尽量让他们相当小,要知道,他们将增加的依赖关系。例如:我带领一个项目,一个开发增加了一个小功能(应用程序的不到1%),但由于依赖关系的数量就需要(如Three20然后几个以上),最终的可执行的二进制规模扩大了一倍(和生成时间上去,解析器有很多工作要做)。这其中大部分是没有必要的功能 - 他们不能被剥夺,因为他们是objc符号

  • 减少翻译计数,如果可能的话。

  • 优化你如何使用preFIX头。你可以分享,并可以在没有更好的理由创建。这有利于编译器比IDE多。

  • 最小化内存使用情况。 GC的工作(包括所有NSObject的allocs)消耗了较大的项目的CPU使用的1/3,但它仍然花费了大量时间收集时,其堆是巨大的。

  • 使用外部文本编辑器和VC客户端。 pretty明显,因为XC4显示SBBOD而经常在大型项目。

  • 最小化语言的复杂性。在复杂顺序:C,ObjC,C ++,ObjC ++。更复杂的翻译,时间越长,将采取解析和编译你的源代码,尤其是当你的依赖性很高。如果你可以轻松地设置语言障碍在你的依赖,这样做。

  • 您可以通过<禁止code感索引code>默认 (也减少了内存的需求)。

硬盘

这可以是一个速度/大小平衡。

This can be a speed/size balance.


  • 购买更快一(例如SSD)。

  • 清理和减少你的头的依赖关系。

  • 使用RAM磁盘,如使RAM磁盘

  • 购买更多的内存。随着XC4消费量,它结束了在大型项目中经常换出到磁盘上。

  • 优化您建立适当使用PCH文件。这并不总是显而易见的方向:我没有使用过他们好几年的大型项目

  • 清除出临时文件X code和仪器留下,<一个href=\"http://stackoverflow.com/questions/7776073/how-can-i-$p$pvent-x$c$c-4-2-from-filling-my-boot-drive-with-$p$pamble-pch-files\">they是巨大的。在某些情况下,你可以将它们保存在自定义的位置。如果他们确实消耗几十GB的和你的build目录是一样的引导目录,那么你会做你的工作盘少了很多,定期清理它们。

  • Buy a faster one (e.g. SSD).
  • Cleanup and minimize your header dependencies.
  • Use a RAM Disk, such as Make RAM Disk.
  • Buy more memory. With the amount Xc4 consumes, it ends up swapping out to disk often in large projects.
  • Optimize your builds to use pch files appropriately. This is not always the obvious direction: I have not used them for several years in large projects.
  • Clear out the temp files Xcode and Instruments leave behind, they can be huge. In some cases, you can save them in customized locations. If they do consume tens of GB and your build dir is the same as your boot dir, then you will make your disk work a lot less by cleaning them up regularly.

构建


  • 在XC4,X $ C $平行于X code cbuild现在增加一倍(默认情况下单独的构建迪尔斯)的工作。在XC3,默认是建立到同一目标。验证设置 - X code会做一吨多余的建筑,如果你允许它(每个工作区/配置例如一个目标,而不是XC3的扁蓄模型)

  • In Xc4, xcodebuild parallel to Xcode now doubles the work (separate build dirs by default). In Xc3, the default was to build to the same destination. Verify your settings - Xcode will do a ton of redundant building, if you allow it (e.g. one target per workspace/config, rather than Xc3's flat build model).

或仅填写一个抽屉四核MacMinis和使用,作为一个专门的或分布式建设者。

Or just fill a drawer with quad core MacMinis and use that as a dedicated or distributed builder.

文件中的错误

(言自明)

这篇关于为什么X codebuild和X code 4.2这么慢?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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