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 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
 

Plus 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...
 

Dernier

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 MenDelhi Call girls
 
🐬 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
 
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
 
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
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
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
 
[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
 
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
 
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)wesley chun
 
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.pdfEnterprise Knowledge
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfhans926745
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?Antenna Manufacturer Coco
 
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 organizationRadu Cotescu
 
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
 
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
 
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.pdfChristopherTHyatt
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
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
 

Dernier (20)

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
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
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
 
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
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
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
 
[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
 
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
 
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)
 
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
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdf
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
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
 
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
 
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...
 
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
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
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
 

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