Applications f or Android use only one processor core: truth or fiction?

For a decade, our computers have been equipped with multi-core processors, and now this is the norm. First there were two cores, then four, and today companies like Intel and AMD offer hig h-end desktop processors with 6 or 8 cores. It’s the same story with processors in smartphones. Dual-core energy-efficient processors from ARM appeared about 5 years ago, followed by 4, 6 and 8-core processors on the ARM architecture. Meanwhile, there is a difference between 6- and 8-core desktop processors from Intel and AMD and 6- and 8-core processors based on the ARM architecture. Most processors in the second category with more than 4 cores use at least two different core designs.

c

With a few exceptions, in general, an eight-core ARM processor uses a system known as Heterogeneous Multi-Processing (HMP), in which ‘heterogeneity’ means unequal cores. In a modern 64-bit processor, this means that a Cortex-A57 or Cortex-A72 cluster is used in conjunction with a Cortex-A53 cluster. The A72 is a high performance core while the A53 is more energy efficient. This combination is known as big.LITTLE because it combines the ‘big’ cores (Cortex-A72) with the ‘small’ Cortex-A53. This is very different from the 6- and 8-core PC processors from Intel and AMD, as the issue of power consumption in this case is not as relevant as on a mobile device.

When multi-core processors first hit the PC, there were many questions about the advantages of a dual-core processor over a single-core processor. Dual-core 1.6GHz processor is ‘better’ than single-core 3.2GHz processor or not? What Windows? Will it be able to maximize the potential of a dual-core processor? And what about games? Do they really go better with a dual-core processor? And do you need to do this in a special way when writing applications so that they can use additional kernels? And so on.

About multiprocessing

These questions are quite natural, and, of course, the same questions arise about multi-core processors in smartphones. Before looking at the ‘relationship’ between multi-core processors in smartphones and Android apps, let’s take a quick look at multi-core technology in general.

Computers are great at solving one problem. Need to know the first hundred million primes? No question, the computer will calculate them all day, over and over again. But then when you need it to do two things, for example, identify the same primes with the GUI running at the same time so that you can do web browsing at the same time, it turns out to be a little more complicated.

Without going deep into particular, there is a technology known as preemptive multitasking, which allows you to split the available CPU time across multiple tasks. A ‘piece’ of CPU time is allocated to one task, a ‘piece’ to another, and so on. Operating systems such as Linux, Windows, OS X, and Android are based on the piece of technology known as the scheduler and , which process will get the next ‘piece’ of processor time.

d

Schedulers can be written in different ways, on the server the scheduler can be sharpened to give priority to I / O tasks like writing to disk or reading from the network, while in the desktop version it will pay more attention to the responsiveness of the graphical interface.

When there is more than one core, the scheduler can set aside a slice of processor 0 for one process, while another process gets a slice of processor 1. So the scheduler and dual-core processor allow two tasks to run simultaneously. The more cores, the more processes can run concurrently.

You’ve already noticed that the scheduler is good at dividing CPU resources between various tasks, such as calculating primes, starting the desktop, using the browser. However, a single process, such as calculating primes, can be split across multiple cores. Or not?

Some tasks are sequential in and of themselves. To bake a pie, you need to break eggs, add flour, knead the dough, and so on. You cannot put the pie in the oven until the dough is ready. So even if you have two chefs in your kitchen, you won’t be able to save time on one of the tasks. There is an unbreakable order and sequence of actions. It is possible to solve several problems at once and entrust one cook with a pie and another with slicing salad, but tasks with a predefined order of actions will not benefit from either a dual-core or even a 12-core processor.

Not all tasks are as described above. Many operations that a computer performs can be divided into several independent tasks. For this to happen, the main process must create another process and outsource some of the work. For example, if, using the algorithm for calculating prime numbers, you do not use the previous results, do not use the Sieve of Eratosthenes, you can divide the work into two parts. One process calculates the first 50 million numbers and the second calculates the second 50 million. A quad-core processor allows you to divide the work into 4 parts, and so on.

But in order for all this to work, the program must be written in a special way. In other words, it should be designed to divide the load into smaller parts, rather than do it entirely. There are various programming technologies for this, and you’ve probably heard words like ‘single-threaded’ or ‘multi-threaded’. These words mean programs that are written to perform one task (single-threaded, all together) or programs with individual tasks (threads), which can be separately assigned their own processor time. To summarize, a single-threaded program does not benefit from running on a multi-core processor, while a multi-threaded program does not.

e

So we almost got to the point, and before we get to Android we need one more thing. How the OS is written depends on the fact that some executable programs can be multithreaded in the first place. Often, separate parts of the OS are independent tasks in and of themselves, and when your program does input and output or displays something on the screen, it can be a separate process on the system. Using what’s called non-blocking calls can introduce multithreading into a program without creating threads on purpose.

This is an important aspect for Android. One of the system-level tasks in architecture Android is SurfaceFlinger. This is the basis of the graphical display process in Android. This is a separate task that needs to be allocated CPU time. Which means that certain graphical operations involve starting a new process for execution.

Android

Because of processes like SurfaceFlinger Android, it benefits from multi-core processors without the need for inherently multithreaded special applications. And since a lot of things happen in the background, like sync and widgets, Android benefits from multicore and as a whole. This OS, as expected, has the ability to create multi-threaded applications. For more information, see the Processes and Threads section of the documentation Android. There are also multithreaded examples from Google, and there is also an interesting article from Qualcomm on programming Android applications for multi-core processors.

However, the question remains whether most Android applications are single-threaded and thus only use one core. The question is important, because if so, then you may have a multi-core monster from the world of smartphones, but in fact its processor will work like a dual-core one!

There may also be a question regarding the difference between a 4- and 8-core processor. In PCs or servers, eight-core processors are built so that the chip consists of the same cores. For most eight-core ARM-based processors, there are high-performance and energy-efficient core options. And the point is that the more energy efficient cores are for more secondary tasks, and the high-performance cores are for the heavy weight category. However, just like the desktop version, these kernels can be used simultaneously.

The main thing to remember here is that the eight-core big.LITTLE has eight cores for energy efficiency reasons, not performance.

Testing

In Android it is possible to get information about how many cores the system has used in the processor. For the savvy, this can be seen in the / proc / stat file. A tool has been created that takes information about kernel usage in Android while the application is running. To improve its efficiency and reduce performance degradation, information is collected only when the application is active. Data analysis is done offline.

Using this unnamed tool, for the test, we ran a series of different types of applications (games, web browsing, etc.) on a phone with a quad-core processor Qualcomm Snapdragon 801, and then on a phone with an eight-core processor Qualcomm Snapdragon 615. When comparing the data, we got the graphs of processor usage. Let’s start with a simple example. Here is a graph of the Snapdragon 801 cores when using the Chrome browser:

f

The graph shows how many cores were used Android and the browser. It does not show how much the kernel was involved, only whether it was actually used. If Chrome were single-threaded, one would expect one or two cores to be involved, maybe a third or fourth on occasion. But we don’t see this. On the contrary, four cores are involved, and only from time to time the number of cores used drops to 2. In the test with browsing, the loaded pages were not read, this would not affect the processor usage. Pages just loaded, and you could go to new ones.

Here is a graph that shows how much each core was involved. This is an average graph (in real life, a huge number of lines introduces confusion). This means that at least peaks of use are shown. For example, the peak in this graph is over 90%, but the initial data showed that some cores reached 100% many times. Nevertheless, here you can clearly see what was happening.

g

And what about the eight-core processor? Does he demonstrate the same scheme? No, as seen in the graph below. Seven cores are constantly used, at the peaks it reaches 8, sometimes it drops to 6 and 4.

h

Also, the average utilization of each core shows that the scheduler behaved differently, since the Snapdragon 615 is a big.LITTLE processor.

i

You can see that two or three cores work harder than others, but one way or another all cores are involved. We see how the big.LITTLE architecture can transfer threads from kernel to kernel depending on the workload. And don’t forget that the point of additional cores is energy efficiency, not performance.

We can safely say that the use of only one core by the ‘android’ is a myth. This was to be expected given that Chrome, like Android, was designed to be multi-threaded, just like it was for desktops.

Other applications

So this was designed by multithreaded Chrome, but what about other apps? Here’s what happened in brief

Gmail – on a 4-core phone, we got equal shares of 2 and 4 cores. However, the average kernel utilization did not rise above 50% – as expected for a relatively light application. The octa-core processor gave jumps from 4 to 8 cores, but the average core utilization was less than 35%.

YouTube – On a 4-core processor, only 2 cores were used, averaging less than 50% load. On an 8-core, there are basically 4 cores, at times it grew to 6 and dropped to 3. The load of cores averaged only 30%. Interestingly, the scheduler preferred large kernels and almost never used small ones.

Riptide GP2 – 4 Cores – The Qualcomm processor used two cores most of the time, with very few other two. And in the 8-core version, 6-7 cores were sequentially used, but only three did the main work.

Templerun 2 – This game is a clearer example of the single-threading problem than the other applications in the benchmark. The 8-core version involved 4-5 cores in series with peaks up to 7. And only one core did the hard work. On a phone with a 4-core Qualcomm Snapdragon 801, two cores shared the load approximately equally, while the other two got very little. On a phone with a 4-core processor from MediaTek, the load was distributed between all four cores. This shows how different schedulers and different cores dramatically change how the processor is used.

Here is a selection of graphs for clarity. The 8-core idle schedule has been added as a starting point.

Octa-core device, active screen, user does not perform any actions:

1

YouTube launched on a 4-core machine:

2

YouTube running on an 8-core machine:

3

TempleRun2 running on a 4-core machine:

4

TempleRun2 running on a 4-core machine with a processor MediaTek:

5

Gmail running on a 4-core machine:

6

Gmail running on an 8-core machine:

7

Riptide GP2 running on a 4-core machine:

8

Riptide GP2 running on an 8-core machine:

9

An interesting result was obtained in AnTuTu on an 8-core processor.

a

As you can see, the last part of the test loads all cores completely. It is clear that the benchmark artificially creates a high load, and since all cores are working at full capacity, chipsets with a large number of cores win. This was not the case with conventional applications. Benchmarks artificially inflate the performance advantage of eight-core devices (more than energy efficiency).

Why light applications use 8 cores?

If you look at apps like Gmail, you will notice an interesting phenomenon. On a 4-core apparatus, the use of cores is equally divided between two and four cores, and on an 8-core apparatus, between four and eight. How can Gmail run on 2-4 cores on a 4-core phone and require at least four cores on an 8-core phone? Some kind of nonsense.

The point is again that the cores in phones with big.LITTLE are not equal. In reality, we see that the scheduler uses LITTLE cores, and when the load rises, their big brothers come into play. After some time working together, the LITTLE kernels go to rest. When the load is reduced, the opposite is true. Of course, all this happens very quickly, thousands of times a second. Take a look at the graph comparing the use of big and LITTLE cores in Epic Citadel.

b

Look, the big kernels are used first, and the LITTLE kernels are inactive. Then, around the 12 second mark, the big kernels start to be used less and the LITTLE kernels wake up. At 20 seconds, the big cores increase activity again, and LITTLE decreases it to almost zero. This can be seen at the 30, 45 and 52 seconds marks. At these points, the number of cores used fluctuates. For example, in the first 10 seconds, only 3 or 4 cores are used (these are big cores), and in 12 seconds this number reaches 6, then drops again to 4, etc. This is how big.LITTLE works. This processor is not built like a PC processor. Additional kernels allow the scheduler to select the correct kernels for different actions.

All tests that were carried out showed that there was not a single real application that would use all 8 cores one hundred percent. It should be so.

Summing up

First of all, we emphasize that these tests do not reflect the performance of the phones, but only show whether the applications Android are using multiple cores. The advantages or disadvantages of multicore or the big.LITTLE chipset are not disclosed, as well as the performance of application parts on two cores when they are used by 25%, using one core by 50%, and so on.

Then, tests have not yet been performed for the Cortex-A53 / Cortex-A57 or Cortex-A53 / Cortex-A72 circuit. Qualcomm Snapdragon 615 has a 4-core 1.7 GHz ARM Cortex A53 cluster and a quad-core 1.0 GHz A53 cluster.

The scan interval in this statistic is about a third of a second, i.e. about 330 milliseconds. If the core signals 25% utilization in these 300 milliseconds and the second core signals the same, the graph will show that both cores are used at 25% at the same time, while one core can be used 25% within 150 milliseconds, the same with the second. This means that the kernels were used sequentially and not at a time. Currently, the test does not suggest a smaller interval.

That said, Android applications are obviously able to take advantage of multi-core processors and big.LITTLE processors allow the scheduler to choose the best combination of cores for the task at hand. Therefore, if you still hear from people “But the smartphone does not need 8 cores!”, You just have to shrug your hands in despair. These people do not understand anything.

Rate article
About smartphones.
Add a comment