SlideShare una empresa de Scribd logo
1 de 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!

Más contenido relacionado

Más de GameLandVN

Mobile Game Asia 2015 Ho Chi Minh City: Building a sustainable eSports ecosys...
Mobile Game Asia 2015 Ho Chi Minh City: Building a sustainable eSports ecosys...Mobile Game Asia 2015 Ho Chi Minh City: Building a sustainable eSports ecosys...
Mobile Game Asia 2015 Ho Chi Minh City: Building a sustainable eSports ecosys...GameLandVN
 
Mobile Game Asia 2015 Ho Chi Minh City: An overview of the mobile game market...
Mobile Game Asia 2015 Ho Chi Minh City: An overview of the mobile game market...Mobile Game Asia 2015 Ho Chi Minh City: An overview of the mobile game market...
Mobile Game Asia 2015 Ho Chi Minh City: An overview of the mobile game market...GameLandVN
 
Mobile Game Asia 2015 Ho Chi Minh City: Monetization strategies in Southeast ...
Mobile Game Asia 2015 Ho Chi Minh City: Monetization strategies in Southeast ...Mobile Game Asia 2015 Ho Chi Minh City: Monetization strategies in Southeast ...
Mobile Game Asia 2015 Ho Chi Minh City: Monetization strategies in Southeast ...GameLandVN
 
Mobile Game Asia 2015 Ho Chi Minh City: Rewarded video ads
Mobile Game Asia 2015 Ho Chi Minh City: Rewarded video adsMobile Game Asia 2015 Ho Chi Minh City: Rewarded video ads
Mobile Game Asia 2015 Ho Chi Minh City: Rewarded video adsGameLandVN
 
Mobile Game Asia 2015 Ho Chi Minh City: The role of a game publisher in Vietnam
Mobile Game Asia 2015 Ho Chi Minh City: The role of a game publisher in VietnamMobile Game Asia 2015 Ho Chi Minh City: The role of a game publisher in Vietnam
Mobile Game Asia 2015 Ho Chi Minh City: The role of a game publisher in VietnamGameLandVN
 
Mobile Game Asia 2015 Ho Chi Minh City: Predictive monetization
Mobile Game Asia 2015 Ho Chi Minh City: Predictive monetizationMobile Game Asia 2015 Ho Chi Minh City: Predictive monetization
Mobile Game Asia 2015 Ho Chi Minh City: Predictive monetizationGameLandVN
 
Mobile Game Asia 2015 Ho Chi Minh City: The roadmap of IP creation
Mobile Game Asia 2015 Ho Chi Minh City: The roadmap of IP creationMobile Game Asia 2015 Ho Chi Minh City: The roadmap of IP creation
Mobile Game Asia 2015 Ho Chi Minh City: The roadmap of IP creationGameLandVN
 
Cloud Powered Mobile Apps with Azure
Cloud Powered Mobile Apps with AzureCloud Powered Mobile Apps with Azure
Cloud Powered Mobile Apps with AzureGameLandVN
 
Windows app & Microsoft's support
Windows app & Microsoft's supportWindows app & Microsoft's support
Windows app & Microsoft's supportGameLandVN
 
Kinh nghiệm phát triển Captain Strike
Kinh nghiệm phát triển Captain StrikeKinh nghiệm phát triển Captain Strike
Kinh nghiệm phát triển Captain StrikeGameLandVN
 
Microsoft BizSpark
Microsoft BizSparkMicrosoft BizSpark
Microsoft BizSparkGameLandVN
 
Microsoft Azure Introduction
Microsoft Azure IntroductionMicrosoft Azure Introduction
Microsoft Azure IntroductionGameLandVN
 
OGDC 2014: Animation workflow with Spine in Tiny Busters
OGDC 2014: Animation workflow with Spine in Tiny BustersOGDC 2014: Animation workflow with Spine in Tiny Busters
OGDC 2014: Animation workflow with Spine in Tiny BustersGameLandVN
 
OGDC 2014: Vietnam Smartphone game market 2013 overview
OGDC 2014: Vietnam Smartphone game market 2013 overviewOGDC 2014: Vietnam Smartphone game market 2013 overview
OGDC 2014: Vietnam Smartphone game market 2013 overviewGameLandVN
 
OGDC 2014: Speed up and make quality for your 3d models
OGDC 2014: Speed up and make quality for your 3d modelsOGDC 2014: Speed up and make quality for your 3d models
OGDC 2014: Speed up and make quality for your 3d modelsGameLandVN
 
OGDC 2014: Sky Garden Mobile conceptualization: From PC to Mobile
OGDC 2014: Sky Garden Mobile conceptualization: From PC to MobileOGDC 2014: Sky Garden Mobile conceptualization: From PC to Mobile
OGDC 2014: Sky Garden Mobile conceptualization: From PC to MobileGameLandVN
 
OGDC 2014: One-Man Studio: How to make a game prototype
OGDC 2014: One-Man Studio: How to make a game prototypeOGDC 2014: One-Man Studio: How to make a game prototype
OGDC 2014: One-Man Studio: How to make a game prototypeGameLandVN
 
OGDC 2014: Program farmery by cocos2dx
OGDC 2014: Program farmery by cocos2dxOGDC 2014: Program farmery by cocos2dx
OGDC 2014: Program farmery by cocos2dxGameLandVN
 
OGDC 2014: Optimize or Die: Key disciplines to optimize your mobile game
OGDC 2014: Optimize or Die: Key disciplines to optimize your mobile gameOGDC 2014: Optimize or Die: Key disciplines to optimize your mobile game
OGDC 2014: Optimize or Die: Key disciplines to optimize your mobile gameGameLandVN
 
OGDC 2014: Tips and Tricks for seasonal events and community building in Drag...
OGDC 2014: Tips and Tricks for seasonal events and community building in Drag...OGDC 2014: Tips and Tricks for seasonal events and community building in Drag...
OGDC 2014: Tips and Tricks for seasonal events and community building in Drag...GameLandVN
 

Más de GameLandVN (20)

Mobile Game Asia 2015 Ho Chi Minh City: Building a sustainable eSports ecosys...
Mobile Game Asia 2015 Ho Chi Minh City: Building a sustainable eSports ecosys...Mobile Game Asia 2015 Ho Chi Minh City: Building a sustainable eSports ecosys...
Mobile Game Asia 2015 Ho Chi Minh City: Building a sustainable eSports ecosys...
 
Mobile Game Asia 2015 Ho Chi Minh City: An overview of the mobile game market...
Mobile Game Asia 2015 Ho Chi Minh City: An overview of the mobile game market...Mobile Game Asia 2015 Ho Chi Minh City: An overview of the mobile game market...
Mobile Game Asia 2015 Ho Chi Minh City: An overview of the mobile game market...
 
Mobile Game Asia 2015 Ho Chi Minh City: Monetization strategies in Southeast ...
Mobile Game Asia 2015 Ho Chi Minh City: Monetization strategies in Southeast ...Mobile Game Asia 2015 Ho Chi Minh City: Monetization strategies in Southeast ...
Mobile Game Asia 2015 Ho Chi Minh City: Monetization strategies in Southeast ...
 
Mobile Game Asia 2015 Ho Chi Minh City: Rewarded video ads
Mobile Game Asia 2015 Ho Chi Minh City: Rewarded video adsMobile Game Asia 2015 Ho Chi Minh City: Rewarded video ads
Mobile Game Asia 2015 Ho Chi Minh City: Rewarded video ads
 
Mobile Game Asia 2015 Ho Chi Minh City: The role of a game publisher in Vietnam
Mobile Game Asia 2015 Ho Chi Minh City: The role of a game publisher in VietnamMobile Game Asia 2015 Ho Chi Minh City: The role of a game publisher in Vietnam
Mobile Game Asia 2015 Ho Chi Minh City: The role of a game publisher in Vietnam
 
Mobile Game Asia 2015 Ho Chi Minh City: Predictive monetization
Mobile Game Asia 2015 Ho Chi Minh City: Predictive monetizationMobile Game Asia 2015 Ho Chi Minh City: Predictive monetization
Mobile Game Asia 2015 Ho Chi Minh City: Predictive monetization
 
Mobile Game Asia 2015 Ho Chi Minh City: The roadmap of IP creation
Mobile Game Asia 2015 Ho Chi Minh City: The roadmap of IP creationMobile Game Asia 2015 Ho Chi Minh City: The roadmap of IP creation
Mobile Game Asia 2015 Ho Chi Minh City: The roadmap of IP creation
 
Cloud Powered Mobile Apps with Azure
Cloud Powered Mobile Apps with AzureCloud Powered Mobile Apps with Azure
Cloud Powered Mobile Apps with Azure
 
Windows app & Microsoft's support
Windows app & Microsoft's supportWindows app & Microsoft's support
Windows app & Microsoft's support
 
Kinh nghiệm phát triển Captain Strike
Kinh nghiệm phát triển Captain StrikeKinh nghiệm phát triển Captain Strike
Kinh nghiệm phát triển Captain Strike
 
Microsoft BizSpark
Microsoft BizSparkMicrosoft BizSpark
Microsoft BizSpark
 
Microsoft Azure Introduction
Microsoft Azure IntroductionMicrosoft Azure Introduction
Microsoft Azure Introduction
 
OGDC 2014: Animation workflow with Spine in Tiny Busters
OGDC 2014: Animation workflow with Spine in Tiny BustersOGDC 2014: Animation workflow with Spine in Tiny Busters
OGDC 2014: Animation workflow with Spine in Tiny Busters
 
OGDC 2014: Vietnam Smartphone game market 2013 overview
OGDC 2014: Vietnam Smartphone game market 2013 overviewOGDC 2014: Vietnam Smartphone game market 2013 overview
OGDC 2014: Vietnam Smartphone game market 2013 overview
 
OGDC 2014: Speed up and make quality for your 3d models
OGDC 2014: Speed up and make quality for your 3d modelsOGDC 2014: Speed up and make quality for your 3d models
OGDC 2014: Speed up and make quality for your 3d models
 
OGDC 2014: Sky Garden Mobile conceptualization: From PC to Mobile
OGDC 2014: Sky Garden Mobile conceptualization: From PC to MobileOGDC 2014: Sky Garden Mobile conceptualization: From PC to Mobile
OGDC 2014: Sky Garden Mobile conceptualization: From PC to Mobile
 
OGDC 2014: One-Man Studio: How to make a game prototype
OGDC 2014: One-Man Studio: How to make a game prototypeOGDC 2014: One-Man Studio: How to make a game prototype
OGDC 2014: One-Man Studio: How to make a game prototype
 
OGDC 2014: Program farmery by cocos2dx
OGDC 2014: Program farmery by cocos2dxOGDC 2014: Program farmery by cocos2dx
OGDC 2014: Program farmery by cocos2dx
 
OGDC 2014: Optimize or Die: Key disciplines to optimize your mobile game
OGDC 2014: Optimize or Die: Key disciplines to optimize your mobile gameOGDC 2014: Optimize or Die: Key disciplines to optimize your mobile game
OGDC 2014: Optimize or Die: Key disciplines to optimize your mobile game
 
OGDC 2014: Tips and Tricks for seasonal events and community building in Drag...
OGDC 2014: Tips and Tricks for seasonal events and community building in Drag...OGDC 2014: Tips and Tricks for seasonal events and community building in Drag...
OGDC 2014: Tips and Tricks for seasonal events and community building in Drag...
 

Último

Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsRoshan Dwivedi
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
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 slidevu2urc
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
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...Neo4j
 
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 AutomationSafe Software
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 
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 Servicegiselly40
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024The Digital Insurer
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
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 textsMaria Levchenko
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...gurkirankumar98700
 
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 Scriptwesley chun
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Paola De la Torre
 

Último (20)

Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live StreamsTop 5 Benefits OF Using Muvi Live Paywall For Live Streams
Top 5 Benefits OF Using Muvi Live Paywall For Live Streams
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
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
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
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...
 
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
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
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
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.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
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
 
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
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101
 

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