Powerkap - a Tool for Improving Energy Transparency for Software Developers on GNU/Linux (X86) Platforms
Total Page:16
File Type:pdf, Size:1020Kb
Project Report Department of Computing Imperial College of Science, Technology and Medicine PowerKap - A tool for Improving Energy Transparency for Software Developers on GNU/Linux (x86) platforms Author: Supervisor: Krish De Souza Dr. Anandha Gopalan Submitted in partial fulfilment of the requirements for the M.Eng Computing 4 of Imperial College London Contents 1 Introduction 6 1.1 Motivation . .6 1.2 Objectives . .7 1.3 Achievements . .7 2 Background 9 2.1 The relationship between power and energy. .9 2.2 Power controls on x86 platforms . .9 2.3 Improving software for power efficiency . 10 2.3.1 Algorithm . 10 2.3.2 Multithreading . 10 2.3.3 Vectorisation . 10 2.3.4 Improper sleep loops . 12 2.3.5 OS Timers . 13 2.3.6 Context aware programming . 13 2.4 Current methods of monitoring energy. 14 2.4.1 Out of Band Energy Monitor . 14 2.4.2 In-Band Energy Monitor . 14 2.4.2.1 Powertop . 15 2.4.2.2 Turbostat . 16 2.5 Related Work . 16 2.5.1 ENTRA 2012-2015 . 16 2.5.1.1 Common Assertion Language . 16 2.5.1.2 Compiler Optimisation and Power Trade-offs . 18 2.5.1.3 Superoptimization . 18 2.5.1.4 Thermal trade-off . 20 2.5.2 eProf . 20 2.5.2.1 Asynchronous vs Synchronous . 20 2.5.2.2 Profiling implementation . 21 2.5.3 Energy Formal Definitions . 21 2.5.3.1 Java Based Energy Formalism . 22 2.5.3.2 Energy Application Model . 22 2.5.4 Impact of language, Compiler, Optimisations . 22 2.5.4.1 Choice of Language . 22 2.5.4.2 Relation of execution time and energy consumption . 23 2.5.4.3 Impact of Optimisation flags . 23 2.5.4.4 Choice in Algorithm . 25 2.6 Similar Tools . 25 2.6.1 AEON . 25 2.6.2 Visual Studio . 26 2.7 Gathering Energy Measurements . 27 2.7.1 Module Specific Registers (MSR) . 27 2.7.1.1 Running Average Power Limits (RAPL) Interfaces . 27 2.7.2 Perf . 30 2.7.3 PAPI (Performance Application Programming Interface) . 30 1 2.7.4 HWMON . 30 2.7.5 Intel Powercap . 30 2.7.6 PowerAPI . 31 2.7.7 Summary . 31 2.8 Interacting with these interfaces from user space . 33 2.8.1 Sysfs . 33 2.8.2 NetLink . 33 2.8.3 Procfs . 33 3 Profiling a program 35 3.1 Initial Ideas . 35 3.2 The Profiler . 35 3.2.1 Design Ideas . 35 3.2.2 Chosen Design . 36 3.2.3 Why not use current profilers? . 38 3.2.4 Choice of energy interface . 38 3.2.4.1 Energy Consumption of CPU and Memory . 38 3.2.5 Thermal Information . 39 3.2.5.1 Battery Information . 39 3.2.5.2 DiskIO . 39 3.2.5.3 Network . 40 3.2.5.4 Choice of language . 41 3.2.6 Profiler Design . 41 3.2.6.1 Forker . 41 3.2.6.2 Profiler . 43 3.2.6.3 Sysfs, Procfs and Energy Interfaces . 43 3.2.6.4 Printer . 45 3.2.6.5 Measurement and Energy Structure . 45 3.2.6.6 Networking Script . 49 3.2.7 Implementation Details . 49 3.2.7.1 Steps taken to minimise the overhead introduced by the profiler 49 3.2.7.2 Avoiding the impact of the user environment . 51 3.3 Linux Java Energy Assessment (LJEA) plugin . 51 3.3.1 Choice of IDE . 52 3.3.2 EnergyPoints . 52 3.3.2.1 The profiling code . 52 3.3.2.2 StackTrace . 54 3.3.2.3 Energy Graphs . 54 3.3.3 Implementation Details . 54 3.3.3.1 The UI design . 54 3.3.3.2 Action Classes . 57 4 Project Evaluation 59 4.1 The hardware and methodology . 59 4.2 The Profiler . 62 4.2.1 The Results . 62 4.3 The Battery Measurements . 62 4.4 CPU Measurements . 66 2 4.4.1 Battery vs CPU measurements . 66 4.4.2 CPU Stress Test . 66 4.4.3 Desktop vs Laptop . 69 4.4.3.1 Gaming Desktop . 69 4.4.3.2 Modern Laptop . 72 4.4.4 Governor Choice . 74 4.4.5 BigBuckBunny Mplayer Test . 76 4.4.6 Choice of Algorithm . 79 4.4.7 Asynchronous vs Busywait . 81 4.4.8 Effects of Timers . 83 4.4.9 Reproducibility of the results gathered . 83 4.4.9.1 John the Ripper . 85 4.4.9.2 OpenSSL . 86 4.4.9.3 STREAM Benchmark . 86 4.4.9.4 Sunflow benchmark . 87 4.4.9.5 MPlayer . 87 4.4.9.6 Summary of Benchmark Findings . 89 4.4.10 Temperature Sensor Data . 89 4.4.11 IO Capturing Capability . 91 4.4.11.1 Ping Test . 91 4.4.12 DiskIO Capturing Technique . 94 4.4.13 Case Study: Browser Comparison . 96 4.4.14 LJEA . 100 4.4.14.1 Graphing Module . 100 4.4.14.2 Energy Trace . 100 5 Conclusion 103 6 Recommendations for Future Work 104 6.1 PowerKap . 104 6.1.1 Expanding the interfaces . 104 6.1.2 Sysfs/Procfs/Linux Interfaces . 104 6.1.3 Asynchronous computing . 104 6.1.4 Machine Learning and Model Generating . 105 6.1.5 Handling Thermal Spikes . 105 6.2 LJEA . 105 6.2.1 Introducing code suggestions . ..