Search Unity

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

Discussion in 'Scripting' started by Kichang-Kim, Aug 11, 2020.

  1. Kichang-Kim

    Kichang-Kim

    Joined:
    Oct 19, 2010
    Posts:
    1,011
    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?
     
  2. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    38,689
    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.
     
    Last edited: Aug 11, 2020
    Joe-Censored likes this.
  3. PraetorBlue

    PraetorBlue

    Joined:
    Dec 13, 2012
    Posts:
    7,909
    Wait... are you telling me that SimCity2000 wasn't actually reticulating splines?
     
    Kurt-Dekker likes this.
  4. Kichang-Kim

    Kichang-Kim

    Joined:
    Oct 19, 2010
    Posts:
    1,011
    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.
     
  5. Joe-Censored

    Joe-Censored

    Joined:
    Mar 26, 2013
    Posts:
    11,847
    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.
     
    Last edited: Aug 12, 2020
  6. Kichang-Kim

    Kichang-Kim

    Joined:
    Oct 19, 2010
    Posts:
    1,011
    I admit that referring inlining makes confusion. I reverted my changes and will find other solution.