XcodeBenchmark icon indicating copy to clipboard operation
XcodeBenchmark copied to clipboard

Build is mush faster after increasing task concurrency count (58 seconds on M1 Ultra)

Open Naituw opened this issue 3 years ago • 6 comments

I have a Mac Studio 2022, M1 Ultra, 64GB, 1TB SDD machine.

Before altering the xcodebuild's default task concurrency settings, the benchmark result is close to others' 68 seconds, but after increasing the task concurrency count with following commands, the result is about 15% better,

defaults write com.apple.dt.xcodebuild PBXNumberOfParallelBuildSubtasks 128
defaults write com.apple.dt.xcodebuild IDEBuildOperationMaxNumberOfConcurrentCompileTasks 128
defaults write com.apple.dt.Xcode PBXNumberOfParallelBuildSubtasks 128
defaults write com.apple.dt.Xcode IDEBuildOperationMaxNumberOfConcurrentCompileTasks 128

I can get 58 seconds result on the same M1 Ultra machine:

截屏2022-03-20 14 18 16

Can this be considered a valid record?

Naituw avatar Mar 20 '22 06:03 Naituw

Hi @Naituw,

Thank you for mentioning this!

While this does improve the build time on M1 Ultra, these settings look device/project-specific.

I tried both options (but used the following values 10, 20, and 40) on my M1 Pro (10 cores, 32 GB memory), and the build time has not changed 😢


By the way, does M1 Ultra have the High Power Mode?

If yes, could you please share the output of pmset -g?

Thanks!

devMEremenko avatar Mar 20 '22 17:03 devMEremenko

As far as I know, there is no High Power Mode on the Ultra.

Screen Shot 2022-03-20 at 10 44 31 AM

And pmset -g:

Screen Shot 2022-03-20 at 10 45 11 AM

mikeswanson avatar Mar 20 '22 17:03 mikeswanson

There's also a new build option for optimizing multi-core CPUs in Xcode 13.3 (see release notes) defaults write com.apple.dt.XCBuild EnableSwiftBuildSystemIntegration 1

sherwinzadeh avatar Mar 22 '22 20:03 sherwinzadeh

I am using Xcode 13.3 and testing on M1 Max 32GB ram. What I find surprising is that compilation via sh script takes 93seconds, however, when I open this project in Xcode, clean it, and building same scheme(XcodeBenchmark) as in script for any ios device arm64, the result is 67seconds. That would be as fast as Ultra, and that does not make sense, right?

jurajantas avatar Apr 03 '22 13:04 jurajantas

Hi @jurajantas

Could you confirm that you removed Derived Data before running a test in Xcode?

devMEremenko avatar Apr 03 '22 19:04 devMEremenko

@devMEremenko No, I did not. 67sec just with cleaning the project and build. So let's test it. Now I did also explicitly removed derived data, got 77seconds. Still faster than 93seconds. I don't fully understand why is that. I would expect that sh script and build from inside xcode produce same result time-wise, but that is not the case.

Also tested: defaults write com.apple.dt.XCBuild EnableSwiftBuildSystemIntegration 1 but that has no effect on the result at all. Unfortunately.

time to compile with sh script is 97sec, time to compile inside xcode 13.3 without explicitly deleting derived data is 67sec, time to compile inside xcode 13.3 with explicitly deleting derived data is 77sec.

Best I ever got with sh script was 93sec, but that is probably outlier, it most often oscillates around 97sec.

jurajantas avatar Apr 03 '22 22:04 jurajantas