cellular networks and mobile computing coms 6998- 10, spring 2013

Download Cellular Networks and Mobile Computing COMS 6998- 10,  Spring  2013

Post on 24-Jan-2016

24 views

Category:

Documents

0 download

Embed Size (px)

DESCRIPTION

Cellular Networks and Mobile Computing COMS 6998- 10, Spring 2013. Instructor: Li Erran Li ( lierranli@cs.columbia.edu ) http://www.cs.columbia.edu/ ~lierranli/coms6998- 10Spring2013/ 2 /12/2013: Ebug debugging, Power Models, and Profiling. Announcements. - PowerPoint PPT Presentation

TRANSCRIPT

Narrowing the Beam: Lowering Complexity in Cellular Networks by Scaling Up

Cellular Networks and Mobile ComputingCOMS 6998-10, Spring 2013Instructor: Li Erran Li (lierranli@cs.columbia.edu)http://www.cs.columbia.edu/~lierranli/coms6998-10Spring2013/2/12/2013: Ebug debugging, Power Models, and Profiling1AnnouncementsProgramming assignment 1 will be due on FridayProgramming assignment 2 will be out today, due in 10 days. Please start early!2Cellular Networks and Mobile Computing (COMS 6998-10)2/12/13Review of Previous LectureWhat are the four major app components?Which file to declare these components?What is the mechanism for inter-component communication?Which file declares your view hierarchy?How to access your resources in your program?2/12/13Cellular Networks and Mobile Computing (COMS 6998-10)3Review of Previous Lecture (Contd)Four major app components: Activity, Service, Broadcast receiver, Content Provider.Declare app components in AndroidManifest.xmlComponents communicate using IntentView hierarchy are declared in layout.xmlAccess your resources by R.* (e.g. R.id.button1)2/12/13Cellular Networks and Mobile Computing (COMS 6998-10)4OutlineThe Rise of EbugsDebugging no-sleep EbugsMethods of Measuring Power UsagePower ModelsUsage basedSystem call trace basedProfilingConclusion5Cellular Networks and Mobile Computing (COMS 6998-10)2/12/13The Rise of Energy BugsSingle Symptom: Severe, Unexpected Battery Drain

Apps Need Not CrashNo Blue Screen Of DeathCommon Perception:Kill some apps to fixCourtesy: Pathak et al6Cellular Networks and Mobile Computing (COMS 6998-10)2/12/136User Frustration (Dialer App EBug)

Courtesy: Pathak et al7Cellular Networks and Mobile Computing (COMS 6998-10)2/12/137Crawling Internet Forums4 Online Mobile Forums1.2M Posts(~400 mobile devices;Several mobile OSes)grep power drain,battery drain, etc.39K PostsK-means1000 ClustersHumanEBug Taxonomy1.2 Mobile Bugs/Issues Repository2.Indepth AnalysisCourtesy: Pathak et al8Cellular Networks and Mobile Computing (COMS 6998-10)2/12/13Ebug TaxonomyEbugHardware23%Software35%External12%Unknown30%OSAppsNo Sleep BugLoop BugImmortality BugExternal ServiceNetwork Signal StrengthWireless HandoversCourtesy: Pathak et al9Cellular Networks and Mobile Computing (COMS 6998-10)2/12/13Hardware EBugEbugHardware23%Software35%External12%Unknown30%

Battery

Exterior Hardware Damage

SDCard

Sim Card

External HardwareCourtesy: Pathak et al10Cellular Networks and Mobile Computing (COMS 6998-10)2/12/1310Ebug TaxonomyEbug

Hardware23%Software35%External12%Unknown30%OSApps

No Sleep BugLoop BugImmortality Bug

External ServiceNetwork Signal StrengthWireless HandoversCourtesy: Pathak et al11Cellular Networks and Mobile Computing (COMS 6998-10)2/12/13OS Ebugs

IOS Version: 4.0 4.3.3 (5% posts)

2.5% postsWhy does OS Leak Energy?

Hard to infer

OS Processes

System ConfigurationCourtesy: Pathak et al12Cellular Networks and Mobile Computing (COMS 6998-10)2/12/13Apps EBug: No Sleep BugAggressive Sleeping Policies: Smartphone OSes freeze system after brief inactivity

Power encumbered Programming: Programmer has to manage sleep/wake cycle of components

No Sleep Bug: At least one component is kept awake due to mismanagementCourtesy: Pathak et al13Cellular Networks and Mobile Computing (COMS 6998-10)2/12/13External ConditionsExternal Services (5)B0d3: x = 1d4: y = 2 d5: z = xd6: x = 4 B1B2IN[B0]OUT[B0]OUT[B2]IN[B2]IN[B1]IN[exit]OUT[B1]OUT[entry] = {}Cellular Networks and Mobile Computing (COMS 6998-10)Courtesy: Jindal et al2/12/1333NoSleep Code Path DataFlow Analysis34try{

} catch (SomeException e){Print.Error ( e ); //Print Error for Debugging purposes}

wakelock.acquire ( ); //Dont let CPU sleep till I say so

wakelock.release ( ); //CPU is now free to sleepSync_Over_Network ( ); //Sync state with remote server //Can take upto a minute;throws ;exceptionexitEntry d0: wakelock = 1;Sync_over_network()B0d1: wakelock = 0;Print.error(e);B1B2exitEntry d0: wakelock.acquire();Sync_over_network()B0d1: wakelock. realease();Print.Error(e)B1B2: {d0, d1}IN[exit]: {d1}: {d0}Apply reaching definitions to NoSleep CodePathsCellular Networks and Mobile Computing (COMS 6998-10)Courtesy: Jindal et al2/12/1334ImplementationSoot ImplementationOpen source framework for analyzing java bytecode from Sable research group at McGill UniversityAdded ~2 KLOC

Runs on Java byte codeNo need for source code

35Cellular Networks and Mobile Computing (COMS 6998-10)Courtesy: Jindal et al2/12/1335Evaluation: NoSleep Code PathsTotal Apps86BUG in realityNo BUG in realityTool reports BUG (55)True Positive42False Positive13Tool reports no BUG (31)False Negative0True Negative3136500 AppsApps Manipulatingcomponents187Apps which couldbe decompiled86Find NoSleep Bugs55Cellular Networks and Mobile Computing (COMS 6998-10)Courtesy: Jindal et al2/12/1336Causes of Detected NoSleep Bugs37CategoryNumber of AppsExamplesIncorrect Wakelock Handling in Events26MyTracksIf, else + exception Paths12FacebookForgot Release4K9MailCellular Networks and Mobile Computing (COMS 6998-10)Courtesy: Jindal et al2/12/1337Common Cause of False Positives38EXITIf(caller != BLACKLISTED)Wl.release();If(caller != BLACKLISTED)Wl.acquire();ENTER

..Cellular Networks and Mobile Computing (COMS 6998-10)Courtesy: Jindal et al2/12/1338SummaryParadigm shift in power managementPower encumbered programming

NoSleep energy bugsCode paths, race, dilation

Reaching definition data flow analysisFound 30 new previously unreported bugs39Cellular Networks and Mobile Computing (COMS 6998-10)Courtesy: Jindal et al2/12/1339Future WorkComprehensive approaches to No-Sleep bug Detection: e.g. Symbolic execution

Prevention: e.g. Better abstraction for power management API

Mitigation: e.g. Runtime detection, Limiting damage of the bug40Cellular Networks and Mobile Computing (COMS 6998-10)Courtesy: Jindal et al2/12/13Measuring Power UsageApproach 1: Use power meter (offline)Buy an expensive equipment ($770)Problems:Only reports entire device energyconsumption

Approach 2 : Use built-in battery sensor (online)

41Cellular Networks and Mobile Computing (COMS 6998-10)2/12/13iOS Battery APIUse UIDevice class to obtain information and notifications aboutcharging state (property batteryState)charging level (property batteryLevel)

[[UIDevice currentDevice] setBatteryMonitoringEnabled:YES]; NSArray *batteryStatus = [NSArray arrayWithObjects: @"Battery status is unknown.", @"Battery is in use (discharging).", @"Battery is charging.", @"Battery is fully charged.", nil]; if ([[UIDevice currentDevice] batteryState] == UIDeviceBatteryStateUnknown) NSLog(@"%@", [batteryStatus objectAtIndex:0]); else { NSString *msg = [NSString stringWithFormat: @"Battery charge level: %0.2f%%\n%@", [[UIDevice currentDevice] batteryLevel] * 100, [batteryStatus objectAtIndex:[[UIDevice currentDevice] batteryState]] ]; NSLog(@"%@", msg); }

42Cellular Networks and Mobile Computing (COMS 6998-10)2/12/13Android Battery APISample updates stored in files:Current: /sys/class/power_supply/battery/batt_chg_currentVoltage: /sys/class/power_supply/battery/batt_volCapacity: /sys/class/power_supply/battery/capacity

File fcur = new File("/sys/class/power_supply/battery/batt_chg_current");if (fcur.exists()) File names are vendor dependentAccess using Android Debug Bridge (adb)platform-toolsCommand: adb shell43Cellular Networks and Mobile Computing (COMS 6998-10)2/12/13OutlineThe Rise of EbugsDebugging no-sleep BugsMethods of Measuring Power UsagePower ModelsUsage basedSystem call trace basedProfilingConclusion44Cellular Networks and Mobile Computing (COMS 6998-10)2/12/13Smartphone is Energy ConstrainedEnergy: One of the most critical issues in smartphonesLimited battery lifetime

Battery energy density onlydoubled in last 15 yrs

Smartphone capability has increased drasticallyMultiple Components: GPS, 3G, retina display, .

Courtesy: Pathak et al45Cellular Networks and Mobile Computing (COMS 6998-10)2/12/1345Towards Understanding Energy DrainKey Question: Where is energy being spent?Which component/process/thread/function(?) Courtesy: Pathak et al46Cellular Networks and Mobile Computing (COMS 6998-10)2/12/1346Generic Power Modeling

PredictionPhaseActualPowerConsumption

Power meterTriggersModelPredictedPower

ConsumptionTriggers

TrainingPhaseCourtesy: Pathak et al47Cellular Networks and Mobile Computing (COMS 6998-10)2/12/13Make fonts largeBlue color not visiblePut down LR somewhere47Smartphone Power Modeling: Utilization Based (1/3)

PredictionPhaseActualPowerConsumption

Power meterTriggersUtilizationModelPredictedPower

ConsumptionTriggersUtilization

TrainingPhaseModel = (UtilNet)* ENet + (UtilCPU)* ECPU + (UtilDisk)* EDiskLinear Regression (LR) and Superimposition Courtesy: Pathak et al48Cellular Networks and Mobile Computing (COMS 6998-10)2/12/1348Smartphone Power Modeling: Utilization Based (2/3)

Sesame paper has two optimizations: model molding, principle component analysis (PCA)PowerTutor model49Cellular Networks and Mobile Computing (COMS 6998-10)2/12/13Smartphone Power Modeling: Utilization Based (3/3)Fundamental (yet intuitive) assumption(Only active) Utilization => power consumptionSecond assumptionEnergy scales linearly with amount of workThird assumption Components power consumption add linearly

Desired FeatureWhich process/thread/function? Hard to correl

Recommended

View more >