Enhancing Chat Performance on PhonePe Android - Part 2
Article Summary
Ayush Bagaria from PhonePe reveals how CPU profiling and thread optimization slashed chat load times by 30%. Most Android apps are sitting on similar performance gains.
This is Part 2 of PhonePe's deep dive into optimizing their Android chat experience. After achieving 20% improvement through database and pagination fixes (Part 1), the team turned to CPU profiling and thread management to squeeze out even more performance.
Key Takeaways
- Replaced postValue() with setValue() in LiveData to eliminate unnecessary Handler.post() calls
- All databases shared one 4-thread executor pool, creating massive bottlenecks
- Separated database executors and paging library threads for parallel execution
- View stubs and lazy dependency injection reduced fragment inflation time
- Passing metadata between screens eliminated redundant database fetches for 60% of users
Critical Insight
Combined with Part 1 optimizations, PhonePe reduced chat page load time (P90) from 1.5s to 750ms, a 50% improvement over 9 months.