SlideShare a Scribd company logo
1 of 63
Download to read offline
Finding Sensor Related Energy Black
Holes In Smartphone Applications
Yepang Liu1, Chang Xu2, S.C. Cheung1
1The Hong Kong University of Science and Technology
2State Key Lab for Novel Software, Nanjing University
IEEE PerCom 2013
San Diego, California, USA
25+ billion downloads
(September 2012)
650,000+ applications
(September 2012)
Smartphone apps
1/29
Energy Problem
Full Network access
Frequent sensor usage 3D rendering
2/29
Energy Problem
Full Network access
Frequent sensor usage 3D rendering
Annual density improvement
very slow (6%)
Energy Inefficiency
2/29
Energy Problem
• Problem magnitude
– Thousands of apps are NOT energy efficient
– Millions of users affected and complained
– Phone batteries drained in a few hours
• Major reasons
– Hardware management burden (e.g., sensors)
– Lack of dedicated QA, short time to market
– Difficulty in problem diagnosis
3/29
(Pathak et al. Hotnets 2011)
Motivation
• What are the common causes of energy
problems?
• Can we distill patterns to enable automated
diagnosis?
4/29
Our Work
Investigation
•Diagnosis difficulty
•Common causes
Evaluation
•Effectiveness
•Efficiency
Automated
diagnosis
•State exploration
•Energy efficiency
analysis
5/29
Investigated Subjects
7/29
10
33
136
SourceForge
GitHub
Google Code
0 40 80 120 160
App Availability Distribution
174 popular open-source Android apps
Investigated Subjects
Source Repository
(24 affected apps)
Bug reports
Comments on bug
reports
Bug fixing patches
Revision commit logs
7/29
10
33
136
SourceForge
GitHub
Google Code
0 40 80 120 160
App Availability Distribution
174 popular open-source Android apps
Observations
8/29
• Reproduce problem (extensive testing, energy profiling)
• Figure out root cause (instrumentation, runtime logging)
Diagnosis difficulty
Observations
• Reproduce problem (extensive testing, energy profiling)
• Figure out root cause (instrumentation, runtime logging)
Diagnosis difficulty
• Common causes (10/24): improper use of sensors
Problem causes
8/29
Patterns
• Sensor listener misusage
9/29
R
Registration
(All executions)
Patterns
• Sensor listener misusage
9/29
R
“Always un-register sensor listener before program exits!”
UnregistrationRegistration
U (All executions)
Patterns
• Sensor listener misusage
9/29
R
“Always un-register sensor listener before program exits!”
UnregistrationRegistration
U (All executions)
• Sensory data underutilization
R U (Execution 1)
Location data well utilized
Patterns
• Sensor listener misusage
9/29
R
“Always un-register sensor listener before program exits!”
UnregistrationRegistration
U (All executions)
• Sensory data underutilization
R U (Execution 1)
Location data well utilized
R R U (Execution 2)
Poor utilization
Sensory Data Underutilization
9/29
R U (Execution 1)
Location data well utilized
R R U (Execution 2)
Poor utilization
“GeoHashDroid should slow down sensor update significantly if
nothing besides the notification bar is listening.”
(GeoHashDroid Issue 24)
“GPS sensor should be timely disabled if location data are used
to update an invisible map.”
(Osmdroid Issue 53)
Approach Overview (GreenDroid)
• Dynamic analysis (on top of Java PathFinder)
• Goal: Simple, scalable, and effective
11/29
Approach Overview (GreenDroid)
• Dynamic analysis (on top of Java PathFinder)
• Goal: Simple, scalable, and effective
11/29
Java PathFinder
Sensory Data
Utilization Analyzer
Runtime
Controller
Application
Under Analysis
*.class
*.xml
Analysis
Report
•Application state
•Energy inefficiency
• Dynamic analysis (on top of Java PathFinder)
• Goal: Simple, scalable, and effective
11/29
Java PathFinder
Sensory Data
Utilization Analyzer
Runtime
Controller
Application
Under Analysis
*.class
*.xml
Analysis
Report
•Application state
•Energy inefficiency
Input Output
Approach Overview (GreenDroid)
• Dynamic analysis (on top of Java PathFinder)
• Goal: Simple, scalable, and effective
11/29
Java PathFinder
Sensory Data
Utilization Analyzer
Runtime
Controller
Application
Under Analysis
*.class
*.xml
Analysis
Report
•Application state
•Energy inefficiency
1. Event generation
2.State exploration
Approach Overview (GreenDroid)
• Dynamic analysis (on top of Java PathFinder)
• Goal: Simple, scalable, and effective
11/29
Java PathFinder
Sensory Data
Utilization Analyzer
Runtime
Controller
Application
Under Analysis
*.class
*.xml
Analysis
Report
•Application state
•Energy inefficiency
1. Sensory data tracking
2.Utilization analysis
3.Sensor listener usage monitoring
Approach Overview (GreenDroid)
• Dynamic analysis (on top of Java PathFinder)
• Goal: Simple, scalable, and effective
• Major Challenges
– App execution and state exploration in Java PathFinder
– Sensory data identification and utilization analysis (no metrics)
11/29
Java PathFinder
Sensory Data
Utilization Analyzer
Runtime
Controller
Application
Under Analysis
*.class
*.xml
Analysis
Report
•Application state
•Energy inefficiency
Approach Overview (GreenDroid)
12/29
General Java programs
(explicit control flow)
• Absence of explicit control flow (event-driven)
• Heavy reliance on native system libs (platform specific)
• Essentially interactive (valid user input generation)
App Execution in JPF (Problems)
12/29
General Java programs
(explicit control flow)
Android programs
(event-driven)
VS
Class C
• Handler 1
• Handler 2
• …
• Handler n
Class B
• Handler 1
• Handler 2
• …
• Handler n
Class A
• Handler 1
• Handler 2
• …
• Handler n
Loosely coupled handlers
• Absence of explicit control flow (event-driven)
• Heavy reliance on native system libs (platform specific)
• Essentially interactive (valid user input generation)
App Execution in JPF (Problems)
12/29
Applications
Frameworks
Libs Dalvik VM
Linux Kernel
Android Platform
Scheduled by
• Absence of explicit control flow (event-driven)
• Heavy reliance on native system libs (platform specific)
• Essentially interactive (valid user input generation)
App Execution in JPF (Problems)
Implicit control flow
12/29
Applications
Frameworks
Libs Dalvik VM
Linux Kernel
Android Platform
Scheduled by
Mostly
native!
• Absence of explicit control flow (event-driven)
• Heavy reliance on native system libs (platform specific)
• Essentially interactive (valid user input generation)
App Execution in JPF (Problems)
Implicit control flow
12/29
• Absence of explicit control flow (event-driven)
• Heavy reliance on native system libs (platform specific)
• Essentially interactive (valid user input generation)
App Execution in JPF (Problems)
• Absence of explicit control flow (event-driven)
• Heavy reliance on native system libs (platform specific)
• Essentially interactive (valid user input generation)
App Execution in JPF (Solutions)
13/29
Android Specs Temporal rules
(AEM Model)
Handler scheduling policies
Temporal rules
(AEM Model)
Input: (1) app execution history
(2) Newly received event
Output: next handler to execute
Decision procedure
Concretization
14/29
• Absence of explicit control flow (event-driven)
• Heavy reliance on native system libs (platform specific)
• Essentially interactive (valid user input generation)
App Execution in JPF (Solutions)
14/29
Identify native methods
Native method
• Absence of explicit control flow (event-driven)
• Heavy reliance on native system libs (platform specific)
• Essentially interactive (valid user input generation)
App Execution in JPF (Solutions)
14/29
Identify native methods
Create stubs (native peers)
Native peer
Native method
• Absence of explicit control flow (event-driven)
• Heavy reliance on native system libs (platform specific)
• Essentially interactive (valid user input generation)
App Execution in JPF (Solutions)
14/29
Identify native methods
Create stubs (native peers)
Implement logics
Native peer
Native method
• Absence of explicit control flow (event-driven)
• Heavy reliance on native system libs (platform specific)
• Essentially interactive (valid user input generation)
App Execution in JPF (Solutions)
15/29
Application configurations
Activity 1
……
Activity n
GUI
Layout
GUI
Layout
Association
Association
GUI Layout Analysis (Static)
• Absence of explicit control flow (event-driven)
• Heavy reliance on native system libs (platform specific)
• Essentially interactive (valid user input generation)
App Execution in JPF (Solutions)
15/29
• Absence of explicit control flow (event-driven)
• Heavy reliance on native system libs (platform specific)
• Essentially interactive (valid user input generation)
App Execution in JPF (Solutions)
JPFJVM
Call stack
onResume()
Listener
VM events
Waiting for user interaction?
Event sequence generation (Dynamic)
…
Click Long press
Sequence length bounded!
State Exploration
• State changes as the app continuous handles events (user
events, system events etc.)
16/29
(Execution 1)
(Execution 2)
(Execution k)
… …
Event State
State Exploration
• State changes as the app continuous handles events (user
events, system events etc.)
16/29
(Execution 1)
(Execution 2)
(Execution k)
… …
Event State
How to analyze sensory data utilization?
Are they well utilized?
Sensory Data Tracking & Identification
17/29
Data enter app
Transformed and
consumed
Data leave app
Data Lifecycle:
Sensory Data Tracking & Identification
17/29
Data enter app
Transformed and
consumed
Data leave app
Data Lifecycle:
• Taint the mock sensory data
Taint source
Sensory Data tracking process:
Sensory Data Tracking & Identification
17/29
Data enter app
Transformed and
consumed
Data leave app
Data Lifecycle:
• Taint the mock sensory data
Taint source
• Tracking and pinpointing sensory data
• Record sensory data usages
Taint propagation
Sensory Data tracking process:
Sensory Data Tracking & Identification
17/29
Data enter app
Transformed and
consumed
Data leave app
Data Lifecycle:
• Taint the mock sensory data
Taint source
• Tracking and pinpointing sensory data
• Record sensory data usages
Taint propagation
• Terminate tainting
• Compute sensory data utilization
Taint sink
Sensory Data tracking process:
Taint Propagation Policy
18/29
Index Bytecode Instruction Taint Propagation Rule
1 Const-op C T(stack[0]) = Ø
2 Load-op index T(stack[0]) = T(localVarindex)
3 LoadArray-op arrayRef, index T(stack[0]) = T(arrayRef) ⋃ T(arrayRef [index])
4 Store-op index T(localVarindex) = T(stack’[0])
5 StoreArray-op arrayRef, index T(arrayRef [index]) = T(stack’[0])
6 Binary-op T(stack[0]) = T(stack’[0]) ⋃ T(stack’[1])
7 Unary-op T(stack[0]) = T(stack’[0])
8 GetField-op index T(stack[0]) = T(stack’[0].instanceField) ⋃ T(stack’[0])
9 GetStatic-op index T(stack[0]) = T(ClassName.staticField)
10 PutField-op index T(stack’[1].instanceField) = T(stack’[0])
1 PutStatic-op index T(ClassName.staticField) = T(stack’[0])
12 Return-op(non-void) T(callerStack[0]) = T(calleeStack’[0])
Example
19/29
float x = values[0];
float y = values[1];
float z = values[2];
float g = GRAVERTIY_EARTH;
float acc = (x*x + y*y + z*z) / (g*g);
Compute acceleration
Input: accEvent from accelerometer
float[] values = accEevent.values;
Example
19/29
float x = values[0];
float y = values[1];
float z = values[2];
float g = GRAVERTIY_EARTH;
float acc = (x*x + y*y + z*z) / (g*g);
Compute acceleration
Input: accEvent from accelerometer
float[] values = accEevent.values;Tainted Data
accEvent
Example
19/29
float x = values[0];
float y = values[1];
float z = values[2];
float g = GRAVERTIY_EARTH;
float acc = (x*x + y*y + z*z) / (g*g);
Compute acceleration
Input: accEvent from accelerometer
float[] values = accEevent.values;Tainted Data
accEvent
values (Rule 8)
Field access
Example
19/29
float x = values[0];
float y = values[1];
float z = values[2];
float g = GRAVERTIY_EARTH;
float acc = (x*x + y*y + z*z) / (g*g);
Compute acceleration
Input: accEvent from accelerometer
float[] values = accEevent.values;Tainted Data
accEvent
values (Rule 8)
x (Rule 3)
y (Rule 3)
z (Rule 3)
Array element
access
Example
19/29
float x = values[0];
float y = values[1];
float z = values[2];
float g = GRAVERTIY_EARTH;
float acc = (x*x + y*y + z*z) / (g*g);
Compute acceleration
Input: accEvent from accelerometer
float[] values = accEevent.values;Tainted Data
accEvent
values (Rule 8)
x (Rule 3)
y (Rule 3)
z (Rule 3)
acc (Rule 6)
Arithmetic computation
Sensory data usage measurement
20/29
Usage Accumulationusage(s,d) = weight(i,s)×rel(i)
i∈Instr(s,d)
∑
Sensory data usage measurement
20/29
(Execution 1)
(Execution 2)
State1 State2
State3
Osmdroid issue 53:
Usage Accumulationusage(s,d) = weight(i,s)×rel(i)
i∈Instr(s,d)
∑
Sensory data usage measurement
21/29
dataProcess()
broadcast()
updateMap()
Location data dataProcess()
broadcast()
updateMap()
Location data
writeToDB()
State 2(map invisible) State 3
dataProcess()
broadcast()
updateMap()
Location data
State 1
1 2 (Execution 1)
(Execution 2)3
Sensory data usage measurement
21/29
dataProcess()
broadcast()
updateMap()
Location data dataProcess()
broadcast()
updateMap()
Location data
writeToDB()
State 2(map invisible) State 3
dataProcess()
broadcast()
updateMap()
Location data
State 1
+n
+n
+n
+n
+n
+0
+n
+n
+n
+n
1 2 (Execution 1)
(Execution 2)3
Usage Comparison
22/29
1 2 (Execution 1)
(Execution 2)3
Index Usage Utilization coefficient
State 1 3n 0.75
State 2 2n 0.5
State 3 4n 1
utilization_coefficient(s,d) =
usage(s,d)
Maxs'∈S,d'∈D (usage(s',d'))
Usage Comparison
22/29
1 2 (Execution 1)
(Execution 2)3
Index Usage Utilization coefficient
State 1 3n 0.75
State 2 2n 0.5
State 3 4n 1
utilization_coefficient(s,d) =
usage(s,d)
Maxs'∈S,d'∈D (usage(s',d'))
Report
• Event sequence
• Sensory data usage details
Usage Comparison
22/29
1 2 (Execution 1)
(Execution 2)3
Index Usage Utilization coefficient
State 1 3n 0.75
State 2 2n 0.5
State 3 4n 1
utilization_coefficient(s,d) =
usage(s,d)
Maxs'∈S,d'∈D (usage(s',d'))
Report
• Event sequence
• Sensory data usage details
Sensor listener misusage
Evaluation
• RQ1 (Effectiveness): Can GreenDroid effectively
detect energy problems?
• RQ2 (Efficiency): How much overhead does
GreenDroid incur? Is GreenDroid practical enough
to handler real-world large subjects?
23/29
Subjects
24/29
Application
Basic Information
Revision No. Lines of code Downloads Availability
Osmdroid 750 18,091 10K—50K Google Play
Zmanim 322 4,893 10K—50K Google Play
Omnidroid 863 12,427 1K—5K Google Play
DroidAR 204 18,106 1K—5K Google Code
Recycle-locator 68 3,241 1K—5K Google Play
GPSLogger 15 659 1K—5K Google Code
Effectiveness
25/29
Energy Problem Problem type New problem
OsmDroid Issue 53 Sensory data underutilization No
Zmanim Issue 50 Sensory data underutilization No
Zmanim Issue 56 Sensory data underutilization No
DroidAR Issue 27 Sensor listener misusage No
Recycle-Locator Issue 33 Sensor listener misusage No
Omnidroid Issue 179 Sensory data underutilization Yes
GPSLogger Issue 7 Sensory data underutilization Yes
GreenDroid found seven real problems. Five problems are
caused by poor sensory data utilization. Two problems are
caused by sensor listener misusage.
Energy Problem Problem type New problem
OsmDroid Issue 53 Sensory data underutilization No
Zmanim Issue 50 Sensory data underutilization No
Zmanim Issue 56 Sensory data underutilization No
DroidAR Issue 27 Sensor listener misusage No
Recycle-Locator Issue 33 Sensor listener misusage No
Omnidroid Issue 179 Sensory data underutilization Yes
GPSLogger Issue 7 Sensory data underutilization Yes
Effectiveness
25/29
First five problems were confirmed before our experiments.
The Last two were new problems found by GreenDroid
Effectiveness
25/29
“Completely true, Omnidroid does suck up way more energy
than necessary. I'd be happy to accept a patch in this regard”.
(Omnidroid issue 179)
Energy Problem Problem type New problem
OsmDroid Issue 53 Sensory data underutilization No
Zmanim Issue 50 Sensory data underutilization No
Zmanim Issue 56 Sensory data underutilization No
DroidAR Issue 27 Sensor listener misusage No
Recycle-Locator Issue 33 Sensor listener misusage No
Omnidroid Issue 179 Sensory data underutilization Yes
GPSLogger Issue 7 Sensory data underutilization Yes
Efficiency
26/29
Application
Analysis Overhead
Explored states Time (seconds) Space (MB)
Osmdroid 120,189 151 591
Zmanim 54,270 110 205
Omnidroid (12 KLOC) 52,805 220 342
DroidAR (18 KLOC) 91,170 276 217
Recycle-locator 114,709 43 153
GPSLogger 58,824 35 149
Thousands of states explored in a few minutes. Memory
Consumption well supported by modern PCs even without
optimization.
Efficiency
26/29
Application
Analysis Overhead
Explored states Time (seconds) Space (MB)
Osmdroid (18 KLOC) 120,189 151 591
Zmanim 54,270 110 205
Omnidroid (12 KLOC) 52,805 220 342
DroidAR (18 KLOC) 91,170 276 217
Recycle-locator 114,709 43 153
GPSLogger 58,824 35 149
Large subjects’ analysis overhead suggests that GreenDroid is
practical enough to handle real world Android applications.
Discussion
• Limitations
– Imprecision in AEM model and native lib modeling
– Complex inputs generation (e.g., password)
– Limited subjects in evaluation
• Future work
– Validate the effectiveness with more subjects
– Investigate energy problems caused by other reasons (e.g.,
network)
28/29
Conclusion
29/29
Thank you!

More Related Content

Similar to Finding sensor related energy black holes in smartphone applications

Characterizing and detecting performance bugs for smartphone applications
Characterizing and detecting performance bugs for smartphone applicationsCharacterizing and detecting performance bugs for smartphone applications
Characterizing and detecting performance bugs for smartphone applicationsSchool of Engineering, HKUST
 
Towards Software Sustainability Guides for Industrial Software Systems
Towards Software Sustainability Guides for Industrial Software SystemsTowards Software Sustainability Guides for Industrial Software Systems
Towards Software Sustainability Guides for Industrial Software SystemsHeiko Koziolek
 
Fragility of Layout-based and Visual GUI test scripts: an assessment study on...
Fragility of Layout-based and Visual GUI test scripts: an assessment study on...Fragility of Layout-based and Visual GUI test scripts: an assessment study on...
Fragility of Layout-based and Visual GUI test scripts: an assessment study on...Riccardo Coppola
 
Monitoring and Instrumentation Strategies: Tips and Best Practices - AppSphere16
Monitoring and Instrumentation Strategies: Tips and Best Practices - AppSphere16Monitoring and Instrumentation Strategies: Tips and Best Practices - AppSphere16
Monitoring and Instrumentation Strategies: Tips and Best Practices - AppSphere16AppDynamics
 
Next Generation Vulnerability Assessment Using Datadog and Snyk
Next Generation Vulnerability Assessment Using Datadog and SnykNext Generation Vulnerability Assessment Using Datadog and Snyk
Next Generation Vulnerability Assessment Using Datadog and SnykDevOps.com
 
OORPT Dynamic Analysis
OORPT Dynamic AnalysisOORPT Dynamic Analysis
OORPT Dynamic Analysislienhard
 
Auto-completing Bug Reports for Android Applications
Auto-completing Bug Reports for Android ApplicationsAuto-completing Bug Reports for Android Applications
Auto-completing Bug Reports for Android ApplicationsKevin Moran
 
Presentation for use
Presentation   for usePresentation   for use
Presentation for usebolu804
 
Code, ci, infrastructure - the gophers way
Code, ci, infrastructure - the gophers wayCode, ci, infrastructure - the gophers way
Code, ci, infrastructure - the gophers wayAlex Baitov
 
redpill Mobile Case Study (Salvation Army)
redpill Mobile Case Study (Salvation Army)redpill Mobile Case Study (Salvation Army)
redpill Mobile Case Study (Salvation Army)Peter Presnell
 
SourceWarp AST 2023.pdf
SourceWarp AST 2023.pdfSourceWarp AST 2023.pdf
SourceWarp AST 2023.pdfJulian Thome
 
LIFT: A Legacy InFormation retrieval Tool
LIFT: A Legacy InFormation retrieval ToolLIFT: A Legacy InFormation retrieval Tool
LIFT: A Legacy InFormation retrieval ToolKellyton Brito
 
Ecological Impact of Native vs. Cross-Platform Mobile Apps: a Preliminary Study
 Ecological Impact of Native vs. Cross-Platform Mobile Apps: a Preliminary Study Ecological Impact of Native vs. Cross-Platform Mobile Apps: a Preliminary Study
Ecological Impact of Native vs. Cross-Platform Mobile Apps: a Preliminary StudyOlivier Le Goaër
 
Presentation for slideshare
Presentation   for slidesharePresentation   for slideshare
Presentation for slidesharebolu804
 
Automated Discovery of Performance Regressions in Enterprise Applications
Automated Discovery of Performance Regressions in Enterprise ApplicationsAutomated Discovery of Performance Regressions in Enterprise Applications
Automated Discovery of Performance Regressions in Enterprise ApplicationsSAIL_QU
 
Switch! Recommending Artifacts Needed Next Based on Personal and Shared Context
Switch! Recommending Artifacts Needed Next Based on Personal and Shared ContextSwitch! Recommending Artifacts Needed Next Based on Personal and Shared Context
Switch! Recommending Artifacts Needed Next Based on Personal and Shared Contextalexandersahm
 

Similar to Finding sensor related energy black holes in smartphone applications (20)

Characterizing and detecting performance bugs for smartphone applications
Characterizing and detecting performance bugs for smartphone applicationsCharacterizing and detecting performance bugs for smartphone applications
Characterizing and detecting performance bugs for smartphone applications
 
Towards Software Sustainability Guides for Industrial Software Systems
Towards Software Sustainability Guides for Industrial Software SystemsTowards Software Sustainability Guides for Industrial Software Systems
Towards Software Sustainability Guides for Industrial Software Systems
 
Dynamix IoT 2012
Dynamix IoT 2012Dynamix IoT 2012
Dynamix IoT 2012
 
Fragility of Layout-based and Visual GUI test scripts: an assessment study on...
Fragility of Layout-based and Visual GUI test scripts: an assessment study on...Fragility of Layout-based and Visual GUI test scripts: an assessment study on...
Fragility of Layout-based and Visual GUI test scripts: an assessment study on...
 
Monitoring and Instrumentation Strategies: Tips and Best Practices - AppSphere16
Monitoring and Instrumentation Strategies: Tips and Best Practices - AppSphere16Monitoring and Instrumentation Strategies: Tips and Best Practices - AppSphere16
Monitoring and Instrumentation Strategies: Tips and Best Practices - AppSphere16
 
Next Generation Vulnerability Assessment Using Datadog and Snyk
Next Generation Vulnerability Assessment Using Datadog and SnykNext Generation Vulnerability Assessment Using Datadog and Snyk
Next Generation Vulnerability Assessment Using Datadog and Snyk
 
OORPT Dynamic Analysis
OORPT Dynamic AnalysisOORPT Dynamic Analysis
OORPT Dynamic Analysis
 
Auto-completing Bug Reports for Android Applications
Auto-completing Bug Reports for Android ApplicationsAuto-completing Bug Reports for Android Applications
Auto-completing Bug Reports for Android Applications
 
Presentation for use
Presentation   for usePresentation   for use
Presentation for use
 
Ch01lect1 et
Ch01lect1 etCh01lect1 et
Ch01lect1 et
 
Improve Android System Component Performance
Improve Android System Component PerformanceImprove Android System Component Performance
Improve Android System Component Performance
 
Code, ci, infrastructure - the gophers way
Code, ci, infrastructure - the gophers wayCode, ci, infrastructure - the gophers way
Code, ci, infrastructure - the gophers way
 
redpill Mobile Case Study (Salvation Army)
redpill Mobile Case Study (Salvation Army)redpill Mobile Case Study (Salvation Army)
redpill Mobile Case Study (Salvation Army)
 
SourceWarp AST 2023.pdf
SourceWarp AST 2023.pdfSourceWarp AST 2023.pdf
SourceWarp AST 2023.pdf
 
LIFT: A Legacy InFormation retrieval Tool
LIFT: A Legacy InFormation retrieval ToolLIFT: A Legacy InFormation retrieval Tool
LIFT: A Legacy InFormation retrieval Tool
 
Ecological Impact of Native vs. Cross-Platform Mobile Apps: a Preliminary Study
 Ecological Impact of Native vs. Cross-Platform Mobile Apps: a Preliminary Study Ecological Impact of Native vs. Cross-Platform Mobile Apps: a Preliminary Study
Ecological Impact of Native vs. Cross-Platform Mobile Apps: a Preliminary Study
 
Presentation for slideshare
Presentation   for slidesharePresentation   for slideshare
Presentation for slideshare
 
Automated Discovery of Performance Regressions in Enterprise Applications
Automated Discovery of Performance Regressions in Enterprise ApplicationsAutomated Discovery of Performance Regressions in Enterprise Applications
Automated Discovery of Performance Regressions in Enterprise Applications
 
Switch! Recommending Artifacts Needed Next Based on Personal and Shared Context
Switch! Recommending Artifacts Needed Next Based on Personal and Shared ContextSwitch! Recommending Artifacts Needed Next Based on Personal and Shared Context
Switch! Recommending Artifacts Needed Next Based on Personal and Shared Context
 
RFCs for HDF5 and HDF-EOS5 Status Update
RFCs for HDF5 and HDF-EOS5 Status UpdateRFCs for HDF5 and HDF-EOS5 Status Update
RFCs for HDF5 and HDF-EOS5 Status Update
 

Finding sensor related energy black holes in smartphone applications

  • 1. Finding Sensor Related Energy Black Holes In Smartphone Applications Yepang Liu1, Chang Xu2, S.C. Cheung1 1The Hong Kong University of Science and Technology 2State Key Lab for Novel Software, Nanjing University IEEE PerCom 2013 San Diego, California, USA
  • 2. 25+ billion downloads (September 2012) 650,000+ applications (September 2012) Smartphone apps 1/29
  • 3. Energy Problem Full Network access Frequent sensor usage 3D rendering 2/29
  • 4. Energy Problem Full Network access Frequent sensor usage 3D rendering Annual density improvement very slow (6%) Energy Inefficiency 2/29
  • 5. Energy Problem • Problem magnitude – Thousands of apps are NOT energy efficient – Millions of users affected and complained – Phone batteries drained in a few hours • Major reasons – Hardware management burden (e.g., sensors) – Lack of dedicated QA, short time to market – Difficulty in problem diagnosis 3/29 (Pathak et al. Hotnets 2011)
  • 6. Motivation • What are the common causes of energy problems? • Can we distill patterns to enable automated diagnosis? 4/29
  • 7. Our Work Investigation •Diagnosis difficulty •Common causes Evaluation •Effectiveness •Efficiency Automated diagnosis •State exploration •Energy efficiency analysis 5/29
  • 8. Investigated Subjects 7/29 10 33 136 SourceForge GitHub Google Code 0 40 80 120 160 App Availability Distribution 174 popular open-source Android apps
  • 9. Investigated Subjects Source Repository (24 affected apps) Bug reports Comments on bug reports Bug fixing patches Revision commit logs 7/29 10 33 136 SourceForge GitHub Google Code 0 40 80 120 160 App Availability Distribution 174 popular open-source Android apps
  • 10. Observations 8/29 • Reproduce problem (extensive testing, energy profiling) • Figure out root cause (instrumentation, runtime logging) Diagnosis difficulty
  • 11. Observations • Reproduce problem (extensive testing, energy profiling) • Figure out root cause (instrumentation, runtime logging) Diagnosis difficulty • Common causes (10/24): improper use of sensors Problem causes 8/29
  • 12. Patterns • Sensor listener misusage 9/29 R Registration (All executions)
  • 13. Patterns • Sensor listener misusage 9/29 R “Always un-register sensor listener before program exits!” UnregistrationRegistration U (All executions)
  • 14. Patterns • Sensor listener misusage 9/29 R “Always un-register sensor listener before program exits!” UnregistrationRegistration U (All executions) • Sensory data underutilization R U (Execution 1) Location data well utilized
  • 15. Patterns • Sensor listener misusage 9/29 R “Always un-register sensor listener before program exits!” UnregistrationRegistration U (All executions) • Sensory data underutilization R U (Execution 1) Location data well utilized R R U (Execution 2) Poor utilization
  • 16. Sensory Data Underutilization 9/29 R U (Execution 1) Location data well utilized R R U (Execution 2) Poor utilization “GeoHashDroid should slow down sensor update significantly if nothing besides the notification bar is listening.” (GeoHashDroid Issue 24) “GPS sensor should be timely disabled if location data are used to update an invisible map.” (Osmdroid Issue 53)
  • 17. Approach Overview (GreenDroid) • Dynamic analysis (on top of Java PathFinder) • Goal: Simple, scalable, and effective 11/29
  • 18. Approach Overview (GreenDroid) • Dynamic analysis (on top of Java PathFinder) • Goal: Simple, scalable, and effective 11/29 Java PathFinder Sensory Data Utilization Analyzer Runtime Controller Application Under Analysis *.class *.xml Analysis Report •Application state •Energy inefficiency
  • 19. • Dynamic analysis (on top of Java PathFinder) • Goal: Simple, scalable, and effective 11/29 Java PathFinder Sensory Data Utilization Analyzer Runtime Controller Application Under Analysis *.class *.xml Analysis Report •Application state •Energy inefficiency Input Output Approach Overview (GreenDroid)
  • 20. • Dynamic analysis (on top of Java PathFinder) • Goal: Simple, scalable, and effective 11/29 Java PathFinder Sensory Data Utilization Analyzer Runtime Controller Application Under Analysis *.class *.xml Analysis Report •Application state •Energy inefficiency 1. Event generation 2.State exploration Approach Overview (GreenDroid)
  • 21. • Dynamic analysis (on top of Java PathFinder) • Goal: Simple, scalable, and effective 11/29 Java PathFinder Sensory Data Utilization Analyzer Runtime Controller Application Under Analysis *.class *.xml Analysis Report •Application state •Energy inefficiency 1. Sensory data tracking 2.Utilization analysis 3.Sensor listener usage monitoring Approach Overview (GreenDroid)
  • 22. • Dynamic analysis (on top of Java PathFinder) • Goal: Simple, scalable, and effective • Major Challenges – App execution and state exploration in Java PathFinder – Sensory data identification and utilization analysis (no metrics) 11/29 Java PathFinder Sensory Data Utilization Analyzer Runtime Controller Application Under Analysis *.class *.xml Analysis Report •Application state •Energy inefficiency Approach Overview (GreenDroid)
  • 23. 12/29 General Java programs (explicit control flow) • Absence of explicit control flow (event-driven) • Heavy reliance on native system libs (platform specific) • Essentially interactive (valid user input generation) App Execution in JPF (Problems)
  • 24. 12/29 General Java programs (explicit control flow) Android programs (event-driven) VS Class C • Handler 1 • Handler 2 • … • Handler n Class B • Handler 1 • Handler 2 • … • Handler n Class A • Handler 1 • Handler 2 • … • Handler n Loosely coupled handlers • Absence of explicit control flow (event-driven) • Heavy reliance on native system libs (platform specific) • Essentially interactive (valid user input generation) App Execution in JPF (Problems)
  • 25. 12/29 Applications Frameworks Libs Dalvik VM Linux Kernel Android Platform Scheduled by • Absence of explicit control flow (event-driven) • Heavy reliance on native system libs (platform specific) • Essentially interactive (valid user input generation) App Execution in JPF (Problems) Implicit control flow
  • 26. 12/29 Applications Frameworks Libs Dalvik VM Linux Kernel Android Platform Scheduled by Mostly native! • Absence of explicit control flow (event-driven) • Heavy reliance on native system libs (platform specific) • Essentially interactive (valid user input generation) App Execution in JPF (Problems) Implicit control flow
  • 27. 12/29 • Absence of explicit control flow (event-driven) • Heavy reliance on native system libs (platform specific) • Essentially interactive (valid user input generation) App Execution in JPF (Problems)
  • 28. • Absence of explicit control flow (event-driven) • Heavy reliance on native system libs (platform specific) • Essentially interactive (valid user input generation) App Execution in JPF (Solutions) 13/29 Android Specs Temporal rules (AEM Model) Handler scheduling policies Temporal rules (AEM Model) Input: (1) app execution history (2) Newly received event Output: next handler to execute Decision procedure Concretization
  • 29. 14/29 • Absence of explicit control flow (event-driven) • Heavy reliance on native system libs (platform specific) • Essentially interactive (valid user input generation) App Execution in JPF (Solutions)
  • 30. 14/29 Identify native methods Native method • Absence of explicit control flow (event-driven) • Heavy reliance on native system libs (platform specific) • Essentially interactive (valid user input generation) App Execution in JPF (Solutions)
  • 31. 14/29 Identify native methods Create stubs (native peers) Native peer Native method • Absence of explicit control flow (event-driven) • Heavy reliance on native system libs (platform specific) • Essentially interactive (valid user input generation) App Execution in JPF (Solutions)
  • 32. 14/29 Identify native methods Create stubs (native peers) Implement logics Native peer Native method • Absence of explicit control flow (event-driven) • Heavy reliance on native system libs (platform specific) • Essentially interactive (valid user input generation) App Execution in JPF (Solutions)
  • 33. 15/29 Application configurations Activity 1 …… Activity n GUI Layout GUI Layout Association Association GUI Layout Analysis (Static) • Absence of explicit control flow (event-driven) • Heavy reliance on native system libs (platform specific) • Essentially interactive (valid user input generation) App Execution in JPF (Solutions)
  • 34. 15/29 • Absence of explicit control flow (event-driven) • Heavy reliance on native system libs (platform specific) • Essentially interactive (valid user input generation) App Execution in JPF (Solutions) JPFJVM Call stack onResume() Listener VM events Waiting for user interaction? Event sequence generation (Dynamic) … Click Long press Sequence length bounded!
  • 35. State Exploration • State changes as the app continuous handles events (user events, system events etc.) 16/29 (Execution 1) (Execution 2) (Execution k) … … Event State
  • 36. State Exploration • State changes as the app continuous handles events (user events, system events etc.) 16/29 (Execution 1) (Execution 2) (Execution k) … … Event State How to analyze sensory data utilization? Are they well utilized?
  • 37. Sensory Data Tracking & Identification 17/29 Data enter app Transformed and consumed Data leave app Data Lifecycle:
  • 38. Sensory Data Tracking & Identification 17/29 Data enter app Transformed and consumed Data leave app Data Lifecycle: • Taint the mock sensory data Taint source Sensory Data tracking process:
  • 39. Sensory Data Tracking & Identification 17/29 Data enter app Transformed and consumed Data leave app Data Lifecycle: • Taint the mock sensory data Taint source • Tracking and pinpointing sensory data • Record sensory data usages Taint propagation Sensory Data tracking process:
  • 40. Sensory Data Tracking & Identification 17/29 Data enter app Transformed and consumed Data leave app Data Lifecycle: • Taint the mock sensory data Taint source • Tracking and pinpointing sensory data • Record sensory data usages Taint propagation • Terminate tainting • Compute sensory data utilization Taint sink Sensory Data tracking process:
  • 41. Taint Propagation Policy 18/29 Index Bytecode Instruction Taint Propagation Rule 1 Const-op C T(stack[0]) = Ø 2 Load-op index T(stack[0]) = T(localVarindex) 3 LoadArray-op arrayRef, index T(stack[0]) = T(arrayRef) ⋃ T(arrayRef [index]) 4 Store-op index T(localVarindex) = T(stack’[0]) 5 StoreArray-op arrayRef, index T(arrayRef [index]) = T(stack’[0]) 6 Binary-op T(stack[0]) = T(stack’[0]) ⋃ T(stack’[1]) 7 Unary-op T(stack[0]) = T(stack’[0]) 8 GetField-op index T(stack[0]) = T(stack’[0].instanceField) ⋃ T(stack’[0]) 9 GetStatic-op index T(stack[0]) = T(ClassName.staticField) 10 PutField-op index T(stack’[1].instanceField) = T(stack’[0]) 1 PutStatic-op index T(ClassName.staticField) = T(stack’[0]) 12 Return-op(non-void) T(callerStack[0]) = T(calleeStack’[0])
  • 42. Example 19/29 float x = values[0]; float y = values[1]; float z = values[2]; float g = GRAVERTIY_EARTH; float acc = (x*x + y*y + z*z) / (g*g); Compute acceleration Input: accEvent from accelerometer float[] values = accEevent.values;
  • 43. Example 19/29 float x = values[0]; float y = values[1]; float z = values[2]; float g = GRAVERTIY_EARTH; float acc = (x*x + y*y + z*z) / (g*g); Compute acceleration Input: accEvent from accelerometer float[] values = accEevent.values;Tainted Data accEvent
  • 44. Example 19/29 float x = values[0]; float y = values[1]; float z = values[2]; float g = GRAVERTIY_EARTH; float acc = (x*x + y*y + z*z) / (g*g); Compute acceleration Input: accEvent from accelerometer float[] values = accEevent.values;Tainted Data accEvent values (Rule 8) Field access
  • 45. Example 19/29 float x = values[0]; float y = values[1]; float z = values[2]; float g = GRAVERTIY_EARTH; float acc = (x*x + y*y + z*z) / (g*g); Compute acceleration Input: accEvent from accelerometer float[] values = accEevent.values;Tainted Data accEvent values (Rule 8) x (Rule 3) y (Rule 3) z (Rule 3) Array element access
  • 46. Example 19/29 float x = values[0]; float y = values[1]; float z = values[2]; float g = GRAVERTIY_EARTH; float acc = (x*x + y*y + z*z) / (g*g); Compute acceleration Input: accEvent from accelerometer float[] values = accEevent.values;Tainted Data accEvent values (Rule 8) x (Rule 3) y (Rule 3) z (Rule 3) acc (Rule 6) Arithmetic computation
  • 47. Sensory data usage measurement 20/29 Usage Accumulationusage(s,d) = weight(i,s)×rel(i) i∈Instr(s,d) ∑
  • 48. Sensory data usage measurement 20/29 (Execution 1) (Execution 2) State1 State2 State3 Osmdroid issue 53: Usage Accumulationusage(s,d) = weight(i,s)×rel(i) i∈Instr(s,d) ∑
  • 49. Sensory data usage measurement 21/29 dataProcess() broadcast() updateMap() Location data dataProcess() broadcast() updateMap() Location data writeToDB() State 2(map invisible) State 3 dataProcess() broadcast() updateMap() Location data State 1 1 2 (Execution 1) (Execution 2)3
  • 50. Sensory data usage measurement 21/29 dataProcess() broadcast() updateMap() Location data dataProcess() broadcast() updateMap() Location data writeToDB() State 2(map invisible) State 3 dataProcess() broadcast() updateMap() Location data State 1 +n +n +n +n +n +0 +n +n +n +n 1 2 (Execution 1) (Execution 2)3
  • 51. Usage Comparison 22/29 1 2 (Execution 1) (Execution 2)3 Index Usage Utilization coefficient State 1 3n 0.75 State 2 2n 0.5 State 3 4n 1 utilization_coefficient(s,d) = usage(s,d) Maxs'∈S,d'∈D (usage(s',d'))
  • 52. Usage Comparison 22/29 1 2 (Execution 1) (Execution 2)3 Index Usage Utilization coefficient State 1 3n 0.75 State 2 2n 0.5 State 3 4n 1 utilization_coefficient(s,d) = usage(s,d) Maxs'∈S,d'∈D (usage(s',d')) Report • Event sequence • Sensory data usage details
  • 53. Usage Comparison 22/29 1 2 (Execution 1) (Execution 2)3 Index Usage Utilization coefficient State 1 3n 0.75 State 2 2n 0.5 State 3 4n 1 utilization_coefficient(s,d) = usage(s,d) Maxs'∈S,d'∈D (usage(s',d')) Report • Event sequence • Sensory data usage details Sensor listener misusage
  • 54. Evaluation • RQ1 (Effectiveness): Can GreenDroid effectively detect energy problems? • RQ2 (Efficiency): How much overhead does GreenDroid incur? Is GreenDroid practical enough to handler real-world large subjects? 23/29
  • 55. Subjects 24/29 Application Basic Information Revision No. Lines of code Downloads Availability Osmdroid 750 18,091 10K—50K Google Play Zmanim 322 4,893 10K—50K Google Play Omnidroid 863 12,427 1K—5K Google Play DroidAR 204 18,106 1K—5K Google Code Recycle-locator 68 3,241 1K—5K Google Play GPSLogger 15 659 1K—5K Google Code
  • 56. Effectiveness 25/29 Energy Problem Problem type New problem OsmDroid Issue 53 Sensory data underutilization No Zmanim Issue 50 Sensory data underutilization No Zmanim Issue 56 Sensory data underutilization No DroidAR Issue 27 Sensor listener misusage No Recycle-Locator Issue 33 Sensor listener misusage No Omnidroid Issue 179 Sensory data underutilization Yes GPSLogger Issue 7 Sensory data underutilization Yes GreenDroid found seven real problems. Five problems are caused by poor sensory data utilization. Two problems are caused by sensor listener misusage.
  • 57. Energy Problem Problem type New problem OsmDroid Issue 53 Sensory data underutilization No Zmanim Issue 50 Sensory data underutilization No Zmanim Issue 56 Sensory data underutilization No DroidAR Issue 27 Sensor listener misusage No Recycle-Locator Issue 33 Sensor listener misusage No Omnidroid Issue 179 Sensory data underutilization Yes GPSLogger Issue 7 Sensory data underutilization Yes Effectiveness 25/29 First five problems were confirmed before our experiments. The Last two were new problems found by GreenDroid
  • 58. Effectiveness 25/29 “Completely true, Omnidroid does suck up way more energy than necessary. I'd be happy to accept a patch in this regard”. (Omnidroid issue 179) Energy Problem Problem type New problem OsmDroid Issue 53 Sensory data underutilization No Zmanim Issue 50 Sensory data underutilization No Zmanim Issue 56 Sensory data underutilization No DroidAR Issue 27 Sensor listener misusage No Recycle-Locator Issue 33 Sensor listener misusage No Omnidroid Issue 179 Sensory data underutilization Yes GPSLogger Issue 7 Sensory data underutilization Yes
  • 59. Efficiency 26/29 Application Analysis Overhead Explored states Time (seconds) Space (MB) Osmdroid 120,189 151 591 Zmanim 54,270 110 205 Omnidroid (12 KLOC) 52,805 220 342 DroidAR (18 KLOC) 91,170 276 217 Recycle-locator 114,709 43 153 GPSLogger 58,824 35 149 Thousands of states explored in a few minutes. Memory Consumption well supported by modern PCs even without optimization.
  • 60. Efficiency 26/29 Application Analysis Overhead Explored states Time (seconds) Space (MB) Osmdroid (18 KLOC) 120,189 151 591 Zmanim 54,270 110 205 Omnidroid (12 KLOC) 52,805 220 342 DroidAR (18 KLOC) 91,170 276 217 Recycle-locator 114,709 43 153 GPSLogger 58,824 35 149 Large subjects’ analysis overhead suggests that GreenDroid is practical enough to handle real world Android applications.
  • 61. Discussion • Limitations – Imprecision in AEM model and native lib modeling – Complex inputs generation (e.g., password) – Limited subjects in evaluation • Future work – Validate the effectiveness with more subjects – Investigate energy problems caused by other reasons (e.g., network) 28/29