TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
Continuous Profiling for Android Game Performance Optimization
1. Continuous Profiling for
Android Game Performance Optimization
KLab Inc.
Yoshio Hanawa
Software Engineer
KLab Inc.
Suguru Oho
Software Engineer
KLab Inc.
Sho Hosoda
Unity Engineer
KLab Inc.
KLab Inc.
2. About us
KLab is a Mobile gaming
company in Japan.
We have a number of games available globally
based on Japanese IPs.
3. 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
KLab Inc.
4. 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
KLab Inc.
6. 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
KLab Inc.
7. 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
Convert
Binary Log CSV
KLab Inc.
8. 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...
KLab Inc.
10. 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
KLab Inc.
11. ● 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)
Auto-Profiling System
KLab Inc.
12. ● 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
KLab Inc.
14. ● Services on GCP
○ Cloud Storage + Cloud Functions
■ Storing and Processing data from Android
○ BigQuery
■ Data storage for dashboard
● Google Data Studio
○ Sharing visualized analytics for team members
Dashboard System Components
KLab Inc.
15. ● Pros
○ Lower cost than RDB
○ Almost constant performance for massive data
○ Supported by popular business intelligence tools
● Cons
○ 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
KLab Inc.
16. ● Pros
○ Free BI tool (Thanks Google!)
○ Provides access control with Google account
● Cons
○ Limited chart type and customizability
Good enough for our dashboard
Pros & Cons of Data Studio
KLab Inc.
18. 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
[ms]
etc...
Detailed Report
KLab Inc.
20. ● Profile and show other performance indices
○ Memory consumption
○ GPU
○ Network I/O
○ Etc.
● More stability and usability
○ Monitoring auto-profiling system
○ Web interface for controlling auto-profiling system
Future works
KLab Inc.
21. 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.
Conclusion
KLab Inc.