0 Replies
      Latest reply on Nov 24, 2016 8:56 AM by Anton Petrov
      Anton Petrov Level 1 Level 1 (0 points)

        This is a continuation of my previous question: Why main thread is faster than a pthread? (https://forums.developer.apple.com/thread/66171)

         

        I have created new OpenGL ES XCode project from scratch (with rotating 3D cubes). Then I implemented a CPU heavy method which computes sqrt() for real numbers in a tight loop.

         

        First I measure its execution from the Main Thread before any OpenGL drawing begins. Then the standard logic of the default OpenGL ES application starts with two rotating 3D cubes. I do create a background NSThread and execute the same heavy method from background.

         

        Results are strange. It takes 2x time longer for background thread to complete the task when Instruments say that CPU usage for this background task is 100%. Please see this image: https://monosnap.com/file/5fTphHG52cmT1cTSJBFuSL4F8dLCP7

         

        If I disable any OpenGL ES drawing in foreground then background task takes expected amount of time: https://monosnap.com/file/uYanRMNXujUCnWpJGUg9WanoKCNZY1

         

        So how is this possible that task becomes 2x longer while still utilizing CPU for 100% ??? I would expect it will occupy 50% CPU if executed slower due to scheduling.

         

        And this is iPad Air behaviour with A7 CPU (tested on two identical devices with iOS 9.x and 10x).

        The same test for A8 does not reveal background performance decrease.

         

        Why?