Using Order Files to Speed Up Launches and Conformance Checks
A 150MB+ app binary file, like the one in Uber‘s app, takes between 500 ms and 1 second just to be loaded into memory (measured on an iPhone 6s). Loading large files like this is just a fraction of the app‘s launch time. To put in perspective, Apple‘s recommended startup time is just 400ms. That‘s already 1-2x the recommended completed launch time without any code even executing!
By default, apps can need to read more than 75% of their binary during startup. However, with the help of order files, we can read only the functions we need during start up.
[…]
The order file instructs the linker to put functions in a specific sequence. By ordering the binary so all the startup functions are together, we now only need to load those pages.
By default, protocol conformances end up spread throughout the
__TEXT/__const
section of the binary. This is because each module in an app generates their own static binary. When they are linked into the final app, the binaries are placed side by side. Data from different modules is not interleaved in the executable.[…]
We can apply the idea of using order files to group data onto as few pages as possible to conformances, and generate an order file that moves all conformances onto their own pages.
[…]
In our tests, co-locating the conformances like this resulted in an over 20% decrease in protocol conformance lookup time on an iPhone 7 running iOS 15!
You can generate an order file that has this result by parsing the linkmap file.
Previously:
- The Evolution of Facebook’s iOS App Architecture
- The Surprising Cost of Checking Protocol Conformances in Swift
- Faster App Launching in iOS 15 and Monterey
3 Comments RSS · Twitter · Mastodon
What is going on in a glorified taxi summoning app that needs 150MB of binary code?
This is super interesting! It does seem like Emerge is focused on selling their own CI solution to large enterprises, though.
Have you found any open-source examples of using order files that Indie developers could replicate?
Order files are really old stuff, and for the most part haven't been considered necessary for many years.
That these folks are reaching back to that is quite an indictment of their inability to achieve performance in more sensible ways.