250 likes | 418 Views
PowerSpy: Fine Grained Power Profiler. Kutty S Banerjee Emmanuel Agu. Mobile Devices – Energy Crisis. Rate of Growth of CPU Memory Disk Space Wireless Transfer Speed Far Greater than that of Battery Energy !!.
E N D
PowerSpy:Fine Grained Power Profiler Kutty S Banerjee Emmanuel Agu
Mobile Devices – Energy Crisis • Rate of Growth of • CPU • Memory • Disk Space • Wireless Transfer Speed Far Greater than that of Battery Energy !! Powerful Change Part1:Batteries and Possible Alternatives for the Mobile Market. IEEE Pervasive Computing,October-December 2003 (Vol. 2, No. 4)
PowerSpy Helps answer the following questions: • Which Thread consumes How much power? • What procedures in each thread are invoked? • Which I/O Device consumes how much power? • <Application initiated I/O>
PowerSpy Features: • Non Intrusive of Kernel Source • Non Intrusive of Application Source • `Software-Only’ • Accurate Billing sans OS activities • Windows 2000,XP,Server 2003
PowerSpy Usage • Installation: • Powerspy.sys (kernel mode driver) • Installation Requires Administrative Privilege • Powerspy.exe (user mode application) • Windows XP (run checked build) • Boot option `/debug’ flag set • Usage: • powerspy devenv.exe (Microsoft Visual Studio) • Produces `report.dat’ . Results next…
Thread and I/O Profiling Thread Power Usage Device Power Usage
Application Profiled • OpenVRML • VRML Browser (disk heavy) • Graphics appln. • Mozilla • I/O heavy (Network heavy) • Windows Media Player • I/O heavy (Network heavy)
Power Measurement Approaches • Measure Power Loss - Application Runtime • Hardware (PowerScope) • Software (PowerSpy) • Break Application Runtime ->Finite Elements • Power Consumption Finitie Elements Known prior • Sum to get total power
PowerScope Approach • Hardware multimeter measures current, voltage. • Samples PC, PID, ISR • Analysis offline
OS Context Switches • Time of execution of thread=quantum • Need to monitor `current thread of execution’ as often as quantum period • What about preemption? We’ll see next… System Architecture
Pseudo Code Algorithm if(measurePowerOn_==true) { if(currentThread_!=SchedulerThread()) measurePowerOn_=false; tempPower_=instPower_; instPower_=measurePower(); totalPower_=tempPower_-instPower_; } else { if(currentThread_==SchedulerThread()) { measurePowerOn_=true; instPower_=measurePower(); } }
I/O Device Monitor • Question ->Do you check all I/O Devices live in system ? • Push on stack question until Implementation!! • Question -> What if thread does overlapped I/O with `n’ devices? • Limitation of PowerSpy. We cannot distinguish b/w them!!
What about Procedures? • Two Approaches? • Invasive – Add stub of code in executable in each procedure for all modules • Stub merely records itself!! • NonInvasive – Simply check PC at sampled intervals. (POWERSPY APPROACH) • Use Module Export/Import Table • Base Loading Address For address to module,procedure translation!!
Windows Scheduling Policy • Preemptive Priority driven. • Get current thread running (last running) PsGetCurrentThreadId (kernel mode call) • To monitor Scheduler • Need to be at same priority • Must be non preemptable by Scheduler • DPC (Deferred Procedure Calls) execute at same priority as Windows Scheduler called `Dispatcher’ • Timed DPC running at 10ms=roughly equal to Windows standard quantum. • Every 10ms, DPC preempts Scheduler and executes algorithm. • 10ms NOT GUARANTEED EXACT!!Windows is NOT REAL TIME!!
Monitor I/O Operations • All user mode appln do I/O by Win32 API • Win32 API forwards request to I/O Manager • I/O Manager creates IRP (I/O Request Packet) and forwards to appropriate Device Driver. • For every thread( user mode or kernel mode), internal OS data structure (undocumented) -> ETHREAD. • ETHREAD contains list of IRPs thread currently blocked on. • IRP contains name of I/O Devices. • Therefore, thread to I/O Device located!! • ETHREAD maintained in `ntoskrnl.exe’. Not Exported!! Therefore need `debug symbols’. Hence need to run `checked build of Windows’. • Have access to Internet!! Symbol Server of Microsoft at http://msdl.microsoft.com
Limitations • Thread Blocked on I/O Device DOES NOT mean I/O Device currently executing its order!! • I/O Device has internal queue. • Thread 4 blocked and billed but not actually serviced!! Excess Power billed!! • Procedures NOT CALL GRAPH!!
Reference • Inside Windows 2000 • Programming Applications for MS Windows • Windows Loader – Matt Pietrik • www.sysinternals.com • www.osronline.com • Powerscope • Windows DDK