SlideShare une entreprise Scribd logo
1  sur  28
Tran Vu Tat Binh
I’ve done all kind of micro-optimizations, use good
algorithms, choose the right data structures but still
got serious performance issues in my mobile apps.
Our online game took about 10
minutes to download 25 MB resources
using 3G in the old version
Performance issues?
 The overall application runs slow.
 The application makes other
applications on phone run slower (yes, it
can)
 Users feel the application slow.
 Be strict: it’s also performance issue if
we can do much better but we don’t
Some interesting points
 Number of threads
 Organizing threads
 Multi-threading and network
 Mobile network under the hood
Number of threads
 Using too many threads
After launch Rush hour
Number of threads
 Using too many threads:
 Overhead
 Hard to control
 Less time for each thread
 Concurrency
Number of threads
 Using too few threads:
 Not take advantage of system resources
 Not so responsive
Number of threads
So how many?
Flexible and should not be a fixed
number, see the next “Organizing
threads” for more details.
Organizing threads
 Usually, there are 3 kinds of task
 Blocking UI task
 Updater task
 Lazy media task
Organizing threads
 Blocking UI task
○ When there are no other data
on screen
○ When user definitely have to
wait for updated data only
Should be a single thread with
high priority since user can not
proceed if task is not done.
Organizing threads
 Updater task
○ Updating / refreshing
○ Loading more
○ User can still interact with
existed data on screen
○ Can move to other screen
without finishing task
Should be a thread pool
(suggest size 2-4)
Organizing threads
 Lazy media task
○ Thumbnails for existed data
○ A list/grid of images
Should be 2 thread pools: one
for downloading and one for
decoding
Organizing threads
 Lazy media task (con.)
 Usually most heavy task  focus optimizing
 Why separating into downloading and
decoding
○ Images might be in local cache already and
decoding usually much faster than
downloading, so don’t let downloading slow
down the progress
○ Decoding pool size should be based on CPU
cores
○ Downloading pool size should be based on
network status
Organizing threads
 Decoding pool size
NUMBER_OF_CORES = Runtime.getRuntime().availableProcessors();
mDecodeThreadPool = new ThreadPoolExecutor(NUMBER_OF_CORES,
NUMBER_OF_CORES, KEEP_ALIVE_TIME, KEEP_ALIVE_TIME_UNIT,
mDecodeWorkQueue);
Organizing threads
 Downloading pool size
 Normal:
○ Fixed size (may be 8 like in some tutorials)
 More optimized:
○ 2G – size 4
○ 3G – size 8
○ 4G – size 16 (or more)
○ WIFI – size 8
 Much more optimized:
○ Based on network speed, increasing size if
can still download faster, decreasing size if
still not slower, until get the best size.
Organizing threads
 Why variable size is better choice:
2G pool size 2
2G pool size 4
2G pool size 8
Organizing threads
 Why variable size is better choice:
3G pool size 4 3G pool size 8
3G pool size 24
Organizing threads
 Facts:
 Each connection has a limited bandwidth
 The phone’s network connection has a
overall limited bandwidth
 There are network latency causing “gaps”
while downloading
Organizing threads
 Downloading pool size
 Too small size
○ Waste network bandwidth
○ Drain battery life if using mobile network
○ Slow
 Too large size
○ Take more time to show individual image (not
overall images on screen)  users feel slow
○ TCP congestion control
○ Slower to start downloading new images when
scrolling
Variable size based on network status is good
choice but need more time to implement
Organizing threads
 Conclusion:
 Blocking UI task – 1 thread
 Updater task – 1 thread pool size 2 - 4
 Lazy media task – 2 thread pools
○ 1 thread pool for decoding size = available cores
○ 1 thread pool for downloading size based on
network status
Mobile network under the hood
 Online applications like messenger,
news reader, social app or online
game… some got serious issues when
using mobile network
○ Battery drain
○ Slow response
Mobile network
 Typical 3G wireless radio state machine (source)
Mobile network
 Messenger application
○ Small data message
○ Transferring more
frequently
○ No fixed schedule
Mobile network
 Online game
○ Small data message
○ Transferring much more
frequently
○ Usually fixed schedule
○ Responsiveness is
importance
Mobile network
 Social app
 News reader
 Photo sharing
 Music app
…
Mobile network
 Optimize data to transfer (as always)
 Batch operation
 Prefetch
 When receive, if need to transmit then
do quick
 If possible, do at the same time with
other apps
Q&A
Thank you!

Contenu connexe

Plus de AiTi Education

[Vietnam Mobile Day 2014] Tăng doanh thu quảng cáo cho mobile site và ứng dụn...
[Vietnam Mobile Day 2014] Tăng doanh thu quảng cáo cho mobile site và ứng dụn...[Vietnam Mobile Day 2014] Tăng doanh thu quảng cáo cho mobile site và ứng dụn...
[Vietnam Mobile Day 2014] Tăng doanh thu quảng cáo cho mobile site và ứng dụn...
AiTi Education
 
[Vietnam Mobile Day 2014] Mobile money - Xu hướng thanh toán nhỏ trên mobile ...
[Vietnam Mobile Day 2014] Mobile money - Xu hướng thanh toán nhỏ trên mobile ...[Vietnam Mobile Day 2014] Mobile money - Xu hướng thanh toán nhỏ trên mobile ...
[Vietnam Mobile Day 2014] Mobile money - Xu hướng thanh toán nhỏ trên mobile ...
AiTi Education
 
[Vietnam Mobile Day 2014] Mobile kết nối thế giới số và thế giới thực và vai ...
[Vietnam Mobile Day 2014] Mobile kết nối thế giới số và thế giới thực và vai ...[Vietnam Mobile Day 2014] Mobile kết nối thế giới số và thế giới thực và vai ...
[Vietnam Mobile Day 2014] Mobile kết nối thế giới số và thế giới thực và vai ...
AiTi Education
 
[Vietnam Mobile Day 2014] The new mobile marketing channel: Social Wifi Marke...
[Vietnam Mobile Day 2014] The new mobile marketing channel: Social Wifi Marke...[Vietnam Mobile Day 2014] The new mobile marketing channel: Social Wifi Marke...
[Vietnam Mobile Day 2014] The new mobile marketing channel: Social Wifi Marke...
AiTi Education
 
[Vietnam Mobile Day 2014] Cá nhân hóa và xác định Khách hàng mục tiêu trong q...
[Vietnam Mobile Day 2014] Cá nhân hóa và xác định Khách hàng mục tiêu trong q...[Vietnam Mobile Day 2014] Cá nhân hóa và xác định Khách hàng mục tiêu trong q...
[Vietnam Mobile Day 2014] Cá nhân hóa và xác định Khách hàng mục tiêu trong q...
AiTi Education
 
[Vietnam Mobile Day 2014] Chiến lược thu hút người dùng cho ứng dụng tại thị ...
[Vietnam Mobile Day 2014] Chiến lược thu hút người dùng cho ứng dụng tại thị ...[Vietnam Mobile Day 2014] Chiến lược thu hút người dùng cho ứng dụng tại thị ...
[Vietnam Mobile Day 2014] Chiến lược thu hút người dùng cho ứng dụng tại thị ...
AiTi Education
 
[Vietnam Mobile Day 2014] Thanh toán mobile, hiện tại và xu hướng- Nguyễn Chi...
[Vietnam Mobile Day 2014] Thanh toán mobile, hiện tại và xu hướng- Nguyễn Chi...[Vietnam Mobile Day 2014] Thanh toán mobile, hiện tại và xu hướng- Nguyễn Chi...
[Vietnam Mobile Day 2014] Thanh toán mobile, hiện tại và xu hướng- Nguyễn Chi...
AiTi Education
 
[Vietnam Mobile Day 2014] Thanh toán bằng thẻ ngân hàng trên mobile chưa bao ...
[Vietnam Mobile Day 2014] Thanh toán bằng thẻ ngân hàng trên mobile chưa bao ...[Vietnam Mobile Day 2014] Thanh toán bằng thẻ ngân hàng trên mobile chưa bao ...
[Vietnam Mobile Day 2014] Thanh toán bằng thẻ ngân hàng trên mobile chưa bao ...
AiTi Education
 
[Vietnam Mobile Day 2014] How to build a mobile store app in 5 minutes - Ng...
[Vietnam Mobile Day 2014] How to build a mobile store app in 5 minutes - 	 Ng...[Vietnam Mobile Day 2014] How to build a mobile store app in 5 minutes - 	 Ng...
[Vietnam Mobile Day 2014] How to build a mobile store app in 5 minutes - Ng...
AiTi Education
 
[Vietnam Mobile Day 2014] Touch the future of the web - Nguyễn Việt Anh - Cou...
[Vietnam Mobile Day 2014] Touch the future of the web - Nguyễn Việt Anh - Cou...[Vietnam Mobile Day 2014] Touch the future of the web - Nguyễn Việt Anh - Cou...
[Vietnam Mobile Day 2014] Touch the future of the web - Nguyễn Việt Anh - Cou...
AiTi Education
 
[Vietnam Mobile Day 2014] Xu hướng trong Mobile Learning, 2014 - Nguyễn Thàn...
[Vietnam Mobile Day 2014] Xu hướng trong Mobile Learning, 2014  - Nguyễn Thàn...[Vietnam Mobile Day 2014] Xu hướng trong Mobile Learning, 2014  - Nguyễn Thàn...
[Vietnam Mobile Day 2014] Xu hướng trong Mobile Learning, 2014 - Nguyễn Thàn...
AiTi Education
 
[Vietnam Mobile Day 2014] Toàn cảnh thị trường game smartphone Việt Nam 2013....
[Vietnam Mobile Day 2014] Toàn cảnh thị trường game smartphone Việt Nam 2013....[Vietnam Mobile Day 2014] Toàn cảnh thị trường game smartphone Việt Nam 2013....
[Vietnam Mobile Day 2014] Toàn cảnh thị trường game smartphone Việt Nam 2013....
AiTi Education
 
[Vietnam Mobile Day 2014] Toàn cảnh thị trường game smartphone Việt Nam 2013....
[Vietnam Mobile Day 2014] Toàn cảnh thị trường game smartphone Việt Nam 2013....[Vietnam Mobile Day 2014] Toàn cảnh thị trường game smartphone Việt Nam 2013....
[Vietnam Mobile Day 2014] Toàn cảnh thị trường game smartphone Việt Nam 2013....
AiTi Education
 
[Vietnam Mobile Day 2014] Gamification and Mobile Learning - Nguyễn Hữu Ân -...
[Vietnam Mobile Day 2014]  Gamification and Mobile Learning - Nguyễn Hữu Ân -...[Vietnam Mobile Day 2014]  Gamification and Mobile Learning - Nguyễn Hữu Ân -...
[Vietnam Mobile Day 2014] Gamification and Mobile Learning - Nguyễn Hữu Ân -...
AiTi Education
 
[Vietnam Mobile Day 2014] Cơ hội & thách thức cho Game Studio Việt trước tảng...
[Vietnam Mobile Day 2014] Cơ hội & thách thức cho Game Studio Việt trước tảng...[Vietnam Mobile Day 2014] Cơ hội & thách thức cho Game Studio Việt trước tảng...
[Vietnam Mobile Day 2014] Cơ hội & thách thức cho Game Studio Việt trước tảng...
AiTi Education
 
[Vietnam Mobile Day 2014] Touch the future of the web - Nguyễn Việt Anh – Cou...
[Vietnam Mobile Day 2014] Touch the future of the web - Nguyễn Việt Anh – Cou...[Vietnam Mobile Day 2014] Touch the future of the web - Nguyễn Việt Anh – Cou...
[Vietnam Mobile Day 2014] Touch the future of the web - Nguyễn Việt Anh – Cou...
AiTi Education
 
[Vietnam Mobile Day 2014] Mobile money - Xu hướng thanh toán nhỏ trên mobile ...
[Vietnam Mobile Day 2014] Mobile money - Xu hướng thanh toán nhỏ trên mobile ...[Vietnam Mobile Day 2014] Mobile money - Xu hướng thanh toán nhỏ trên mobile ...
[Vietnam Mobile Day 2014] Mobile money - Xu hướng thanh toán nhỏ trên mobile ...
AiTi Education
 
[Vietnam Mobile Day 2014] Thanh toán bằng thẻ ngân hàng trên mobile chưa bao ...
[Vietnam Mobile Day 2014] Thanh toán bằng thẻ ngân hàng trên mobile chưa bao ...[Vietnam Mobile Day 2014] Thanh toán bằng thẻ ngân hàng trên mobile chưa bao ...
[Vietnam Mobile Day 2014] Thanh toán bằng thẻ ngân hàng trên mobile chưa bao ...
AiTi Education
 

Plus de AiTi Education (20)

AiTi Education Software Testing Session 01 a
AiTi Education Software Testing Session 01 aAiTi Education Software Testing Session 01 a
AiTi Education Software Testing Session 01 a
 
Vietnam mobile internet_2014_mwork_vietnam_mobile_day
Vietnam mobile internet_2014_mwork_vietnam_mobile_dayVietnam mobile internet_2014_mwork_vietnam_mobile_day
Vietnam mobile internet_2014_mwork_vietnam_mobile_day
 
[Vietnam Mobile Day 2014] Tăng doanh thu quảng cáo cho mobile site và ứng dụn...
[Vietnam Mobile Day 2014] Tăng doanh thu quảng cáo cho mobile site và ứng dụn...[Vietnam Mobile Day 2014] Tăng doanh thu quảng cáo cho mobile site và ứng dụn...
[Vietnam Mobile Day 2014] Tăng doanh thu quảng cáo cho mobile site và ứng dụn...
 
[Vietnam Mobile Day 2014] Mobile money - Xu hướng thanh toán nhỏ trên mobile ...
[Vietnam Mobile Day 2014] Mobile money - Xu hướng thanh toán nhỏ trên mobile ...[Vietnam Mobile Day 2014] Mobile money - Xu hướng thanh toán nhỏ trên mobile ...
[Vietnam Mobile Day 2014] Mobile money - Xu hướng thanh toán nhỏ trên mobile ...
 
[Vietnam Mobile Day 2014] Mobile kết nối thế giới số và thế giới thực và vai ...
[Vietnam Mobile Day 2014] Mobile kết nối thế giới số và thế giới thực và vai ...[Vietnam Mobile Day 2014] Mobile kết nối thế giới số và thế giới thực và vai ...
[Vietnam Mobile Day 2014] Mobile kết nối thế giới số và thế giới thực và vai ...
 
[Vietnam Mobile Day 2014] The new mobile marketing channel: Social Wifi Marke...
[Vietnam Mobile Day 2014] The new mobile marketing channel: Social Wifi Marke...[Vietnam Mobile Day 2014] The new mobile marketing channel: Social Wifi Marke...
[Vietnam Mobile Day 2014] The new mobile marketing channel: Social Wifi Marke...
 
[Vietnam Mobile Day 2014] Cá nhân hóa và xác định Khách hàng mục tiêu trong q...
[Vietnam Mobile Day 2014] Cá nhân hóa và xác định Khách hàng mục tiêu trong q...[Vietnam Mobile Day 2014] Cá nhân hóa và xác định Khách hàng mục tiêu trong q...
[Vietnam Mobile Day 2014] Cá nhân hóa và xác định Khách hàng mục tiêu trong q...
 
[Vietnam Mobile Day 2014] Chiến lược thu hút người dùng cho ứng dụng tại thị ...
[Vietnam Mobile Day 2014] Chiến lược thu hút người dùng cho ứng dụng tại thị ...[Vietnam Mobile Day 2014] Chiến lược thu hút người dùng cho ứng dụng tại thị ...
[Vietnam Mobile Day 2014] Chiến lược thu hút người dùng cho ứng dụng tại thị ...
 
[Vietnam Mobile Day 2014] Thanh toán mobile, hiện tại và xu hướng- Nguyễn Chi...
[Vietnam Mobile Day 2014] Thanh toán mobile, hiện tại và xu hướng- Nguyễn Chi...[Vietnam Mobile Day 2014] Thanh toán mobile, hiện tại và xu hướng- Nguyễn Chi...
[Vietnam Mobile Day 2014] Thanh toán mobile, hiện tại và xu hướng- Nguyễn Chi...
 
[Vietnam Mobile Day 2014] Thanh toán bằng thẻ ngân hàng trên mobile chưa bao ...
[Vietnam Mobile Day 2014] Thanh toán bằng thẻ ngân hàng trên mobile chưa bao ...[Vietnam Mobile Day 2014] Thanh toán bằng thẻ ngân hàng trên mobile chưa bao ...
[Vietnam Mobile Day 2014] Thanh toán bằng thẻ ngân hàng trên mobile chưa bao ...
 
[Vietnam Mobile Day 2014] How to build a mobile store app in 5 minutes - Ng...
[Vietnam Mobile Day 2014] How to build a mobile store app in 5 minutes - 	 Ng...[Vietnam Mobile Day 2014] How to build a mobile store app in 5 minutes - 	 Ng...
[Vietnam Mobile Day 2014] How to build a mobile store app in 5 minutes - Ng...
 
[Vietnam Mobile Day 2014] Touch the future of the web - Nguyễn Việt Anh - Cou...
[Vietnam Mobile Day 2014] Touch the future of the web - Nguyễn Việt Anh - Cou...[Vietnam Mobile Day 2014] Touch the future of the web - Nguyễn Việt Anh - Cou...
[Vietnam Mobile Day 2014] Touch the future of the web - Nguyễn Việt Anh - Cou...
 
[Vietnam Mobile Day 2014] Xu hướng trong Mobile Learning, 2014 - Nguyễn Thàn...
[Vietnam Mobile Day 2014] Xu hướng trong Mobile Learning, 2014  - Nguyễn Thàn...[Vietnam Mobile Day 2014] Xu hướng trong Mobile Learning, 2014  - Nguyễn Thàn...
[Vietnam Mobile Day 2014] Xu hướng trong Mobile Learning, 2014 - Nguyễn Thàn...
 
[Vietnam Mobile Day 2014] Toàn cảnh thị trường game smartphone Việt Nam 2013....
[Vietnam Mobile Day 2014] Toàn cảnh thị trường game smartphone Việt Nam 2013....[Vietnam Mobile Day 2014] Toàn cảnh thị trường game smartphone Việt Nam 2013....
[Vietnam Mobile Day 2014] Toàn cảnh thị trường game smartphone Việt Nam 2013....
 
[Vietnam Mobile Day 2014] Toàn cảnh thị trường game smartphone Việt Nam 2013....
[Vietnam Mobile Day 2014] Toàn cảnh thị trường game smartphone Việt Nam 2013....[Vietnam Mobile Day 2014] Toàn cảnh thị trường game smartphone Việt Nam 2013....
[Vietnam Mobile Day 2014] Toàn cảnh thị trường game smartphone Việt Nam 2013....
 
[Vietnam Mobile Day 2014] Gamification and Mobile Learning - Nguyễn Hữu Ân -...
[Vietnam Mobile Day 2014]  Gamification and Mobile Learning - Nguyễn Hữu Ân -...[Vietnam Mobile Day 2014]  Gamification and Mobile Learning - Nguyễn Hữu Ân -...
[Vietnam Mobile Day 2014] Gamification and Mobile Learning - Nguyễn Hữu Ân -...
 
[Vietnam Mobile Day 2014] Cơ hội & thách thức cho Game Studio Việt trước tảng...
[Vietnam Mobile Day 2014] Cơ hội & thách thức cho Game Studio Việt trước tảng...[Vietnam Mobile Day 2014] Cơ hội & thách thức cho Game Studio Việt trước tảng...
[Vietnam Mobile Day 2014] Cơ hội & thách thức cho Game Studio Việt trước tảng...
 
[Vietnam Mobile Day 2014] Touch the future of the web - Nguyễn Việt Anh – Cou...
[Vietnam Mobile Day 2014] Touch the future of the web - Nguyễn Việt Anh – Cou...[Vietnam Mobile Day 2014] Touch the future of the web - Nguyễn Việt Anh – Cou...
[Vietnam Mobile Day 2014] Touch the future of the web - Nguyễn Việt Anh – Cou...
 
[Vietnam Mobile Day 2014] Mobile money - Xu hướng thanh toán nhỏ trên mobile ...
[Vietnam Mobile Day 2014] Mobile money - Xu hướng thanh toán nhỏ trên mobile ...[Vietnam Mobile Day 2014] Mobile money - Xu hướng thanh toán nhỏ trên mobile ...
[Vietnam Mobile Day 2014] Mobile money - Xu hướng thanh toán nhỏ trên mobile ...
 
[Vietnam Mobile Day 2014] Thanh toán bằng thẻ ngân hàng trên mobile chưa bao ...
[Vietnam Mobile Day 2014] Thanh toán bằng thẻ ngân hàng trên mobile chưa bao ...[Vietnam Mobile Day 2014] Thanh toán bằng thẻ ngân hàng trên mobile chưa bao ...
[Vietnam Mobile Day 2014] Thanh toán bằng thẻ ngân hàng trên mobile chưa bao ...
 

Dernier

Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
vu2urc
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
giselly40
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 

Dernier (20)

How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Evaluating the top large language models.pdf
Evaluating the top large language models.pdfEvaluating the top large language models.pdf
Evaluating the top large language models.pdf
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 

[Vietnam Mobile Day 2013] - For Higher Performance Mobile Applications

  • 1. Tran Vu Tat Binh
  • 2. I’ve done all kind of micro-optimizations, use good algorithms, choose the right data structures but still got serious performance issues in my mobile apps. Our online game took about 10 minutes to download 25 MB resources using 3G in the old version
  • 3. Performance issues?  The overall application runs slow.  The application makes other applications on phone run slower (yes, it can)  Users feel the application slow.  Be strict: it’s also performance issue if we can do much better but we don’t
  • 4. Some interesting points  Number of threads  Organizing threads  Multi-threading and network  Mobile network under the hood
  • 5. Number of threads  Using too many threads After launch Rush hour
  • 6. Number of threads  Using too many threads:  Overhead  Hard to control  Less time for each thread  Concurrency
  • 7. Number of threads  Using too few threads:  Not take advantage of system resources  Not so responsive
  • 8. Number of threads So how many? Flexible and should not be a fixed number, see the next “Organizing threads” for more details.
  • 9. Organizing threads  Usually, there are 3 kinds of task  Blocking UI task  Updater task  Lazy media task
  • 10. Organizing threads  Blocking UI task ○ When there are no other data on screen ○ When user definitely have to wait for updated data only Should be a single thread with high priority since user can not proceed if task is not done.
  • 11. Organizing threads  Updater task ○ Updating / refreshing ○ Loading more ○ User can still interact with existed data on screen ○ Can move to other screen without finishing task Should be a thread pool (suggest size 2-4)
  • 12. Organizing threads  Lazy media task ○ Thumbnails for existed data ○ A list/grid of images Should be 2 thread pools: one for downloading and one for decoding
  • 13. Organizing threads  Lazy media task (con.)  Usually most heavy task  focus optimizing  Why separating into downloading and decoding ○ Images might be in local cache already and decoding usually much faster than downloading, so don’t let downloading slow down the progress ○ Decoding pool size should be based on CPU cores ○ Downloading pool size should be based on network status
  • 14. Organizing threads  Decoding pool size NUMBER_OF_CORES = Runtime.getRuntime().availableProcessors(); mDecodeThreadPool = new ThreadPoolExecutor(NUMBER_OF_CORES, NUMBER_OF_CORES, KEEP_ALIVE_TIME, KEEP_ALIVE_TIME_UNIT, mDecodeWorkQueue);
  • 15. Organizing threads  Downloading pool size  Normal: ○ Fixed size (may be 8 like in some tutorials)  More optimized: ○ 2G – size 4 ○ 3G – size 8 ○ 4G – size 16 (or more) ○ WIFI – size 8  Much more optimized: ○ Based on network speed, increasing size if can still download faster, decreasing size if still not slower, until get the best size.
  • 16. Organizing threads  Why variable size is better choice: 2G pool size 2 2G pool size 4 2G pool size 8
  • 17. Organizing threads  Why variable size is better choice: 3G pool size 4 3G pool size 8 3G pool size 24
  • 18. Organizing threads  Facts:  Each connection has a limited bandwidth  The phone’s network connection has a overall limited bandwidth  There are network latency causing “gaps” while downloading
  • 19. Organizing threads  Downloading pool size  Too small size ○ Waste network bandwidth ○ Drain battery life if using mobile network ○ Slow  Too large size ○ Take more time to show individual image (not overall images on screen)  users feel slow ○ TCP congestion control ○ Slower to start downloading new images when scrolling Variable size based on network status is good choice but need more time to implement
  • 20. Organizing threads  Conclusion:  Blocking UI task – 1 thread  Updater task – 1 thread pool size 2 - 4  Lazy media task – 2 thread pools ○ 1 thread pool for decoding size = available cores ○ 1 thread pool for downloading size based on network status
  • 21. Mobile network under the hood  Online applications like messenger, news reader, social app or online game… some got serious issues when using mobile network ○ Battery drain ○ Slow response
  • 22. Mobile network  Typical 3G wireless radio state machine (source)
  • 23. Mobile network  Messenger application ○ Small data message ○ Transferring more frequently ○ No fixed schedule
  • 24. Mobile network  Online game ○ Small data message ○ Transferring much more frequently ○ Usually fixed schedule ○ Responsiveness is importance
  • 25. Mobile network  Social app  News reader  Photo sharing  Music app …
  • 26. Mobile network  Optimize data to transfer (as always)  Batch operation  Prefetch  When receive, if need to transmit then do quick  If possible, do at the same time with other apps
  • 27. Q&A