Shai Barack, who leads Android Platform Performance and System Health at Google, joins the discussion on balancing performance and battery life. The conversation dives into the intricacies of system health, measuring app efficiency, and using tools like Perfetto and Compiler Explorer. They tackle trade-offs between performance and battery longevity, the importance of telemetry data, and optimizing app performance with a focus on collaborative practices. Insights on memory management and open-source tools further enrich the dialogue.
System health balances resource usage to optimize performance without sacrificing battery life, requiring collaboration between development teams and app developers.
Telemetry data plays a crucial role in identifying performance issues and trends, facilitating informed decision-making for system health management.
Developers are encouraged to leverage tools like Compiler Explorer and Perfetto to experiment with code, optimize performance, and understand critical metrics.
Deep dives
Understanding System Health
System health refers to finding the balance between various resources on a device to ensure optimal performance without compromising battery life. For instance, simply running the CPU at maximum frequency may enhance performance but result in overheating issues, while minimizing CPU usage could prolong battery life at the cost of performance quality. This balance must be managed across the entire stack of the device, from the kernel to the user applications, necessitating cooperation between development teams. Achieving this requires a strategic approach in making changes to the platform while also educating app developers on best practices for maintaining system health.
Educating and Empowering Developers
A significant portion of the system health team's work is centered around training and empowering developers to understand critical metrics relevant to system performance and health. The team recognizes the value of metrics and data collection in identifying areas for improvement, and thus encourages app developers to conduct their own experiments and gather feedback. By offering resources and tools, such as documentation and APIs, developers can learn how to optimize their applications effectively without solely relying on system health interventions. This initiative aligns with the goal of fostering a collaborative environment where all teams can contribute to better overall performance.
The Role of Telemetry in Performance Monitoring
The team emphasizes the importance of telemetry in gathering performance data from real-world user experiences, which has transformed the approach to assessing system health. Through tools like Perfetto, the team can monitor device performance and identify issues without excessive overhead of constantly collecting data from all devices. This sampling strategy allows the team to make informed decisions about performance management while minimizing the impact on user experience. By analyzing the telemetry data, the team can recognize trends and provide targeted feedback to developers, enabling a proactive approach to preventing performance degradation.
Trade-offs in Performance and Battery Life
There exists a fundamental trade-off between performance and battery life, where applications often aim for rapid responsiveness at the expense of power consumption. The Android framework’s lifecycle management enables intelligent scheduling and resource allocation to prioritize user-facing tasks while moderating background activity. For instance, the operating system adjusts resource access based on whether an app is in the foreground or background to balance user demands and device capabilities. By creating an application framework that respects this trade-off, developers can build applications that provide excellent performance while concurrently extending battery life.
Optimizing Applications with Tools and Best Practices
App developers are encouraged to utilize tools like Compiler Explorer and Profetto to identify inefficiencies and optimize their applications for better performance. These tools allow developers to experiment with their code in real-time, providing insights into how code changes may impact performance. Effective use of R8, a code shrinker and optimizer, can significantly reduce app size and improve launch times, but requires awareness of its heuristics and behavior in real contexts. Therefore, engaging with these profiling tools and understanding performance metrics become essential practices for developers to ensure their apps operate effectively within the resource constraints of Android devices.
In this episode Chet, Romain and Tor chat with Shai Barack about how the Android platform team studies performance and understands system health - and what is system health anyway? We talk about measuring performance, deciding trade-offs, and our favorite tools such as Perfetto, Compiler Explorer, and Android Studio's Memory Profiler.
Chapters:
Intro (00:00)
System health (0:27)
Efforts to make apps more efficient (3:35)
Telemetry data (5:59)
Trade offs between long battery life and good performance (8:21)
Scheduling groups (10:38)
Static drain (13:32)
Collaborating with App developers vs operating system (19:10)
High refresh rates (23:26)
Reach vs engagement (32:02)
What tools does your team use to optimize performance? (34:10)
Godbolt.org (37:09)
Demystifying (39:39)
The best tools are multi-player (43:52)
R8 or R-Not? (45:42)
Optimizing for feature sets (48:05)
Tools, not Rules (50:08)
What are the tools I should be aware of as an app developer looking to upscale performance? (54:36)
Allocation tracker (55:37)
Open source tools (57:08)
Useful resources for devs to understand various tools (59:04)