~/talk

Improving App Performance With Custom Thread Pools

Talkat droidcon London 2024 · 2024-10-31..11-01· [concurrency]
links:none on file
slides:none on file

A small app that fetches Flickr images every 200m reveals dozens of threads: coroutines ~5, OkHttp ~5, Room ~4 plus OS and Google services — easily 60+ threads when counting default and IO dispatchers. The demo replaces per-library pools with a shared ThreadPoolExecutor configured with corePoolSize = Runtime.getRuntime().availableProcessors() and keepAlive = 60s; coroutines and OkHttp thread counts disappear while Room keeps its threads. It reduces memory/CPU but risks thread starvation and lost task priority.

AI-written summary · about

  1. 0:00Thread pool impact on performance
  2. 1:08Default and IO sizes in coroutines
  3. 2:32Library thread pools overlap
  4. 3:36Measuring threads offline
  5. 5:24Custom thread pool executor
  6. 6:32Integrating with coroutines
  7. 7:56Disadvantages of shared pools
  8. 8:59Avoid shared thread pools
  9. 9:43Refactoring library instances
  10. 10:23Thread pool optimization
~/search
type to search 6,249 conferences, 138,987 speakers and 185,172 talks
~/help
cmdctrl k
search every conference, speaker and series
/
focus the filter search
h
home
c
conferences
s
speakers
e
series
t
light / dark — the status bar button does the same
?
this help
esc
close this, then clear every filter — or just the search, while you are typing in it

Ignored while you are typing. Pages without a filter rail have no search to focus.