How to reduce C++ code size for resolving ARM64 branch out of range error?

Hi. Recently, I added number of MethodImplOptions.AggressiveInlining attribute to my code for improving performance. But this makes my iOS build failed due to “b(l) ARM64 branch out of range (155837104 max is +/-128MB)” error.

After several googling, I found that this problem was caused by the size of c++ (IL2CPP) code being too big.

Is there any tips or documentations for resolving this problem?

Do you understand what inlining is? This is why your code got so big. Go read about inlining and you’ll see why.

Also, inlining is almost never going to give you any appreciable performance increase on mobile. Did you determine you are even compute-bound with the profiler? If you have even a moderate amount of graphics you are almost certainly fill-bound (GPU-bound generally) if you are building for a mobile target. Inlining CPU code has ZERO impact on GPU bound functions.

Remember: the key to program performance is always finding clever ways to simply NOT do all the computations that the user thinks you are doing.

1 Like

Wait… are you telling me that SimCity2000 wasn’t actually reticulating splines?

1 Like

Yes, I know what inlining do. I profiled my application and it consumes 7-10ms main thread time in single method, which makes many calls of small utility methods so I decided to add inlining attribute to it.

You say you understand what inlining does, but your original question implied you didn’t since it is obviously a big part of the problem you are asking help for. I’m really confused by this thread.

My suggestion would be to go back to your original performance issue and look for a solution other than inlining.

I admit that referring inlining makes confusion. I reverted my changes and will find other solution.