SlideShare a Scribd company logo
1 of 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!

More Related Content

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

More from 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...
 

Recently uploaded

Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
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 RobisonAnna Loughnan Colquhoun
 
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
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 
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...Martijn de Jong
 
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
 
🐬 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
 
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
 
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
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
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
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?Igalia
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
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
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Enterprise Knowledge
 
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
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
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 Nanonetsnaman860154
 

Recently uploaded (20)

Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
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
 
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
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
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...
 
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...
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
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?
 
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
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
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
 
A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
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...
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
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
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
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
 

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