Understanding Mobile Web    Browser Performance    Rajiv Vijayakumar    Qualcomm Incorporated                             ...
Topics    § Mobile browser architecture    § Mobile network latencies    § Android HTTP: Parallel downloads and caching...
SmartPhone Web Browsers                              3
What is a “WebKit” Browser?                                  4
Browser Architecture5
Browser Architecture             Layout Engine5
Browser Architecture                WebKit5
Browser Architecture                           JavaScript                WebKit                             Engine5
Browser Architecture                           JavaScriptCore                WebKit                               or V85
Browser Architecture                           JavaScriptCore                WebKit                               or V8   ...
Browser Architecture                           Browser UI                                   JavaScriptCore                ...
Android              6
Android Browser ≠ Chrome                               7
<img src="http://www.qualcomm.com/imgA.jpg">8
<img src="http://www.qualcomm.com/imgA.jpg">                                           Time8
<img src="http://www.qualcomm.com/imgA.jpg">        DNS                                           Time8
<img src="http://www.qualcomm.com/imgA.jpg">                       DNS                                           Time     ...
<img src="http://www.qualcomm.com/imgA.jpg">        DNS      TCP                                           Time8
<img src="http://www.qualcomm.com/imgA.jpg">        DNS         TCP                                           Time        ...
<img src="http://www.qualcomm.com/imgA.jpg">        DNS      TCP           HTTP                                           ...
<img src="http://www.qualcomm.com/imgA.jpg">        DNS      TCP                   HTTP                                   ...
<img src="http://www.qualcomm.com/imgA.jpg">        DNS      TCP                   HTTP                                   ...
Latencies in 3G/4G Networks9
Latencies in 3G/4G Networks    § Initial connection setup: > 1s (on older 3G)9
Latencies in 3G/4G Networks    § Initial connection setup: > 1s (on older 3G)    § Round trip time (RTT): 80ms or higher...
RTTs at speed of light     § San Diego – New York : ~26ms     § San Diego – Johannesburg : ~110ms10
Every round trip is at least 80-100ms           DNS       TCP            HTTP11
Every round trip is at least 80-100ms           DNS        TCP               HTTP              Including HTTP retrievals f...
DNS                           Every new lookup takes 1 RTT + Lookup Time                                                  ...
Domain Sharding     § Use of multiple domains        (cdn1.domain.com, cdn2.domain.com)     § Requests may not happen in...
Parallel Downloads                   8 images across 2 domains     cdn1.domain.com/img1A.png   cdn2.domain.com/img2A.png  ...
Browsers typically use 4-6 sockets per host        img1A        img1B        img1C                                        ...
Android        img1A   img1D        img1B        img1C                                        cdn1        img2A   img2B   ...
Android        img1A   img1D        img1B        img1C                                        cdn1        img2A   img2B   ...
Android        img1A        img1B        img1C                cdn1        img2A                cdn217
Android        img1A          § “Thread per socket” model        img1B                cdn1        img1C          § 4 HTT...
QUALCOMM CONFIDENTIAL AND PROPRIETARY18   Source: DDMS (from Android SDK) connected to Android 2.3.3 emulator
Android        img1A          § “Thread per socket” model        img1B                cdn1        img1C          § 4 HTT...
Android        img1A          § “Thread per socket” model        img1B                cdn1        img1C          § 4 HTT...
Android        img1A   img1D        img1B        img1C                                        cdn1        img2A   img2B   ...
Android        img2A   img2B                        img2C                                img2D   cdn220
Android        img2A          img2B                               img2C                                       img2D   cdn2...
Android        img2A                               img2B                                                    img2C         ...
Android        img2A                               img2B                                                    img2C         ...
Pipelining     § Not supported, or not enabled by default on most major        browsers     § Historically caused proble...
HTTP Caching22
HTTP Caching     § WebKit maintains a memory cache      § Default size = 8 MB     § Android has a persistent (file syst...
Cache Eviction23
Cache Eviction     § What gets evicted to make room?23
Cache Eviction     § What gets evicted to make room?     § Android policy: Prioritize base on expiration date      § Fa...
Example of Cache Contents     Visited several sites, read blog posts and linked articles etc.24
Example of Cache Contents     Visited several sites, read blog posts and linked articles etc.      sqlite3 webviewCache.db...
Example of Cache Contents     Visited several sites, read blog posts and linked articles etc.      sqlite3 webviewCache.db...
Example of Cache Contents     Visited several sites, read blog posts and linked articles etc.      sqlite3 webviewCache.db...
§ Cache eviction policy affects performance     § Consider real-world cache occupancy when measuring        cached page ...
Caveats     § Devices can (and do!) differ from stock Android     § Differences in:      § Number of HTTP threads      ...
Power     What is the power drawn from the battery while loading a     web page?27
Battery Current (mA)28   Source: Power measurements made on MDP MSM8655™ running Android 2.3 over commercial 3G network
11s download (400mA)                             Baseline (200 mA)                                                        ...
Power     § Any network traffic brings up the radio for several seconds        § Network dormancy timer: typically 10-15...
TCP FINs and Power31   Source: Power measurements made on MDP MSM8655™ running Android 2.3 over commercial 3G network
TCP FINs and Power     § Android closes TCP sockets after ~6s of inactivity        § Sockets get closed at different tim...
TCP FINs and Power     § Android closes TCP sockets after ~6s of inactivity        § Sockets get closed at different tim...
TCP FINs and Power     § Android closes TCP sockets after ~6s of inactivity        § Sockets get closed at different tim...
JavaScript Performance     § SunSpider benchmark numbers have improved dramatically        in recent years        § Andr...
developer.qualcomm.com/webtech33
Q&A34
Disclaimer                                                  QUALCOMM Incorporated                                         ...
Upcoming SlideShare
Loading in …5
×

Understanding Mobile Web Performance

3,476
-1

Published on

Slides from my presentation at Velocity 2011.

Published in: Technology

Understanding Mobile Web Performance

  1. 1. Understanding Mobile Web Browser Performance Rajiv Vijayakumar Qualcomm Incorporated QUALCOMM CONFIDENTIAL AND PROPRIETARY1
  2. 2. Topics § Mobile browser architecture § Mobile network latencies § Android HTTP: Parallel downloads and caching § Power consumption2
  3. 3. SmartPhone Web Browsers 3
  4. 4. What is a “WebKit” Browser? 4
  5. 5. Browser Architecture5
  6. 6. Browser Architecture Layout Engine5
  7. 7. Browser Architecture WebKit5
  8. 8. Browser Architecture JavaScript WebKit Engine5
  9. 9. Browser Architecture JavaScriptCore WebKit or V85
  10. 10. Browser Architecture JavaScriptCore WebKit or V8 Rendering Networking5
  11. 11. Browser Architecture Browser UI JavaScriptCore WebKit or V8 Rendering Networking5
  12. 12. Android 6
  13. 13. Android Browser ≠ Chrome 7
  14. 14. <img src="http://www.qualcomm.com/imgA.jpg">8
  15. 15. <img src="http://www.qualcomm.com/imgA.jpg"> Time8
  16. 16. <img src="http://www.qualcomm.com/imgA.jpg"> DNS Time8
  17. 17. <img src="http://www.qualcomm.com/imgA.jpg"> DNS Time 96.16.97.9 www.qualcomm.com8
  18. 18. <img src="http://www.qualcomm.com/imgA.jpg"> DNS TCP Time8
  19. 19. <img src="http://www.qualcomm.com/imgA.jpg"> DNS TCP Time SYN SYN/ACK8
  20. 20. <img src="http://www.qualcomm.com/imgA.jpg"> DNS TCP HTTP Time8
  21. 21. <img src="http://www.qualcomm.com/imgA.jpg"> DNS TCP HTTP Time HTTP/1.1 200 OK GET /imgA.jpg8
  22. 22. <img src="http://www.qualcomm.com/imgA.jpg"> DNS TCP HTTP Time HTTP/1.1 200 OK GET /imgA.jpg8
  23. 23. Latencies in 3G/4G Networks9
  24. 24. Latencies in 3G/4G Networks § Initial connection setup: > 1s (on older 3G)9
  25. 25. Latencies in 3G/4G Networks § Initial connection setup: > 1s (on older 3G) § Round trip time (RTT): 80ms or higher (typically) § 100 - 200ms common9
  26. 26. RTTs at speed of light § San Diego – New York : ~26ms § San Diego – Johannesburg : ~110ms10
  27. 27. Every round trip is at least 80-100ms DNS TCP HTTP11
  28. 28. Every round trip is at least 80-100ms DNS TCP HTTP Including HTTP retrievals from a CDN11
  29. 29. DNS Every new lookup takes 1 RTT + Lookup Time Histogram of DNS Lookup Times 150 100 50 0 0 0.2 0.4 0.6 0.8 1.0 1.2 1.4 Seconds12 Source: Data collected over 30 sites (280 domains) on Qualcomm corporate network
  30. 30. Domain Sharding § Use of multiple domains (cdn1.domain.com, cdn2.domain.com) § Requests may not happen in parallel...13
  31. 31. Parallel Downloads 8 images across 2 domains cdn1.domain.com/img1A.png cdn2.domain.com/img2A.png cdn1.domain.com/img1B.png cdn2.domain.com/img2B.png cdn1.domain.com/img1C.png cdn2.domain.com/img2C.png cdn1.domain.com/img1D.png cdn2.domain.com/img2D.png14
  32. 32. Browsers typically use 4-6 sockets per host img1A img1B img1C cdn1 img1D img2A img2B img2C cdn2 img2D15 t=0
  33. 33. Android img1A img1D img1B img1C cdn1 img2A img2B img2C img2D cdn216
  34. 34. Android img1A img1D img1B img1C cdn1 img2A img2B img2C img2D cdn216
  35. 35. Android img1A img1B img1C cdn1 img2A cdn217
  36. 36. Android img1A § “Thread per socket” model img1B cdn1 img1C § 4 HTTP threads img2A cdn217
  37. 37. QUALCOMM CONFIDENTIAL AND PROPRIETARY18 Source: DDMS (from Android SDK) connected to Android 2.3.3 emulator
  38. 38. Android img1A § “Thread per socket” model img1B cdn1 img1C § 4 HTTP threads img2A cdn219
  39. 39. Android img1A § “Thread per socket” model img1B cdn1 img1C § 4 HTTP threads § Only 4 sockets can have img2A outstanding HTTP requests cdn2 (“active”)19
  40. 40. Android img1A img1D img1B img1C cdn1 img2A img2B img2C img2D cdn220
  41. 41. Android img2A img2B img2C img2D cdn220
  42. 42. Android img2A img2B img2C img2D cdn2 Pipelining20
  43. 43. Android img2A img2B img2C img2D cdn2 Pipelining § Send multiple requests without waiting for each response § Responses must arrive in order20
  44. 44. Android img2A img2B img2C img2D cdn2 Pipelining § Send multiple requests without waiting for each response § Responses must arrive in order § Android pipelines up to 3 requests on each socket20
  45. 45. Pipelining § Not supported, or not enabled by default on most major browsers § Historically caused problems (e.g. due to badly behaving proxies) § Millions of Android devices actively using pipelining § Time to revisit... ?21
  46. 46. HTTP Caching22
  47. 47. HTTP Caching § WebKit maintains a memory cache § Default size = 8 MB § Android has a persistent (file system) HTTP cache § Default size = 6 MB22
  48. 48. Cache Eviction23
  49. 49. Cache Eviction § What gets evicted to make room?23
  50. 50. Cache Eviction § What gets evicted to make room? § Android policy: Prioritize base on expiration date § Far future expiration dates have higher priority § Evict lowest priority items first Expires:Wed, 09 Jun 2021 21:12:36 GMT23
  51. 51. Example of Cache Contents Visited several sites, read blog posts and linked articles etc.24
  52. 52. Example of Cache Contents Visited several sites, read blog posts and linked articles etc. sqlite3 webviewCache.db select expires from cache order by expires desc;24
  53. 53. Example of Cache Contents Visited several sites, read blog posts and linked articles etc. sqlite3 webviewCache.db select expires from cache order by expires desc; Expiration Year 2036 2035 ... 201124
  54. 54. Example of Cache Contents Visited several sites, read blog posts and linked articles etc. sqlite3 webviewCache.db select expires from cache order by expires desc; 200 Expiration Year 150 2036 Count 2035 100 ... 50 2011 0 2010 2020 2030 204024 Expiration Year
  55. 55. § Cache eviction policy affects performance § Consider real-world cache occupancy when measuring cached page load performance25
  56. 56. Caveats § Devices can (and do!) differ from stock Android § Differences in: § Number of HTTP threads § Cache size and eviction algorithm § etc.26
  57. 57. Power What is the power drawn from the battery while loading a web page?27
  58. 58. Battery Current (mA)28 Source: Power measurements made on MDP MSM8655™ running Android 2.3 over commercial 3G network
  59. 59. 11s download (400mA) Baseline (200 mA) 10s idle (300mA) QUALCOMM CONFIDENTIAL AND PROPRIETARY29 Source: Power measurements made on MDP MSM8655™ running Android 2.3 over commercial 3G network
  60. 60. Power § Any network traffic brings up the radio for several seconds § Network dormancy timer: typically 10-15 seconds § Use long periods for any periodic Ajax calls etc.30 Source: Power measurements made on MDP MSM8655™ running Android 2.3 over commercial 3G network
  61. 61. TCP FINs and Power31 Source: Power measurements made on MDP MSM8655™ running Android 2.3 over commercial 3G network
  62. 62. TCP FINs and Power § Android closes TCP sockets after ~6s of inactivity § Sockets get closed at different times31 Source: Power measurements made on MDP MSM8655™ running Android 2.3 over commercial 3G network
  63. 63. TCP FINs and Power § Android closes TCP sockets after ~6s of inactivity § Sockets get closed at different times § Every socket close generates a TCP FIN § Extends the dormancy timer § Keeps the modem on for a 1-bit communication31 Source: Power measurements made on MDP MSM8655™ running Android 2.3 over commercial 3G network
  64. 64. TCP FINs and Power § Android closes TCP sockets after ~6s of inactivity § Sockets get closed at different times § Every socket close generates a TCP FIN § Extends the dormancy timer § Keeps the modem on for a 1-bit communication § Optimization: close all sockets after page load completes31 Source: Power measurements made on MDP MSM8655™ running Android 2.3 over commercial 3G network
  65. 65. JavaScript Performance § SunSpider benchmark numbers have improved dramatically in recent years § Android (Jun 2011) < 2.5s § Desktop Chrome (Sep 2008) ~2.8 s32 Source: http://ejohn.org/blog/javascript-performance-rundown/
  66. 66. developer.qualcomm.com/webtech33
  67. 67. Q&A34
  68. 68. Disclaimer QUALCOMM Incorporated 5775 Morehouse Drive San Diego, CA. 92121-1714 U.S.A. Copyright © 2011 Qualcomm Incorporated. All rights reserved. Not to be used, copied, reproduced in whole or in part, nor its contents revealed in any manner to others without the express written permission of Qualcomm. Qualcomm and MSM8655 are trademarks of Qualcomm Incorporated, registered in the United States. Other product and brand names may be trademarks or registered trademarks of their respective owners. Nothing in these materials is an offer to sell any of the components or devices referenced herein. Certain components for use in the U.S. are available only through licensed suppliers. Some components are not available for use in the U.S.35

×