cellular networks and mobile computing coms 6998-7, spring 2014

Download Cellular Networks and Mobile Computing COMS 6998-7, Spring 2014

Post on 25-Feb-2016

32 views

Category:

Documents

5 download

Embed Size (px)

DESCRIPTION

Cellular Networks and Mobile Computing COMS 6998-7, Spring 2014. Instructor: Li Erran Li ( lierranli@cs.columbia.edu ) http://www.cs.columbia.edu/~lierranli/coms6998-7Spring2014/ 2/ 17/ 2014: Ebug debugging, Power Models, and Profiling. Review of Previous Lecture. - PowerPoint PPT Presentation

TRANSCRIPT

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

Cellular Networks and Mobile ComputingCOMS 6998-7, Spring 2014Instructor: Li Erran Li (lierranli@cs.columbia.edu)http://www.cs.columbia.edu/~lierranli/coms6998-7Spring2014/2/17/2014: Ebug debugging, Power Models, and Profiling1Review 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/17/14Cellular Networks and Mobile Computing (COMS 6998-7)Review 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/17/14Cellular Networks and Mobile Computing (COMS 6998-7)OutlineThe Rise of EbugsDebugging no-sleep EbugsMethods of Measuring Power UsagePower ModelsUsage basedSystem call trace basedProfilingConclusionCellular Networks and Mobile Computing (COMS 6998-7)2/17/14The 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 alCellular Networks and Mobile Computing (COMS 6998-7)2/17/145User Frustration (Dialer App EBug)

Courtesy: Pathak et alCellular Networks and Mobile Computing (COMS 6998-7)2/17/146Crawling 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 alCellular Networks and Mobile Computing (COMS 6998-7)2/17/14Ebug TaxonomyEbugHardware23%Software35%External12%Unknown30%OSAppsNo Sleep BugLoop BugImmortality BugExternal ServiceNetwork Signal StrengthWireless HandoversCourtesy: Pathak et alCellular Networks and Mobile Computing (COMS 6998-7)2/17/14Hardware EBugEbugHardware23%Software35%External12%Unknown30%

Battery

Exterior Hardware Damage

SDCard

Sim Card

External HardwareCourtesy: Pathak et alCellular Networks and Mobile Computing (COMS 6998-7)2/17/149Ebug TaxonomyEbug

Hardware23%Software35%External12%Unknown30%OSApps

No Sleep BugLoop BugImmortality Bug

External ServiceNetwork Signal StrengthWireless HandoversCourtesy: Pathak et alCellular Networks and Mobile Computing (COMS 6998-7)2/17/14OS 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 alCellular Networks and Mobile Computing (COMS 6998-7)2/17/14Apps 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 alCellular Networks and Mobile Computing (COMS 6998-7)2/17/14External 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-7)Courtesy: Jindal et al2/17/1432NoSleep Code Path DataFlow Analysistry{

} 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-7)Courtesy: Jindal et al2/17/1433ImplementationSoot 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

Cellular Networks and Mobile Computing (COMS 6998-7)Courtesy: Jindal et al2/17/1434Evaluation: NoSleep Code PathsTotal Apps86BUG in realityNo BUG in realityTool reports BUG (55)True Positive42False Positive13Tool reports no BUG (31)False Negative0True Negative31500 AppsApps Manipulatingcomponents187Apps which couldbe decompiled86Find NoSleep Bugs55Cellular Networks and Mobile Computing (COMS 6998-7)Courtesy: Jindal et al2/17/1435Causes of Detected NoSleep BugsCategoryNumber of AppsExamplesIncorrect Wakelock Handling in Events26MyTracksIf, else + exception Paths12FacebookForgot Release4K9MailCellular Networks and Mobile Computing (COMS 6998-7)Courtesy: Jindal et al2/17/1436Common Cause of False PositivesEXITIf(caller != BLACKLISTED)Wl.release();If(caller != BLACKLISTED)Wl.acquire();ENTER

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

NoSleep energy bugsCode paths, race, dilation

Reaching definition data flow analysisFound 30 new previously unreported bugsCellular Networks and Mobile Computing (COMS 6998-7)Courtesy: Jindal et al2/17/1438Future 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 bugCellular Networks and Mobile Computing (COMS 6998-7)Courtesy: Jindal et al2/17/14Measuring 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)

Cellular Networks and Mobile Computing (COMS 6998-7)2/17/14iOS 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); }

Cellular Networks and Mobile Computing (COMS 6998-7)2/17/14Android 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 shellCellular Networks and Mobile Computing (COMS 6998-7)2/17/14OutlineThe Rise of EbugsDebugging no-sleep BugsMethods of Measuring Power UsagePower ModelsUsage basedSystem call trace basedProfilingConclusionCellular Networks and Mobile Computing (COMS 6998-7)2/17/14Smartphone 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 alCellular Networks and Mobile Computing (COMS 6998-7)2/17/1444Towards Understanding Energy DrainKey Question: Where is energy being spent?Which component/process/thread/function(?) Courtesy: Pathak et alCellular Networks and Mobile Computing (COMS 6998-7)2/17/1445Generic Power Modeling

PredictionPhaseActualPowerConsumption

Power meterTriggersModelPredictedPower

ConsumptionTriggers

TrainingPhaseCourtesy: Pathak et alCellular Networks and Mobile Computing (COMS 6998-7)2/17/14Make fonts largeBlue color not visiblePut down LR somewhere46Smartphone Power Modeling: Utilization Based (1/3)

PredictionPhaseActualPowerConsumption

Power meterTriggersUtilizationModelPredictedPower

ConsumptionTriggersUtilization

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

Sesame paper has two optimizations: model molding, principle component analysis (PCA)PowerTutor modelCellular Networks and Mobile Computing (COMS 6998-7)2/17/14Smartphone 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 correlateModel = (UtilNet)* ENet + (UtilCPU)* ECPU + (UtilDisk)* EDiskCourtesy: Pathak et alCellular Networks and Mobile Computing (COMS 6998-7)2/17/1449(Only active) Utilization => Power Consumption

File open/delete/close/create change power stateSeveral components have