75
AppInsight: Mobile App Performance Monitoring in the Wild Lenin Ravindranath, Jitu Padhye, Sharad Agarwal, Ratul Mahajan, Ian Obermiller, Shahin Shayandeh Microsoft Research

AppInsight: Mobile App Performance Monitoring in the Wild

  • Upload
    tal

  • View
    29

  • Download
    2

Embed Size (px)

DESCRIPTION

AppInsight: Mobile App Performance Monitoring in the Wild. Lenin Ravindranath, Jitu Padhye, Sharad Agarwal, Ratul Mahajan, Ian Obermiller, Shahin Shayandeh. Microsoft Research. > One Million Apps. > 300,000 Developers. There’s an App For That. But its slow. - PowerPoint PPT Presentation

Citation preview

Page 1: AppInsight:  Mobile App Performance Monitoring in the Wild

AppInsight: Mobile App Performance Monitoring in

the Wild

Lenin Ravindranath, Jitu Padhye, Sharad Agarwal, Ratul Mahajan, Ian Obermiller, Shahin Shayandeh

Microsoft Research

Page 2: AppInsight:  Mobile App Performance Monitoring in the Wild
Page 3: AppInsight:  Mobile App Performance Monitoring in the Wild
Page 4: AppInsight:  Mobile App Performance Monitoring in the Wild

> One Million Apps

> 300,000 Developers

Page 5: AppInsight:  Mobile App Performance Monitoring in the Wild

There’s an App For That

“… Too slow - killing the usefulness when you really need to go.”

But its slow

Page 6: AppInsight:  Mobile App Performance Monitoring in the Wild

“Slower than a snail.”

“Slow and unresponsive like mud”

“Consistently 3 seconds behind where I touch.”

“So slow. Did an intern write this app??”

“Very very slow compared to even browsing web.”

“Sluggish and freezes my HTC phone.”

“Loading GPS data is *** slow”

Page 7: AppInsight:  Mobile App Performance Monitoring in the Wild

“Slower than a snail.”

“Slow and unresponsive like mud”

“Consistently 3 seconds behind where I touch.”

“So slow. Did an intern write this app??”

“Very very slow compared to even browsing web.”

“Sluggish and freezes my HTC phone.”

“Loading GPS data is *** slow”Performance problems are inevitable in the wild

Hard to emulate in the lab

• Diverse environmental conditions– Network connectivity, GPS signal quality, etc

• Variety of hardware and OS versions• Wide range of user interactions

Page 8: AppInsight:  Mobile App Performance Monitoring in the Wild

What is the user-perceived delay?Where is the bottleneck?

Monitor Performance in the Hands of Users

Significant barrier for most app developers

• Little platform support• Only option is to instrument your app– Manage your own logging infrastructure

Page 9: AppInsight:  Mobile App Performance Monitoring in the Wild

AppInsight

• Automatic App Instrumentation– Zero developer effort– Binary Instrumentation

• Readily deployable– No changes to the OS or runtime

• Low overhead

What is the user-perceived delay?Where is the bottleneck?

Page 10: AppInsight:  Mobile App Performance Monitoring in the Wild

App

Instrumenter

AppInstrumented

App Store

Downloads

Analysis

DeveloperFeedback

Server

Traces

Developer

Page 11: AppInsight:  Mobile App Performance Monitoring in the Wild

App

Instrumenter

AppInstrumented

App Store

Downloads

Analysis

DeveloperFeedback

Server

Traces

Developer

Page 12: AppInsight:  Mobile App Performance Monitoring in the Wild

App

Instrumenter

AppInstrumented

Downloads

Analysis

DeveloperFeedback

Server

Traces

Developer

App Store

Page 13: AppInsight:  Mobile App Performance Monitoring in the Wild

Instrumentation impacts app performance– They are already slow enough!!!

Limited Resources– Network, Battery, Memory

App Instrumentation is Challenging

Page 14: AppInsight:  Mobile App Performance Monitoring in the Wild

• Highly interactive, UI centric– Single UI thread that should not be blocked

• Most tasks are performed asynchronously– Asynchronous APIs for Network, Sensor, IO etc.– Computation performed on background threads

App Instrumentation is Challenging

Highly Asynchronous Programming Pattern

Tracing async code is challenging

Page 15: AppInsight:  Mobile App Performance Monitoring in the Wild

Internet

53%

“Mitt Romney might vote for Obama as well”

“We recommend Mitt Romney for president”

“I would definitely trust Mitt Romney with my money.”

“If I had a nickel for every time Mitt Romney said something stupid I'd be in his tax bracket”

Mitt Romney

MittRating

MittRating

Tweets

Page 16: AppInsight:  Mobile App Performance Monitoring in the Wild

ClickHandler() { tweets = HttpGet(url); rating = ProcessTweets(tweets); display.Text = rating;

}

ProcessTweets(tweets){ ...}

Click HandlerStart

Click HandlerEnd

LogStart();

LogEnd();

Thread

User Perceived Delay

53%

MittRating

Hypothetical Synchronous Code

Page 17: AppInsight:  Mobile App Performance Monitoring in the Wild

ClickHandler() { AsyncHttpGet(url, DownloadCallback);}DownloadCallback(tweets) { rating = ProcessTweets(tweets); UIDispatch(DisplayRating, rating);}DisplayRating(rating){ display.Text = rating;}ProcessTweets(tweets){ ...}

DisplayRating

UI Thread

Background ThreadUI Dispatch

ClickHandlerEndClickHandler

Start

MittRating

System

Async Get CallProcessTweets

DownloadCallback

53%

User Click

Asynchronous Code

Page 18: AppInsight:  Mobile App Performance Monitoring in the Wild

MittRating

53%

User Perceived Delay

System

UI Thread

Background Thread

DisplayRating

UI Dispatch

Async Get Call

DownloadCallback

ClickHandlerStart

User Transaction

Transaction time

Page 19: AppInsight:  Mobile App Performance Monitoring in the Wild

UI Thread

Background Thread

Transaction time

User Transaction

Get Rating

53%

Page 20: AppInsight:  Mobile App Performance Monitoring in the Wild

UI Thread

Background Thread

User Transaction

7 edges

MittRating

53%

Page 21: AppInsight:  Mobile App Performance Monitoring in the Wild

Apps are highly asynchronous

Where is the bottleneck?Focus development efforts

30 popular apps167,000 transactions

– On average, 19 asynchronous calls per user transaction– On average, 8 parallel threads per user transaction

Up to 7000 edges

Page 22: AppInsight:  Mobile App Performance Monitoring in the Wild

UI Thread

Background Thread

Background Thread

Background Thread

Twitter

Thread Wakeup

Thread Blocked

Fire

Fire

DisplayUser Transaction

Callback

Callback

Tweets

PostsTwitter

Facebook Process

Posts

Process Tweets

Facebook

MittRating

47%

User Click

Page 23: AppInsight:  Mobile App Performance Monitoring in the Wild

UI Thread

Background Thread

Background Thread

Background Thread

User Click

Twitter

Thread Wakeup

Thread Blocked

Fire

Fire

Callback

Callback

Twitter

Facebook Process

Posts

Process Tweets

Facebook

Critical PathOptimizing the critical path reduces the user perceived delay

User Transaction Display

Page 24: AppInsight:  Mobile App Performance Monitoring in the Wild

AppInsight

What is the user-perceived delay?Where is the bottleneck?

Automatically instruments the app to track user transactions and critical path

Page 25: AppInsight:  Mobile App Performance Monitoring in the Wild

App

Instrumenter

AppInstrumented

Downloads

Analysis

DeveloperFeedback

Server

Traces

Developer

App Store

Page 26: AppInsight:  Mobile App Performance Monitoring in the Wild

Low OverheadUser Transaction

UI Thread

Background Thread

• Should not impact app performance• Limited Resources

Capturing User Transaction

Page 27: AppInsight:  Mobile App Performance Monitoring in the Wild

User Transaction

UI Thread

Background Thread

Page 28: AppInsight:  Mobile App Performance Monitoring in the Wild

UI Thread

Background Thread

User ClickEvent Handler

• UI ManipulationsCapture

User Transaction

Page 29: AppInsight:  Mobile App Performance Monitoring in the Wild

• UI ManipulationsCapture

User Transaction

UI Thread

Background Thread

Page 30: AppInsight:  Mobile App Performance Monitoring in the Wild

• UI Manipulations• Thread Execution

Capture

Click Handler Start

Click Handler End

Update UIStart End

CallbackStart

Callback End

User TransactionUser Transaction

UI Thread

Background Thread

Page 31: AppInsight:  Mobile App Performance Monitoring in the Wild

• UI Manipulations• Thread Execution

Capture

User Transaction

UI Thread

Background Thread

Page 32: AppInsight:  Mobile App Performance Monitoring in the Wild

• UI Manipulations• Thread Execution• Async Calls and Callbacks

Async Get Call

UI Dispatch Call

UI Dispatch Callback

Capture

DownloadCallback

User Transaction

UI Thread

Background Thread

Page 33: AppInsight:  Mobile App Performance Monitoring in the Wild

• UI Manipulations• Thread Execution• Async Calls and Callbacks

Capture

User Transaction

UI Thread

Background Thread

Page 34: AppInsight:  Mobile App Performance Monitoring in the Wild

• UI Manipulations• Thread Execution• Async Calls and Callbacks• UI Updates

Capture

User Transaction

UI Update

User Transaction

UI Thread

Background Thread

Page 35: AppInsight:  Mobile App Performance Monitoring in the Wild

• UI Manipulations• Thread Execution• Async Calls and Callbacks• UI Updates

Capture

User Transaction

UI Thread

Background Thread

Page 36: AppInsight:  Mobile App Performance Monitoring in the Wild

UI Thread

Background Thread

Background Thread

Background Thread

User Transaction

• UI Manipulations• Thread Execution• Async Calls and Callbacks• UI Updates• Thread Synchronization

Fire

Fire

Thread Blocked

Thread Wakeup

Capture

Page 37: AppInsight:  Mobile App Performance Monitoring in the Wild

• UI Manipulations• Thread Execution• Async Calls and Callbacks• UI Updates• Thread Synchronization

Capture

Page 38: AppInsight:  Mobile App Performance Monitoring in the Wild

• UI Manipulations• Thread Execution• Async Calls and Callbacks• UI Updates• Thread Synchronization

Capture

User Transaction

UI Thread

Background Thread

Page 39: AppInsight:  Mobile App Performance Monitoring in the Wild

• UI Manipulations• Thread Execution• Async Calls and Callbacks• UI Updates• Thread Synchronization

Capture

Click Handler Start

Click Handler End

Update UIStart End

CallbackStart

Callback End

User TransactionUser Transaction

UI Thread

Background Thread

Page 40: AppInsight:  Mobile App Performance Monitoring in the Wild

• Trace every method– Prohibitive overhead

• Enough to log thread boundaries• Log entry and exit of Upcalls

Capturing Thread Execution

Upcalls

System

App

Click Handler Start

Click Handler End

Update UIStart End

CallbackStart

Callback End

UI Thread

Background Thread

Page 41: AppInsight:  Mobile App Performance Monitoring in the Wild

ClickHandler() { AsyncHttpGet(url, DownloadCallback);}DownloadCallback(tweets) { rating = ProcessTweets(tweets); UIDispatch(DisplayRating, rating);}DisplayRating(rating){ display.Text = rating;}ProcessTweets(tweets){ ...}

• Event Handlers are Upcalls• Function pointers point to potential Upcalls

– Callbacks are passed as function pointers

<Button Click=“ClickHandler” />

Identify Upcalls

Page 42: AppInsight:  Mobile App Performance Monitoring in the Wild

Instrument Upcalls• Rewrite app

– Trace UpcallsClickHandler() { Logger.UpcallStart(1); AsyncHttpGet(url, DownloadCallback); Logger.UpcallEnd(1);}DownloadCallback(response) { Logger.UpcallStart(2); rating = ProcessTweets(tweets); UIDispatch(DisplayRating, rating); Logger.UpcallEnd(2);}DisplayRating(rating){ Logger.UpcallStart(3); display.Text = rating; Logger.UpcallEnd(3);}ProcessTweets(tweets){ ...}

Low Overhead7000 times less overhead

Click Handler Start

Click Handler End

Update UIStart End

CallbackStart

Callback End

UI Thread

Background Thread

Page 43: AppInsight:  Mobile App Performance Monitoring in the Wild

• UI Manipulations• Thread Execution• Async Calls and Callbacks• UI Updates• Thread Synchronization

Capture

Async Get Call

UI Dispatch Call

UI Dispatch Callback

DownloadCallback

User Transaction

UI Thread

Background Thread

Page 44: AppInsight:  Mobile App Performance Monitoring in the Wild

Async Get Call

Callback

Async Calls and Callbacks• Log Callback Start

– We capture start of the thread• Log Async Call

– Any call that accepts a function pointer

• Match Async Call to its Callback

ClickHandler() { AsyncHttpGet(url, DownloadCallback); Logger.AsyncCall(5);}DownloadCallback(tweets) { Logger.UpcallStart(2); ....}

Page 45: AppInsight:  Mobile App Performance Monitoring in the Wild

Matching Async Call to its Callback• A method could be a callback to many async calls– Replicate the callback for each Async call [Hirzel’01]

• Async call called in a loop (e.g. download list of URLs)– Cannot be matched correctly

• Solution: Detour Callbacks

Page 46: AppInsight:  Mobile App Performance Monitoring in the Wild

System

App

AsyncHttpGet

Async Call

DownloadCallbackDownloadCallback(response){}

Callbacks

Page 47: AppInsight:  Mobile App Performance Monitoring in the Wild

Detour Callbacks

DetourCallback(response){

DownloadCallback(response);}

class DetourObject {

}

MatchId = 3

obj.DetourCallback

MatchId = 3

MatchId = 3

AsyncHttpGet(url, GetCallback); AsyncHttpGet(url, obj.DetourCallback);obj = new DetourObject(DownloadCallback, MatchId++);

System

App

AsyncHttpGet

Async Call

DownloadCallbackDownloadCallback(response){}

while(...) {

}

Page 48: AppInsight:  Mobile App Performance Monitoring in the Wild

Detour Callbacks

DetourCallback(response){

DownloadCallback(response);}

class DetourObject {

}

MatchId = 4

obj.DetourCallback

MatchId = 4

MatchId = 4

obj = new DetourObject(DownloadCallback, MatchId++);

System

App

AsyncHttpGet

Async Call DownloadCallback(response){}

AsyncHttpGet(url, obj.DetourCallback);

while(...) {

}

Page 49: AppInsight:  Mobile App Performance Monitoring in the Wild

Detour Callbacks

DetourCallback(response){

DownloadCallback(response);}

class DetourObject {

}

MatchId = 5

obj.DetourCallback

MatchId = 5

MatchId = 5

obj = new DetourObject(DownloadCallback, MatchId++);

System

App

AsyncHttpGet

Async Call DownloadCallback(response){}

AsyncHttpGet(url, obj.DetourCallback);

while(...) {

}

Page 50: AppInsight:  Mobile App Performance Monitoring in the Wild

• Detour Callbacks• Event Subscriptions• Delayed Callbacks– Track Object Ids

Matching Async Call to its Callback

Low Overhead

Async Get Call

UI Dispatch Call

UI Dispatch Callback

DownloadCallback

UI Thread

Background Thread

Page 51: AppInsight:  Mobile App Performance Monitoring in the Wild

• UI Manipulations• Thread Execution• Async Calls and Callbacks• UI Updates• Thread Synchronization

Capture

User Transaction

UI Thread

Background Thread

Page 52: AppInsight:  Mobile App Performance Monitoring in the Wild

App

Instrumenter

AppInstrumented

App Marketplace

Downloads

Analysis

DeveloperFeedback

Server

Traces

Developer

Page 53: AppInsight:  Mobile App Performance Monitoring in the Wild

App

Instrumenter

AppInstrumented

App Marketplace

Downloads

Analysis

DeveloperFeedback

Server

Traces

Developer

Page 54: AppInsight:  Mobile App Performance Monitoring in the Wild

• Critical Path• Aggregate Analysis• Exception Path

Analysis

Page 55: AppInsight:  Mobile App Performance Monitoring in the Wild

Critical Path• Bottleneck path in the user transaction– Optimizing the critical path reduces user perceived delay

UI UpdateUser Manipulation

Critical Path

• Multiple UI updates• Timers, Sensors

Page 56: AppInsight:  Mobile App Performance Monitoring in the Wild

• Critical Path• Aggregate Analysis• Exception Path

Analysis

Page 57: AppInsight:  Mobile App Performance Monitoring in the Wild

Aggregate Analysis

Group similar transactions– Same transaction graph

• Outliers– Points to corner cases

• Highlight common critical paths– Focus development effort

• Root causes of Performance Variability– Highlight what really matters in the wild

Page 58: AppInsight:  Mobile App Performance Monitoring in the Wild

• Critical Path• Aggregate Analysis• Exception Path

Analysis

Page 59: AppInsight:  Mobile App Performance Monitoring in the Wild

UI Thread

Background Thread

Background Thread

Exceptionat parseXML()DownloadCallback()

Stack trace

parseXML()……DownloadCallback()AsyncHttpGet(url)

ThreadCallback()

ClickHandler()

ThreadStart()User Manipulation Exception Path

Failures in the wild

Page 60: AppInsight:  Mobile App Performance Monitoring in the Wild

• Critical Path• Aggregate Analysis• Exception Path

Analysis

Page 61: AppInsight:  Mobile App Performance Monitoring in the Wild

App

Instrumenter

AppInstrumented

App Store

Downloads

Analysis

DeveloperFeedback

Server

Traces

Developer

Page 62: AppInsight:  Mobile App Performance Monitoring in the Wild

Developer FeedbackWeb based Interface

• Long User Transactions• Critical Path• Aggregate Analysis– Outliers– Common Case– Factors affecting

• Crashes - Exception Path

Page 63: AppInsight:  Mobile App Performance Monitoring in the Wild

App

Instrumenter

AppInstrumented

App Store

Downloads

Analysis

DeveloperFeedback

Server

Traces

Developer

Deployment

Page 64: AppInsight:  Mobile App Performance Monitoring in the Wild

• 30 Windows Phone apps • 30 Users• Over 4 months of data• 6750 app sessions• 33,000 minutes in apps• 167,000 user transactions

Deployment

Page 65: AppInsight:  Mobile App Performance Monitoring in the Wild

User Transactions and Critical Path

• Apps are highly asynchronous

• # edges in the critical path << # edges in the transaction – Top 2 edges responsible for 82% of transaction time– App developer can focus on optimizing these edges

• 15% of the user transactions take more than 5 seconds

Key reason why a system like AppInsight is needed

Up to 7000 edges

Page 66: AppInsight:  Mobile App Performance Monitoring in the Wild

• High variability in the wild

Aggregate Analysis

• 29% transaction groups has multiple critical paths• Network, GPS state, Device model, User– all affects performance

Key reason why performance monitoring in the wild is important

Page 67: AppInsight:  Mobile App Performance Monitoring in the Wild

AppInsight OverheadCompute NetworkMemory Binary

SizeBattery

<1%1.2%2% 4%0.02%

Negligible Overhead

• Impact on app performance is minimal– Our users reported no cases of performance degradation

• Low resource consumption

Page 68: AppInsight:  Mobile App Performance Monitoring in the Wild

App

Instrumenter

AppInstrumented

App Store

Downloads

Analysis

DeveloperFeedback

Server

Traces

Developer

Page 69: AppInsight:  Mobile App Performance Monitoring in the Wild

App

Instrumenter

AppInstrumented

App Store

Downloads

Analysis

DeveloperFeedback

Server

Traces

Developer

Improved

Page 70: AppInsight:  Mobile App Performance Monitoring in the Wild

App: My App

Problem: UI Hog

AppInsight:• Aggregate analysis showed high performance variability– Attributed to UI thread

• Abnormal latencies only at the start of the session• System loading DLLs in the critical path

Developer Case Study

Page 71: AppInsight:  Mobile App Performance Monitoring in the Wild

App: Popular App

Problem: Slow Transactions

AppInsight:• Aggregate analysis showed 3G latencies significantly

affecting critical paths– Known issue but no quantitative data

• Current caching policy insufficient– Quantitative data

Developer Case Study

Page 72: AppInsight:  Mobile App Performance Monitoring in the Wild

Developer Case Study

App: Professional App

Problem: Slow Transactions

AppInsight:• Custom instrumentation in the critical path– Affecting user perceived delay

Page 73: AppInsight:  Mobile App Performance Monitoring in the Wild

AppInsight

• Extremely low overhead• Zero developer effort• Readily deployable

• Automatically tracks User Transactions• Identifies Critical Paths and Exception Paths• Aggregate Analysis highlights factors affecting performance

Helps app developers understand performance bottlenecks in the wild

Page 74: AppInsight:  Mobile App Performance Monitoring in the Wild

1. Who cares about Windows Phone. Can you do it for Android and iPhone?

2. This was done in 1982. Don’t you read related work?

3. Are you one of those who don’t care about user privacy?

4. Sounds too good. Are there any limitations?

5. Are you going to release it? Or is it a one off paper?

6. I totally don’t get why you are doing this!?

FAQ

Page 75: AppInsight:  Mobile App Performance Monitoring in the Wild

AppInsight can miss certain causal relationships• Does not track data dependencies– Two threads communicating through a shared variable

• One thread polling– Uses heuristics to warn the developer

• Will miss implicit casual relationships– Resource contention

• Does not track that state left behind– Dependencies resulting from such state

Limitations