<<

Evaluation of MIPS Prelinking

Shin’ichi TSURUMOTO

MITSUBISHI Electric Corporation Advanced Technology R&D Center Overview

♦ Obtained prelinker for MIPS, compiler and libraries, and ran them on our target board

♦ Measured application startup time on our target board, and verified that the prelinking is effective

2 CELF Embedded Conference, April 18th, 2007 Background ♦ On June 2005, effectiveness of technique was presented at CELF International Technical Conference in Yokohama ♦ On November 2005, I questioned on prelink on MIPS architecture at Tokyo Technical Jamboree ♦ On April 2006, I requested to implement prelink for MIPS at MIPS-SIG piggybacked on ELC (Worldwide Embedded Linux Conference) ♦ On July 2006, MIPS Technologies reported at Ottawa Linux Symposium that they have started to develop prelink ♦ On October 2006, MIPS Technologies and CodeSourcery reported at Tokyo Technical Jamboree that they completed the development 3 CELF Embedded Linux Conference, April 18th, 2007 What is Prelink? Without Prelink With Prelink Source Code Source Code Compile Compile Object File

Link Link File Executable File Shared File Shared Library File Make ROM Image Prelink Executable File ( Resolved Addresses Attached ) ROM Image Shared Library File Make ROM Image

Application Build Time ROM Image

ROM Image ROM Image

Mapping and Loading Executable Mapping and Loading Executable and Shared Library file and Shared Library file Improvement of Addresses of Symbols should Application Launch time be resolved by Dynamic . Addresses are Already Resolved.

Preparing Application execute Preparing Application execute RAM Image App. Shared Library RAM Image

Run Time Addresses of Symbols Execute Application are needed for using Execute Application Shared Library Functions and Data.

4 CELF Embedded Linux Conference, April 18th, 2007 Effective Area of Prelinking

h/w init Init scripts Boot-loader Initial application Kernel startup Applications w/o Prelink

w Prelink Areas prelink is effective

time Power on Startup complete

5 CELF Embedded Linux Conference, April 18th, 2007 Building MIPS Prelink Environment

♦ Obtaining patches ◊ prelink.tar.gz (svn://sourceware.org/svn/prelink) ◊ glibc-2.3.6-prelink.patch (sourceware.org/glibc) ◊ binutils-2.16.1-prelink.patch (sourceware.org) ♦ Applying patches and rebuilding toolchain ♦ Compiling prelink command (we built as self- prelinker on target) ♦ Building target image ♦ Executing prelink on target

6 CELF Embedded Linux Conference, April 18th, 2007 Target Environment

♦ CPU core: MIPS32(4KEc) ♦ Clock: 300MHz ♦ DRAM: 384MByte ♦ Flash: 64MByte

7 CELF Embedded Linux Conference, April 18th, 2007 Target of test 1 and 2

h/w init Init scripts Boot-loader Initial application Kernel startup Applications w/o Prelink

w Prelink Application launch time

time Power on Startup complete

8 CELF Embedded Linux Conference, April 18th, 2007 Test code 1() src-gen/main.c #include "incgen.h" ♦Compiled source code above so that each library function is an int main( int argc, char **argv ) independent shared library file { return 0; ♦Used GNU autotools to compile } ♦Witten shell script to form infinite inc-gen/incgen.h loop; measured time between start extern void func001(); and stop of the command with using extern void func002(); time command, repeating ten times to extern void func003(); get the average value : lib-gen/func001.c #include "incgen.h" #include#include "incgen.h" "incgen.h" void func01() {} voidvoid func01() func001() {} {}

9 CELF Embedded Linux Conference, April 18th, 2007 Test code 1(C++) src-gen/main.cpp #include "incgen.h" ♦Compiled source code above so that each library function is an int main( int argc, char **argv ) independent shared library file { return 0; ♦Used GNU autotools to compile } ♦Witten shell script to form infinite inc-gen/incgen.h loop; measured time between start extern void func001(); and stop of the command with using extern void func002(); time command, repeating ten times to extern void func003(); get the average value : lib-gen/func001.cpp #include "incgen.h" #include#include "incgen.h" "incgen.h" void func01() {} voidvoid func01() func001() {} {} Note: same test as of c edition, except for filename, extension and compiler

10 CELF Embedded Linux Conference, April 18th, 2007 Measurement of application launch time (C)

30

25

20 ec] s

[ 15 e m i Without Prelink t 10

5 With Prelink

0 0 200 400 600 800 1000 1200 Links

11 CELF Embedded Linux Conference, April 18th, 2007 Measurement of application launch time (C++)

30

25

20

ec] Without Prelink s

[ 15 e m i t 10 With Prelink 5

0 0 200 400 600 800 1000 1200 Links

12 CELF Embedded Linux Conference, April 18th, 2007 Measurement of application launch time

30

25

Without Prelink 20 C++

[sec] 15 e m i t C 10

With Prelink 5

0 0 200 400 600 800 1000 1200 Links

13 CELF Embedded Linux Conference, April 18th, 2007 Test Code 2 (C only) incgen.h extern int ival00001_00001; extern int ival00001_00002; : extern int ival00001_00010;

extern void func00001_00001(); : extern void func00001_00002(); extern void func00001_00010();

extern int ival00002_00001; : Length of symbols libfilemmmmm.so libfilemmmmm.c : : #include#include "incgen.h""incgen.h" libfile00002.so libfile00002.c #include#include "incgen.h""incgen.h" libfile00001.so libfile00001.c #include#include "incgen.h""incgen.h" intint ival00001_00001;ival00001_00001; intint ival00001_00001; ival00001_00002; intintint ival00001_00001;ival00001_00001; ival00001_00002; intint ival00001_00001; ival00001_00002;: intint ival00001_00002;ival00001_00002;: int intival00001_00002; :ival00001_nnnnn; Number of lib files int: :ival00001_nnnnn; intint : ival00001_nnnnn;ival00001_nnnnn; intint ival00001_nnnnn;ival00001_nnnnn; Number of voidvoid func00001_00001()func00001_00001() {}{} global variables void func00001_00001() {} voidvoidvoid func00001_00001() func00001_00002()func00001_00002() {} {}{} in each lib file voidvoidvoid func00001_00001()func00001_00001() func00001_00002() {}{} {} void func00001_00002():: {} voidvoid func00001_00002()func00001_00002(): {}{} voidvoid: func00001_nnnnn()func00001_nnnnn() {}{} void:: func00001_nnnnn() {} Number of void func00001_nnnnn() {} voidvoid func00001_nnnnn()func00001_nnnnn() {}{} functions in each lib files 14 CELF Embedded Linux Conference, April 18th, 2007 Launch time dependency

12 •Number of functions : 30 10 •Number of global variables : 30 •Length of symbols : 15 8 ec] s [

6 e Without Prelink m Ti 4

2 With Prelink

0 0 200 400 600 800 Number of lib files

15 CELF Embedded Linux Conference, April 18th, 2007 Launch time dependency

1.2

Without Prelink 1

0.8 ec] s [

0.6 e With Prelink m Ti 0.4 •Number of lib files : 200

0.2 •Number of global variables : 30 •Length of symbols : 15 0 020406080100120 Number of functions in each lib file

16 CELF Embedded Linux Conference, April 18th, 2007 Launch time dependency

1.2

Without Prelink 1

0.8 ec] s [

0.6 e With Prelink m Ti 0.4 •Number of lib files : 200

0.2 •Number of functions : 30 •Length of symbols : 15 0 020406080100120 Number of global variables in each lib files

17 CELF Embedded Linux Conference, April 18th, 2007 Launch time dependency

1.2

Without Prelink 1

0.8 ec] s [

0.6 e With Prelink m i T 0.4 •Number of lib files : 200

0.2 •Number of functions : 30 •Number of global variables : 30 0 0 50 100 150 200 250 Length of symbols

18 CELF Embedded Linux Conference, April 18th, 2007 Target of test 3 (C++ only)

Saving of 1.68sec

h/w init Initial application Boot-loader Init scripts Kernel startup Applications w/o Prelink 3.86sec 2.18sec

w Prelink Areas prelink is effective

time Power on Startup complete

19 CELF Embedded Linux Conference, April 18th, 2007 Test 3; Measurement of System Startup Time ♦ At the top of the init script, just after mounting the procfs, write out contents of /proc/uptime onto a temporary file ♦ At the beginning of first invoked application, just after the completion of init script, got the value of /proc/uptime; measured the time elapsed from init script to the invocation of the first application by comparing the obtained value and the saved value ♦ Time saving of 1.68 sec observed for startup time it run through busybox 8 times (3.86sec -> 2.18sec)

20 CELF Embedded Linux Conference, April 18th, 2007 Conclusion

♦ We verified Prelinker for MIPS ♦ We observed the improvement of 0.92sec -> 0.49 sec (C) and 1.88 sec -> 0.70 sec (C++) with 200 links ♦ Application startup time increases exponentially with number of links ♦ More improvement of application startup time was observed for C++ than for C

21 CELF Embedded Linux Conference, April 18th, 2007 Special Thanks

♦ MIPS Technologies ♦ CodeSourcery ♦ MIPS-SIG Members (CE-Linux Forum)

22 CELF Embedded Linux Conference, April 18th, 2007 Thank You !!!

23 CELF Embedded Linux Conference, April 18th, 2007