Professional Documents
Culture Documents
2
Agenda
Delivering Software Innovation
Video Demonstration
3
Principals
Delivering Software Innovation
The problem:
Getting an embedded Linux based product from power-on to a
useful state of functionality in an acceptable amount of time.
Many innovative solutions exist: Suspend / Hibernate / etc
This presentation focuses on cold-boot optimisation
Specialising software for specific needs of a product
And this works because prior to optimisation the software will be:
– More General purpose
– Likely to contain functionality your device doesn‟t require
which will result in more initialisation and a larger image
– More Convenient and flexible
– Likely to probe and detect hardware which you know will
always be there which will contribute to boot delay.
There is no silver bullet here – all that is required is:
Disciplined Analysis + Common Sense + Pragmatic Approach
4
The Approach
Delivering Software Innovation
Measure
Identify boot Remove un- Optimise
boot time Re-order
time necessary required
across the initialisation
functionality functionality functionality
board
5
The Approach
Delivering Software Innovation
Measure
Identify boot Remove un- Optimise
boot time Re-order
time necessary required
across the initialisation
functionality functionality functionality
board
6
The Approach
Delivering Software Innovation
Measure
Identify boot Remove un- Optimise
boot time Re-order
time necessary required
across the initialisation
functionality functionality functionality
board
7
The Approach
Delivering Software Innovation
Measure
Identify boot Remove un- Optimise
boot time Re-order
time necessary required
across the initialisation
functionality functionality functionality
board
8
The Approach
Delivering Software Innovation
Measure
Identify boot Remove un- Optimise
boot time Re-order
time necessary required
across the initialisation
functionality functionality functionality
board
9
The Approach
Delivering Software Innovation
Measure
Identify boot Remove un- Optimise
boot time Re-order
time necessary required
across the initialisation
functionality functionality functionality
board
10
Case Study
Delivering Software Innovation
Additional functionality:
Video capture/render (representing a security camera)
11
MS7724
Delivering Software Innovation
12
SH7724
Delivering Software Innovation
13
Case Study
Delivering Software Innovation
Additional functionality:
Video capture/render (representing a security camera)
14
Case Study
Delivering Software Innovation
15
Case Study
Delivering Software Innovation
Additional functionality:
Video capture/render (representing a security camera)
16
Case Study
Delivering Software Innovation
17
MS7724 Boot Process
Delivering Software Innovation
Filesystem GUI
Baseline UBoot Kernel Init Scripts
Mount Application
(seconds) (2.58 s) (1.30 s) (1.30 s)
(~6.83 s) (7.43 s)
– Kernel: Mount FS
(init/do_mounts.c:do_mount_root)
– Kernel: Init
(init/main.c:init_post)
Functionality Removal
2.5 • User Boot Delay – 1000 ms
Extract
• Image Verification – 374 ms
Image
0.622 • Image Decompression
2 • USB, ROMImage, Filesystems – 195 ms
Verify
Image Functionality Optimisation
Time (s)
0.374
• Improve „memcpy‟ code – 342 ms
1.5
• Eliminate use of console – 103 ms
• Reduced kernel size – 60ms
User Boot
Delay Functionality Re-ordering
1 1.000
• Read MAC from EEPROM – 124 ms
• Ethernet setup – 98 ms
0.5
Init Reduction: 2577 ms > 280 ms (89%)
0.580
0
Boot Task
19
UBoot (Before and After)
Delivering Software Innovation
3 3
2.5 2.5
Extract
Image
0.622
2 2
Verify
Image
Time (s)
Time (s)
0.374
1.5 1.5
User Boot
Delay
1 1.000 1
0.5 0.5
Init
0.580 Decompress
Initialisation
0 0
Boot Task Boot Task
20
Compressed Kernel Images
Delivering Software Innovation
Functionality Removal
• Remove USB – 88 kB – 144 ms
• Remove keyboard driver – 4 ms
• Remove Filesystems – 300 kB – 0.8 ms
• Remove console output
Functionality Optimisation
• Remove delays in driver initialization – 400 ms
• Removing delays - 252 ms
• Prevent probing disconnected cameras – 200 ms
• Limiting memset size – 90 ms
• Improve performance of memset – 71 ms
Functionality Re-ordering
• Defer networking initialization – 166 kB – 20 ms
22
Linux Kernel (Before and After)
Delivering Software Innovation
23
Userspace (Mount and Init scripts)
Delivering Software Innovation
Functionality Removal
• Remove all init scripts – use a single init
process – 1.32 s
Functionality Optimisation
• Statically link application with uClibc libraries
• Use SquashFS instead of JFFS2 ~6.81 s
• Improve performance of NOR memory driver
Functionality Re-ordering
• Start QT then later start video
24
QT
Delivering Software Innovation
Optimise flash
access Removed features
Used statically
Stripped
Optimising Read-ahead and
linked uClibc executable block size
(arch/sh/kernel/io.c) -2.16s? -0.16s
-0.9s? -0.35s - 0.63s
-2.89s
Measurements show incremental effects against original binary (from left to right)
25
Why does QT take so long to start?
Delivering Software Innovation
26
Function Reordering and Block Sizes
Delivering Software Innovation
FS QT Application
MTD
Block 1 Block 2 Block 3 Block 4 Block 5 Block 6 Block 7
Layer
NOR
NOR Flash
Flash
27
Function Reordering
Delivering Software Innovation
Before:
FS QT Application
MTD
Block 1 Block 2 Block 3 Block 4 Block 5 Block 6 Block 7
Layer
NOR
NOR Flash
Flash
After:
FS QT Application
MTD
Block 1 Block 2 Block 3 Block 4 Block 5 Block 6 Block 7
Layer
NOR
NOR Flash
Flash
29
Essential tools
Delivering Software Innovation
30
Case Study: Before and After
Delivering Software Innovation
Filesystem GUI
Baseline UBoot Kernel Init Scripts
Mount Application
(seconds) (2.58 s) (1.30 s) (1.30 s)
(~6.83 s) (7.43 s)
31
Summary
Delivering Software Innovation
Remove boot delay 1000 Remove driver 652 Use squashfs 6830
delays
Remove Image 374 Prevent probing 200 Optimise flash
verification disconnected accesses 2890
cameras
Optimise memcpy 342 Remove USB 144 Remove unused 2160
code features from QT
Remove USB 195 Don‟t allocate Remove all init scripts 1300
ROMImage, memory for unused 90
filesystems camera components
Defer reading MAC 124 Improve memset 71 Statically link QT with 900
address uclibc
32
Guiding Principles
Delivering Software Innovation
33
Conclusion & Call to action
Delivering Software Innovation
34
Thank You
Any Questions?
35
Appendix
36
Initcall Debug
Delivering Software Innovation
37