Monday, May 31, 2021

How Uber Deals With Large iOS App Size

Milind Chabbi, Jin Lin, and Raj Barik (via Hacker News):

In the following article we will describe how we reduced the code size of Uber’s iOS Rider app by 23% using advanced compiler technologies. The ideas discussed herein also translated to 17% and 19% code size savings in the Uber Driver and Uber Eats iOS apps, respectively.


High-level language and runtime features related to reference counting and memory allocation are common causes of the most frequently repeated patterns.


Generic function instantiations and closures specialized at their call sites result in highly similar, long sequences of machine instructions.


Listing 7 above shows a common idiom recommended by Swift to use the try expressions to deserialize JSON data and assign to properties of a class. In this example, the class MyClass contains 118 properties, which are initialized from a JSON object. The initialization happens via try expressions, which throw Error if the property is not found in the incoming JSON object. If any one of the try expressions fails, all the previously created properties have to be released. When this code is lowered into LLVM IR and then into the machine code, it leads into N blocks of codes where the Nth block and N-1th bock have N-1 same instructions, N-1th and N-2th block have N-2 same instructions and so on — which is a O(N2) replicated code.

They’re contributing the work back to LLVM.


Comments RSS · Twitter

Leave a Comment