Successfully reported this slideshow.
You’ve unlocked unlimited downloads on SlideShare!
Continuous Profiling for Android Game Performance Optimization
Continuous Profiling for
Android Game Performance Optimization
KLab is a Mobile gaming
company in Japan.
We have a number of games available globally
based on Japanese IPs.
Profiling on Mobile Is Painful
● No dedicated debug hardware
● Many different devices / profilers
● Troublesome to set up correctly
● Not easy for non-engineers
So we profiled on only a few devices for a limited set of cases...
Too late to notice performance degradation
Our Solution : Continuous Profiling
● Automatic profiling integrated with CI/CD
● Non-engineers can view the analysis results on the dashboard
We can detect performance degradation sooner
and start optimizing the bottlenecks immediately
Part 1: How to Profile the Application
Scripting allows the Unity player to save profiling data in-device as a Binary Log file.
We can load and view this file in the Unity Editor using the Profiler window.
// Saves profiling data
Profiler.logFile = "mylog";
Profiler.enableBinaryLog = true;
Profiler.enabled = true;
Viewing binary log using Unity Profiler window
Summarizing Profiling Data
● We developed a Converter with Unity Technologies Japan.
● It summarize results for each Unity’s CPU main thread method.
○ processing time ( average / sum / min / max )
○ number of calls
○ call stack
Binary Log CSV
Changes to the Application for Profiling
1. Automatic app play
○ It is necessary for automatic profiling.
○ Execute a fixed scenario, such as the transition to the target scene.
2. Control start and end of profiling
○ We want to profile only the target scene.
3. Save JSON for meta information
○ Unity Version / Platform / Device Model / Scene Name / etc...
We can build an APK package by sending a command to a bot on Slack.
The profiling system starts automatically when the APK build is complete.
The team members don’t need to be aware of the profiling.
Build System Integration
● Python script
● AAPT (Android Asset Packaging Tool)
○ Detect Bundle ID
○ Detect main activity name
● ADB (Android Debug Bridge)
○ Install apk
○ Run application
○ Uninstall, file transfer and cleanup
● Unity (Execute convert script)
● Error recovery
○ Wait and retry loop is better
○ Reset ADB server (by kill-server, start-server)
○ Difference between devices and OS version
● Keep device condition clean
○ Use some ADB subcommands
■ Kill: process kill
■ Kill-all: kill all background processes
■ Pm clear: clear all data related packages
○ Wait for cooling
● Device Settings
○ Developer mode
○ “Stay awake” & Select MTP
Difficulty with REAL devices
● Services on GCP
○ Cloud Storage + Cloud Functions
■ Storing and Processing data from Android
■ Data storage for dashboard
● Google Data Studio
○ Sharing visualized analytics for team members
Dashboard System Components
○ Lower cost than RDB
○ Almost constant performance for massive data
○ Supported by popular business intelligence tools
○ Slower query than RDB (1-10 sec)
○ Append-only storage by design
Suitable for data analytics even if not "big data."
Pros & Cons of BigQuery
○ Free BI tool (Thanks Google!)
○ Provides access control with Google account
○ Limited chart type and customizability
Good enough for our dashboard
Pros & Cons of Data Studio
Top page shows
summary of multiple profiling
Click on the drilldown link on
the top page to go this page.
● By Category
○ Breakdown pie chart
○ Checking upper limit
● By Method
○ Average frame timing
Performance Improvement Due To Optimization
● Profile and show other performance indices
○ Memory consumption
○ Network I/O
● More stability and usability
○ Monitoring auto-profiling system
○ Web interface for controlling auto-profiling system
We developed a fully-automated profiling system for Android games.
Freed from painful manual profiling tasks
Non-engineer friendly system
As a result
We can detect bottlenecks in our games.
The iteration of performance optimization becomes faster.