XCode notes

  • Code generation settings are under project > Build Settings > Code generation
  • The ‘main switch’ is under LLVM GCC 4.2 > Optimization level.
  • You can pass additional flags under LLVM GCC 4.2 > Language > Other C flags
LLVM or GCC?
In the best case scenario you can pick between 3 compilers. I don’t have benchmarks; the overall feel from reading around is that GCC may generate faster apps.
Incidentally, my system stalled while building a C++ library with -O2/-O3/-Os turned on (LLVM GCC, LLVM 3.0). Adding -fno-inline-functions to Other C flags ‘fixed’ the issue. But now, that’s quite note what I wanted to do. Switching to GCC 4.2 solved the problem (the target library wraps basic maths with inlines; enforcing inlining yielded 10-15% gain).
.
Read here?
.
Thumbs up?
.
On ARMv6 ( iPhone 3GS and earlier), turning thumbs off, used to yield a dramatic performance increase on floating point calculations. Well not anymore. Put in a better way, there aren’t many ARMv6 devices around anymore ( ~3.5%? )
.
I tested an FP intensive task and observed a marginal improvement ( maybe less than 3%) with an iPad2.
.
-/O0/O1/O2/O3/Os
.
I was curious to see whether -Os (smallest/fastest) would perform significantly worse than -O3. It doesn’t – well not in my case. I observe about 4% speed increase between -O2/O3/Os and -O0 (-O0 : no optimizations).
.
I tested this on a graphic application running OpenGL ES 1.x . I measure the performance increase by looking at % usage per frame for non GPU tasks (In my case, the CPU/GPU balance is fairly even).
.
Measuring performance
.
Running with GDB or Instruments turned on will slow down your app; a crude way to measure release-grade performance may be to stick a frame rate meter right on top of your UI (now that is common practice, right?) and check with an unplugged device.
This won’t tell you where your overheads are going. For this, I still find Instruments an invaluable help.
.
I’m looking at averaging performance over one or several game sessions to get useful figures. Formal test cases can help solving specific performance issues – keeping in mind that optimization issues and level design strongly interact.
.
Stuff that looks interesting
.
.
Conclusion
.
With a background in Java and other virtual languages, I find that playing with compile time settings is, overall, almost a waste of time. Sadly (cf. the thumbs episode) it isn’t always quite so.
.
Wasting a day on belittling tweaks and flags from time to time isn’t altogether bad.