Professional Documents
Culture Documents
Optimization & Performance Tuning in Mobile Systems, Advanced Level
Optimization & Performance Tuning in Mobile Systems, Advanced Level
Optimization & Performance Tuning in Mobile Systems, Advanced Level
in Mobile Systems,
Advanced Level
Raghu Sesha Iyengar
Agenda
Optimization
What is optimization
Why optimize
When to optimize
Performance parameters
Profilers
Benchmark
References
What is Optimization
What is Optimization
HARDWARE
Processor
RAM
Peripherals
Why to optimize
Major considerations of mobile phone software are:
Portability
User experience
Battery life
Battery technology not catching up with growth in processor power
Security
Software development time
Phone or Supercomputer
Reliability
Current drain
Usability
Performance (speed, memory, responsiveness)
Look and feel
Functionality
Open Source
Pitfalls of optimization
Portability
Repetitive process
Faster processors
Coprocessors
Hardware Accelerators
What is the optimal time to calculate the next move in a chess game?
When to optimize
Start
Platform and
framework Decisions
Compiler/Assembler Decisions
Design
Optimize Code
Code
Optimize Design
Measure Parameters
Compare with
Benchmark
Stop
When to optimize
Effort
Returns
High
Low
Code Optimization
Design Optimization
Compiler Decisions
Processor
Speed
Ram
Internal
Memory
Display
OS
Camera
Droid
550MHZ
256MB
16GB
480x854px
Android
5MP
HTC Nexus
One
1GHZ
512MB
512MB
480x800px
Android
5MP
iPhone 3GS
600MHz
256MB
16GB
320x480px
MAC OS X
3MP
Nokia
N900
600MHz
256MB
32GB
800x480px
Linux
5MP
Samsung
S8500 Wave
1GHz
512MB
2GB
480x800px
Bada
5MP
LG Gw990
480x1024px
MeeGo
5MP
Low
High
Source: http://www.phonegg.com
When to optimize
Effort
Returns
High
Low
Code Optimization
Design Optimization
Compiler Decisions
Low
High
Data Forwarding
Branch Prediction
Predicate Register
Delayed Branch
Cache
When to optimize
Effort
Returns
High
Low
Code Optimization
Design Optimization
Compiler Decisions
Low
High
Optimization levels
Dynamic and Static linking
Prelinking
Pragma
Compiler options
JIT
When to optimize
Effort
Returns
High
Low
Code Optimization
Design Optimization
UI interactions
Background computations
System calls for file op
Compiler Decisions
Speed Vs Memory
Low
High
Hash Vs Binary
Background writes
Algorithm choices
fopen Vs open
Create/destroy resources
Memory
peripherals
When to optimize
Effort
Returns
High
Low
Other decisions
Database decisions
Code Optimization
Design Optimization
Compiler Decisions
Low
Extensibility
Application code
Native libraries
API definitions
High
Do we need database
Which data base to use
Sockets Vs Intents
XML parser
SAX Vs DOM
When to optimize
Effort
Returns
High
Low
Code Optimization
Design Optimization
Compiler Decisions
Low
80/20 rule.
Area for compiler research
Control flow optimizations
High
Optimization Vs Readability
Assembly
When to optimize
Effort
Returns
High
Low
Code Optimization
Design Optimization
Compiler Decisions
Low
High
When to optimize
Start
Platform and
framework Decisions
Compiler/Assembler
Decisions
Design
Optimize Code
Code
Optimize Design
Measure Parameters
Compare with
Benchmark
Stop
Speed
Memory
Response Time
Launch time
Response to user input
Current Drain
Security
Application Security
Device Security
Network Security
Profilers
Speed Profilers
Event based (e.g., gcov, gprofs number of calls etc, codewarrior, eclipse profiler)
Sampling based (e.g., gprofs runtime figures)
Memory Profilers
Profilers
Manual
High Speed Camera setup
Customized setup
Security Profiler
Application security
Device Security
Anti virus
Network security
FindBugs, Klocworks
Netfilter
Appropriate IDEs
Benchmarks
Internal Benchmarks
External Benchmarks
Industry Standard
Embedded Microprocessor Benchmark Consortium
(EEMBC)
Standard Performance Evaluation Corporation (SPEC)
Open Source
I/O intensive (IOMETER)
CPU intensive (PI calculator, LINPACK)
References
Various Processors power dissipation details
http://en.wikipedia.org/wiki/List_of_CPU_power_dissipation
Summary of various processors based on different architectures:
http://www.linuxfordevices.com/c/a/Linux-For-Devices-Articles/Embedded-Processor-and-SystemonChip-Quick-Reference-Guide/
openMP
http://openmp.org/wp/
Boostpro libaries:
http://www.boostpro.com
Vector signal processing library
http://gpu-vsipl.gtri.gatech.edu/
Assembly and high level optimization techniques
http://www.agner.org/optimize/
Optimizing Java code
http://www.glenmccl.com/jperf/index.htm
Optimization levels in GCC:
http://www.linuxjournal.com/article/7269
Optimization levels in CodeWarrior
http://www.freescale.com/infocenter/Codewarrior/index.jsp?topic=/com.freescale.doc.microcontrollers.targeting.manual/050_CWBuildProps.ColdFire_Compiler__Optimization.html
Profiler basics
http://en.wikipedia.org/wiki/Profiling_%28computer_programming%29
Summary of profiling tools:
http://ktown.kde.org/~seli/memory/analysis.html
Valgrind:
http://valgrind.org/
Example codewarrior profiler
http://www.freescale.com/files/soft_dev_tools/doc/user_guide/IDE_5.5_UG_Profiler.pdf
References
Kernel profile and OProfile
http://omappedia.org/wiki/Android_Debugging
WinCE kernel profiler:
http://discovertheexperience.blogspot.com/2009/02/windows-ce-kernel-profiler.html
iPhone Vs Android Development:
http://blogs.zdnet.com/Burnette/?p =682&tag=col1;post-682
Low level optimization resources
http://www.agner.org/optimize/
Iphone security
http://www.itsecurity.com/features/iphone -security-threat/
Email security
http://www.itsecurity.com /email-security/
Jit: http://www.answers.com/topic/just-in-time-compilation
Assembly optimization tips:
http://www.mark.masmcode.com/
Compiler, C++ optimization:
http://www.agner.org/optimize/
Book on Software optimization:
Software Optimization for High-Performance Computing By Kevin R. Wadleigh, Isom L. Crawford
Java benchmarks
http://java-phones.com/tools/fpc-bench-303
Android benchmarks:
http://mobileswdev.wordpress.com/2009/10/27/android-benchmarks/
Thank You
Raghu Sesha Iyengar
raghus@motorola.com
Additional Slides
When to optimize
Effort
Returns
High
Low
Code Optimization
Design Optimization
Compiler Decisions
Low
High
When to optimize
Effort
Returns
High
Low
Code Optimization
Design Optimization
Compiler Decisions
Low
High
When to optimize
Effort
Returns
High
Low
Code Optimization
Design Optimization
Compiler Decisions
Low
High
When to optimize
Effort
Returns
High
Low
Code Optimization
Design Optimization
Compiler Decisions
Low
High
Source:http://www.linuxjournal.com/article/7269
When to optimize
Effort
Returns
High
Low
-O0
No optimization
-O1
-O2
-Os
-O3
Code Optimization
Design Optimization
Compiler Decisions
Low
High
Source:http://www.linuxjournal.com/article/7269
When to optimize
Effort
Returns
High
Low
Code Optimization
Design Optimization
Compiler Decisions
Low
High
Source:http://reallylongword.org/prelink-2/
When to optimize
Effort
Returns
High
Low
Code Optimization
Design Optimization
Compiler Decisions
Low
High
When to optimize
Effort
Returns
High
Low
Lookup Tables
Code Optimization
Design Optimization
Compiler Decisions
Boundary checking
Low
High