Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Power Efficient Software Coding

In a typical handheld/portable embedded system device Battery life is a major concern in design of H/W, S/W and the features the device can support. From the Software programming perspective, one is aware of MIPS, Memory(Data and Program) optimized code. I am aware of the H/W Deep sleep mode, Standby mode that are used to clock the hardware at lower Cycles or turn of the clock entirel to some unused circutis to save power, but i am looking for some ideas from that point of view:

Wherein my code is running and it needs to keep executing, given this how can I write the code "power" efficiently so as to consume minimum watts?

Are there any special programming constructs, data structures, control structures which i should look at to achieve minimum power consumption for a given functionality.

Are there any s/w high level design considerations which one should keep in mind at time of code structure design, or during low level design to make the code as power efficient(Least power consuming) as possible?

like image 402
goldenmean Avatar asked Sep 15 '08 05:09

goldenmean


People also ask

Which software technique are used for energy saving?

Green Cloud Computing is an approach used to improve the utilization of computing resources those are being used in cloud computing network such as storage, servers, its application, and services and reduce energy consumption of these resources which improves power efficiency.

How can you make your Java applications more energy efficient?

Run multiple applications on shared servers If each application runs on its own server, these servers will be doing nothing useful most of the time. But they are on, and consume electricity, all of the time. By letting applications share servers, fewer servers are needed to do the same work.

How can software programs reduce the global energy consumption?

The better approach is to write the software in such a way that the hardware consumes much less electricity in the first place. If the software is developed in a neutral way so that it can run on different hardware configurations, the efficiencies can be replicated with each use of the software.

What is efficient software?

But when it comes to software development, “efficiency” is the amount of software developed or requirement divided by the number of resources used like time, effort, among other examples. In other words, efficiency usually means that waste is avoided.


2 Answers

  • Like 1800 INFORMATION said, avoid polling; subscribe to events and wait for them to happen
  • Update window content only when necessary - let the system decide when to redraw it
  • When updating window content, ensure your code recreates as little of the invalid region as possible
  • With quick code the CPU goes back to deep sleep mode faster and there's a better chance that such code stays in L1 cache
  • Operate on small data at one time so data stays in caches as well
  • Ensure that your application doesn't do any unnecessary action when in background
  • Make your software not only power efficient, but also power aware - update graphics less often when on battery, disable animations, less hard drive thrashing

And read some other guidelines. ;)

Recently a series of posts called "Optimizing Software Applications for Power", started appearing on Intel Software Blogs. May be of some use for x86 developers.

like image 70
macbirdie Avatar answered Sep 24 '22 12:09

macbirdie


Zeroith, use a fully static machine that can stop when idle. You can't beat zero Hz.

First up, switch to a tickless operating system scheduler. Waking up every millisecend or so wastes power. If you can't, consider slowing the scheduler interrupt instead.

Secondly, ensure your idle thread is a power save, wait for next interrupt instruction. You can do this in the sort of under-regulated "userland" most small devices have.

Thirdly, if you have to poll or perform user confidence activities like updating the UI, sleep, do it, and get back to sleep.

Don't trust GUI frameworks that you haven't checked for "sleep and spin" kind of code. Especially the event timer you may be tempted to use for #2.

Block a thread on read instead of polling with select()/epoll()/ WaitForMultipleObjects(). Puts stress on the thread scheuler ( and your brain) but the devices generally do okay. This ends up changing your high-level design a bit; it gets tidier!. A main loop that polls all the things you Might do ends up slow and wasteful on CPU, but does guarantee performance. ( Guaranteed to be slow)

Cache results, lazily create things. Users expect the device to be slow so don't disappoint them. Less running is better. Run as little as you can get away with. Separate threads can be killed off when you stop needing them.

Try to get more memory than you need, then you can insert into more than one hashtable and save ever searching. This is a direct tradeoff if the memory is DRAM.

Look at a realtime-ier system than you think you might need. It saves time (sic) later. They cope better with threading too.

like image 21
Tim Williscroft Avatar answered Sep 26 '22 12:09

Tim Williscroft