Blog post: New -Osize optimization mode

Hi,

there is a new blog post about the new -Osize optimization mode:

Enjoy reading!

Erik

10 Likes

Just read the new post and this graphs raised some questions:

We have seen that using -Osize reduces code size from 5% to even 30% for some projects.

But what about performance? This completely depends on the project. For most applications the performance hit with -Osize will be negligible, i.e. below 5%. But for performance sensitive code -O might still be the better choice.

  • What tests exactly were conducted to draw this conclusion?
  • How can developers reproduce these results?
  • Should developers restructure their apps to move certain kinds of code into frameworks that can use a different optimization setting?

Also wondering if Xcode could just run both modes in any of the following configurations:

  • serially
  • async
  • execute the selected optimization, then run the other in the background

Then developers could receive some kind of telemetry / data about how their code would perform / be sized differently on an ongoing basis.

What tests exactly were conducted to draw this conclusion?

This is the result of running a defined set of benchmarks/project, which includes for example the standard swift benchmarks and source compatibility projects

How can developers reproduce these results?

I'm not sure if this is the right question, because it completely depends on the project. Developers should try the new mode and see how it works for their projects.

Should developers restructure their apps to move certain kinds of code into frameworks that can use a different optimization setting?

This could be done, but I think in most of the cases it is not necessary.

Also wondering if Xcode could just run both modes in any of the following configurations:

An Interesting idea.

I've tried this function in my app. It's a big app with a huge amount of code. There is the results:


Result: no difference.

Is that for the executable itself or the entire app bundle? Because the optimization level doesn't affect the bundled standard library or overlays.

These screenshots has been taken from App Store Connect in the Function section where you can find estimated app sizes.

I tried the -Osize flag today on our app but no change in the size.27%20AM

I have marked the IPA file with WithO and WithOSize in the screenshot.

Can you please make a new thread for this? This announcement post isn't the right place for technical troubleshooting relating to the feature (and just imagine how flooded the post would be, if that were the case!)

2 Likes