简体   繁体   English

使用 Xcode 11 构建后,iOS 应用程序慢了 20 倍以上

[英]iOS App is >20x slower after building with Xcode 11

I have an app (Xcode project) that I developed for iOS 12 (with Xcode 10, Swift 4.2) which I now want to rebuild for iOS 13 using Xcode 11.我有一个为 iOS 12(使用 Xcode 10、Swift 4.2)开发的应用程序(Xcode 项目),现在我想使用 Xcode 11 为 iOS 13 重建它。

When I opened the project in Xcode 11, built and run the project, I found that my app was suddenly more than 20 times slower!当我在 Xcode 11 中打开项目,构建并运行项目时,我发现我的应用程序突然慢了 20 多倍! I checked multiple times that Release configuration was selected and that the same compile flags were used as in Xcode 10. Needless to say, compiler optimisations are maxed out, just like in Xcode 10.我多次检查是否选择了 Release 配置,并且使用了与 Xcode 10 中相同的编译标志。不用说,编译器优化已经最大化,就像在 Xcode 10 中一样。

The app uses a lot of SIMD operations ( float4 , float3 , float4x4 , etc.) and works with pointers (eg UnsafeMutablePointer<float4> ).该应用程序使用大量 SIMD 操作( float4float3float4x4等)并使用指针(例如UnsafeMutablePointer<float4> )。 I found that Xcode 11 showed me that simd types like float4 are now deprecated and typealias ed to new SIMD structs.我发现 Xcode 11 向我展示了像float4这样的 simd 类型现在已被弃用,并且类型typealiastypealias为新的SIMD结构。

Is there something obvious I should know about porting from iOS 12 to iOS 13?关于从 iOS 12 移植到 iOS 13,我应该了解一些明显的信息吗? Can this change of SIMD types be the source of such terrible decrease in performance? SIMD 类型的这种变化会成为性能下降如此可怕的根源吗? How do I restore the original speeds (iOS 13 seems like a downgrade)?如何恢复原始速度(iOS 13 似乎降级了)?

My money is on Xcode 11. Apple probably changed the compiler, or compiler settings, in a way that affected the generation of matrix math instructions.我的钱在 Xcode 11 上。Apple 可能以某种方式更改了编译器或编译器设置,从而影响了矩阵数学指令的生成。

Apple's major releases of Xcode definitely break stuff sometimes, and it can take a while for them to sort it out. Apple 的 Xcode 主要版本有时肯定会破坏一些东西,他们可能需要一段时间才能解决。

Try building for iOS 12 while using Xcode 11. Then take the same project and build it from Xcode 10.2.尝试在使用 Xcode 11 的同时为 iOS 12 构建。然后使用相同的项目并从 Xcode 10.2 构建它。

My company's app is HUGE, and build times went up by ≈3X under Xcode 11. It's quite painful.我公司的应用程序很大,在 Xcode 11 下构建时间增加了大约 3 倍。这很痛苦。 That's a different issue than execution speed, obviously, but it still tells you that there we big changes to the build process.显然,这与执行速度是不同的问题,但它仍然告诉您,我们对构建过程进行了重大更改。

After I rewrote the SIMD-heavy Swift codebase to Objective-C, the old performance was restored.在我将重 SIMD 的 Swift 代码库重写为 Objective-C 后,旧的性能得到了恢复。 Objective-C thankfully still uses the good old SIMD data types without pointless wrappers.幸运的是,Objective-C 仍然使用没有无意义包装的旧 SIMD 数据类型。

The performance correlates with changes in Swift's implementation of SIMD.性能与 Swift 的 SIMD 实现的变化相关。 In Xcode 10.1 and older, Swift used built-in SIMD data types.在 Xcode 10.1 及更早版本中,Swift 使用内置的 SIMD 数据类型。 With Xcode 10.2 (and newer), Apple added useless Object-Oriented wrapper for SIMD data types (eg float3 is typealias for SIMD4<Float> ) and operations and didn't even bother to test the performance, which made my code more than 20x slower .使用 Xcode 10.2(和更新版本),Apple 为 SIMD 数据类型(例如float3SIMD4<Float>类型float3 )和操作添加了无用的面向对象的包装器,甚至没有费心测试性能,这使我的代码超过20 倍慢

Sometimes you just need speed, don't force Protocol-oriented design where it doesn't belong to.有时您只需要速度,不要强迫面向协议的设计不属于它。

It doesn't matter if you choose to use Swift 4 or target iOS 12 in Xcode 10.2 and newer, you'll still get the same, bad SIMD performance.无论您选择在 Xcode 10.2 和更新版本中使用 Swift 4 还是针对 iOS 12,您仍然会获得相同的、糟糕的 SIMD 性能。

TL;DR: Apple messed-up pre-Swift-5 SIMD levels of performance in Xcode 10.2 and newer. TL;DR: Apple 在 Xcode 10.2和更新版本中搞砸了 Swift-5 SIMD 之前的性能水平。 Port your SIMD-heavy code to Objective-C to get good old levels performance (>20x faster in my case).将 SIMD 密集型代码移植到 Objective-C 以获得良好的旧级别性能(在我的情况下速度超过 20 倍)。 Let's hope Apple doesn't touch Objective-C or we're soon going to write in Neon assembly to get decent performance...让我们希望 Apple 不要碰 Objective-C 否则我们很快就会用 Neon 汇编编写以获得不错的性能......

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 xCode 9 iOS 11 之后应用程序中的 UI 更改 - UI change in app after xCode 9 iOS 11 在9月20日之后提交iOS应用更新-Xcode 5 - Submitting iOS app update after 20 September 13 - Xcode 5 使用Swift 4 App(Xcode 9.X)在iOS 11中缺少第一响应者吗? - Missing First Responder in iOS 11 with Swift 4 App (Xcode 9.X)? 使用 Xcode 13 构建后,应用程序在 iOS 12 及更低版本上崩溃 - App crashes on iOS 12 and below after building with Xcode 13 取消ModalViewController后,iOS App的运行速度越来越慢 - iOS App is getting slower after dismissing ModalViewController 在针对iOS 11的Xcode 9上构建应用程序,但在iPhone X上具有兼容模式 - Build app on Xcode 9 targeting iOS 11 but have compatibility mode on iPhone X 构建后XCode iOS颜色不匹配 - XCode iOS colors do not match after building 我在 xcode 12.5 模拟器 iphone 11 ios 14.5 objc[38321] 中构建应用程序时遇到此问题:Class CSAudioFileManager is implementation in both - I am getting this issue when building an app in xcode 12.5 simulator iphone 11 ios 14.5 objc[38321]: Class CSAudioFileManager is implemented in both Xamarin iOS 应用程序在 iPad 更新到 ZA3B5EBD8A1E9EBF44DD72E80DA 后显示白色空白屏幕 - Xamarin iOS app displaying white blank screen on iPad after update to Xcode 11 首次启动应用程序后如何使入职场景消失 Xcode 11 iOS 13 - How do I make onboarding scene disappear after first launching app Xcode 11 iOS 13
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM