Battery Instrumentation at Facebook
Article Summary
Facebook was flying blind on battery drain across a billion devices. User-facing battery percentage? Too noisy, too coarse, and deliberately inaccurate by design.
Three engineers from Facebook's New York team break down their production battery instrumentation system for iOS and Android. They explain why traditional profiling tools fail at scale and how they built a modeling approach that catches regressions before they ship.
Key Takeaways
- CPU energy scales as cube of frequency, not linearly
- Radio tail time from network requests varies dramatically by carrier and connection type
- CPU spin detector aggregates stack traces across millions of devices to pinpoint exact regression lines
- Power model uses device XML profiles (Android) and power monitor measurements (iOS)
- A/B test caught 10% battery increase before shipping to production
Critical Insight
Facebook built a component-level battery monitoring system that models energy drain without physical noise, catching regressions in hours instead of relying on user complaints.