Partager via


Hot Games, Cool Phones

Energy efficiency has always been important for mobile applications. Until recently the main motivation for this has been to make battery last as long as possible, but as phones have become faster and got new capabilities heating has become another - often even more - important reason to be careful with power consumption.

I work in the team responsible for performance tuning for Microsoft’s Lumia phones. For the last half year or so I have been closely involved with Lumia 950 and 950 XL and learned a lot of the subtle complexities of achieving good performance without heating the device too much.  We have analyzed literally hundreds of apps and seen many good and some not so good approaches to performance in mobile. In this series of blog posts I try to summarize the best practices we have learned and introduce some of the tools we have found useful. I will mostly focus in games but the same principles apply to any mobile app that relies on complex computation or graphics.

Setting the Scene

Modern mobile phone chipsets (like Qualcomm’s Snapdragon 808 and 810 used in Lumia 950) are indeed very powerful and capable. However, great performance also means that they can consume a lot of electricity and eventually this power turns into heat. Unlike a PC, phones do not have fans or other active cooling systems so the only way to get this extra energy out is to let it conduct to environment via phone’s surface. The small size and fact that phones are usually held in hand (so that must not become too hot) sets very strict limits for amount of heat that can be transferred. In practice, we are talking about roughly 3-5 watts, depending on phone dimensions, surface material and environmental factors.

The S810 has 8 CPU cores and a very powerful GPU. If all of these are used at full speed simultaneously the chipset alone produces more heat that a phone can dissipate, and you need to count in also heat produced by display, radios, camera, battery discharge (or charging) and other factors. All this available performance is great if your application needs processing in short bursts: the operations can be completed quickly, application feels responsive and the phone can cool afterwards. But games are played for minutes or even hours at once so the device power consumption must be somehow adapted to a sustainable level.

When Windows operating system detects that the phone is getting too hot it takes several actions to force power consumption down. These include dimming display, switching some CPU cores off, forcing rest of CPU cores and GPU to lower clock frequency and lowering the battery charging current, among others. Unfortunately, many of these can be visible to user in a negative way and disturb gameplay.

After all, the operating system does not know what is important for your game so it cannot do much else to save power than slow the whole system down. You as game developer can do much better job in both saving energy and especially using it for the things that matter by adapting game resource usage to a sustainable level.

There are many best practices and techniques that can be applied to achieve this. The list below just introduces some of the most common ones; everyone of the items is worth a separate blog post and I hope to cover many of them in future.

Doing things efficiently

Optimization should not be considered only as a way to speed up an application that is too slow. It also reduces power consumption in an app that runs fast enough as operations complete in shorter time or can be run at lower clock frequency (which can mean lower voltage and less leakage current). All the normal optimization guidance applies here. Look for hot spots that consume lots of CPU cycles.  Consider writing performance critical parts of your game in native C++. Try to reduce the number of draw calls as GPU driver overhead can contribute a significant part of CPU load in a game. And so on. Systematic and frequent profiling is your friend here.

Multithreading can decrease power consumption significantly. Usually it is more efficient to run two or more CPU cores at low frequency than one core at maximum speed. Also, modern mobile chipsets like the Snapdragon 810 have a mixture of CPU cores optimized for energy efficiency and speed; splitting heavy computation to many threads makes it possible to run it quickly using the efficient little cores.

For tasks that can be heavily parallelized GPU might be even better solution for minimizing energy consumption. For example, we use it extensively in Lumia camera and imaging applications (many of these algorithms are available to others via Lumia Imaging SDK). Earlier mobile chipsets were limited to DirectX feature level 9.3 (i.e. vertex and pixel shaders) but the newest ones support same features as desktop GPUs including compute shaders.

Using resources sparingly for things that matter

Forget the PC way of thinking that HW performance stays constant. In mobile world you can do either very fast sprints or run for long time at constant but lower speed. But if you try to run at maximum speed for long time you will be in trouble.

Games have had to cope always with computers with very different performance. The same strategies can be used to adjust resource usage in mobile to a sustainable level. Especially reducing frame rate or rendering resolution can be very effective; for example, Lumia 950 has screen resolution of 2560x1440 pixels and rendering at this resolution to a small phone screen is usually overkill for a game. In our experience 720p seems to be often a sweet spot for fast paced 60 fps games.

The special challenge in mobile is to figure out what performance level is sustainable as this depends not only on the device model but also on environmental factors like temperature, network quality and whether the phone is being charged. My advice here is to do testing in many circumstances. And giving user easy options for changing rendering settings.

Conclusion

The latest generation of mobile phones is quite far from the idealized computer with simple and predictable performance characteristics that I studied while attending  university. We in both Microsoft phones and operating system teams have tried our best to simplify things for you, the app developer , and we will continue that work in future releases. Nevertheless, being a good citizen in this brave new mobile world requires your app to respect the realities of these small devices.

I hope you gained some insight of the system level problematics and some ideas how to adapt application to work well in different devices and environments. In future posts I will dive deeper into these as well as into tools that help you understand how your app interacts with the system.