[bootlin/training-materials updates] master: Boot time: move toolchains earlier (942b0d35)

Michael Opdenacker michael.opdenacker at bootlin.com
Mon May 20 17:54:08 CEST 2019


Repository : https://github.com/bootlin/training-materials
On branch  : master
Link       : https://github.com/bootlin/training-materials/commit/942b0d356eaa40c2b48de73dddce614fed8dd2d4

>---------------------------------------------------------------

commit 942b0d356eaa40c2b48de73dddce614fed8dd2d4
Author: Michael Opdenacker <michael.opdenacker at bootlin.com>
Date:   Mon May 20 17:54:08 2019 +0200

    Boot time: move toolchains earlier
    
    Signed-off-by: Michael Opdenacker <michael.opdenacker at bootlin.com>


>---------------------------------------------------------------

942b0d356eaa40c2b48de73dddce614fed8dd2d4
 mk/boot-time.mk                                    |  5 +--
 .../boot-time-application.tex                      | 11 ------
 .../boot-time-c-libraries-title.tex                |  1 -
 slides/boot-time-toolchain/boot-time-toolchain.tex | 41 +++++++++++++++++++++
 .../boot-time-toolchain2/boot-time-toolchain2.tex  | 42 ++++++++++++++++++++++
 slides/c-libraries/c-libraries.tex                 | 17 +++++++++
 6 files changed, 103 insertions(+), 14 deletions(-)

diff --git a/mk/boot-time.mk b/mk/boot-time.mk
index 53d25ada..753c17b2 100644
--- a/mk/boot-time.mk
+++ b/mk/boot-time.mk
@@ -11,11 +11,12 @@ BOOT_TIME_SLIDES = \
 		boot-time-principles \
 		build-system-bootloader-kernel-lab \
 		boot-time-measuring \
+		boot-time-toolchain \
+		c-libraries \
+		boot-time-toolchain2 \
 		boot-time-application \
 		boot-time-init-scripts \
 		boot-time-filesystems \
-		boot-time-c-libraries-title \
-		c-libraries \
 		boot-time-init-scripts2 \
 		initramfs \
 		boot-sequence-initramfs \
diff --git a/slides/boot-time-application/boot-time-application.tex b/slides/boot-time-application/boot-time-application.tex
index 64927eac..bb31f1e8 100644
--- a/slides/boot-time-application/boot-time-application.tex
+++ b/slides/boot-time-application/boot-time-application.tex
@@ -220,17 +220,6 @@ perf report
 \end{block}
 \end{frame}
 
-\begin{frame}
-\frametitle{Toolchains optimizations}
-Trying a newer toolchain for your platform may help.
-\begin{itemize}
-  \item Results may vary depending on the size/features of your root filesystem.
-  \item Compare binary size and execution speed. Expect only minor improvements
-        though.
-  \item On ARM, Thumb2 toolchains are worth trying too.
-\end{itemize}
-\end{frame}
-
 \begin{frame}
 \frametitle{Linker optimizations (1)}
 Group application code used at startup
diff --git a/slides/boot-time-c-libraries-title/boot-time-c-libraries-title.tex b/slides/boot-time-c-libraries-title/boot-time-c-libraries-title.tex
deleted file mode 100644
index 786b51ad..00000000
--- a/slides/boot-time-c-libraries-title/boot-time-c-libraries-title.tex
+++ /dev/null
@@ -1 +0,0 @@
-\section{C Libraries}
diff --git a/slides/boot-time-toolchain/boot-time-toolchain.tex b/slides/boot-time-toolchain/boot-time-toolchain.tex
new file mode 100644
index 00000000..910c1cd7
--- /dev/null
+++ b/slides/boot-time-toolchain/boot-time-toolchain.tex
@@ -0,0 +1,41 @@
+\section{Toolchain optimizations}
+
+\begin{frame}
+\frametitle{Best toolchain for your project}
+Optimizing the cross-compiling toolchain is typically one of the first
+things to do:
+\begin{itemize}
+  \item The benefits of a toolchain change will be more significant and easier to
+        measure if other optimizations haven't been done yet.
+  \item Here's what you can change in a toolchain, with a potential
+        impact on boot time, performance and size:
+  \begin{itemize}
+    \item Components: versions of {\em gcc} and {\em binutils}\\
+	  More recent versions can feature better optimization capabilities.
+    \item C library: {\em glibc}, {\em uClibc}, {\em musl}\\
+	  {\em uClibc} and {\em musl} libraries make a smaller root
+	  filesystem
+    \item Instruction set variant: {\em ARM} or {\em Thumb2}, {\em Hard
+          Float} support or not.\\
+	  Can have an impact on code performance and code size ({\em Thumb2}
+	  encodes the same instructions as {\em ARM} but in a more
+	  compact way, at least significantly reducing size).
+  \end{itemize}
+\end{itemize}
+\end{frame}
+
+\begin{frame}
+\frametitle{Choosing the C library}
+\begin{itemize}
+  \item The C library is hardcoded at toolchain creation time
+  \item Available C libraries:
+  \begin{itemize}
+    \item {\em glibc}: most standard and featureful
+    \item {\em uClibc}: smaller and configurable. Has been around for
+	about 20 years.
+    \item {\em musl}: an alternative to {\em uClibc}, developed more
+        recently but mature too.
+  \end{itemize}
+\end{itemize}
+\end{frame}
+
diff --git a/slides/boot-time-toolchain2/boot-time-toolchain2.tex b/slides/boot-time-toolchain2/boot-time-toolchain2.tex
new file mode 100644
index 00000000..87ccef97
--- /dev/null
+++ b/slides/boot-time-toolchain2/boot-time-toolchain2.tex
@@ -0,0 +1,42 @@
+\setuplabframe {Trying a Thumb2 toolchain}
+{
+\begin{itemize}
+\item Measure filesystem and \code{ffmpeg} binary size. Time
+      the execution of the application.
+\item Re-compile the root filesystem using a Thumb2 toolchain
+\item Measure size and time again.
+\end{itemize}
+}
+
+\begin{frame}
+\frametitle{Lessons from labs: ARM vs Thumb2}
+\begin{itemize}
+\item Testcase: root filesystem with \code{ffmpeg} and associated
+      libraries (from our training labs)
+\item Compiled with gcc 7.4, generating {\em ARM} code:\\
+      Total filesystem size: 3.79 MB\\
+      \code{ffmpeg} size: 227 KB
+\item Compiled with gcc 7.4, generating {\em Thumb2} code:\\
+      Total filesystem size: 3.10 MB (-18 \%)\\
+      \code{ffmpeg} size: 183 KB (-19 \%)
+\item Performance aspect: performance apparently slightly improved
+      (approximately less than 5 \%, but there are slight variations in measured
+      execution time, for one run to another).
+\end{itemize}
+\end{frame}
+
+\begin{frame}
+\frametitle{Lessons from labs: musl vs uClibc}
+{\em Tested while preparing the labs (too long to do this during the
+class)}\\
+
+Tried to replace {\em uClibc} by {\em musl} in our video player lab:
+\begin{itemize}
+   \item musl library size: 680 KB (size of the \code{lib/} \code{tar} archive)
+   \item uClibc library size: 570 KB
+   \item uClibc saves 110 KB (useful), but otherwise no other significant change
+    in filesystem and code size. Not a surprise when the system is mostly filled
+    with binaries relying on shared libraries.
+\end{itemize}
+We stuck to {\em uClibc}!
+\end{frame}
diff --git a/slides/c-libraries/c-libraries.tex b/slides/c-libraries/c-libraries.tex
index 67a8bdb2..584bf5bd 100644
--- a/slides/c-libraries/c-libraries.tex
+++ b/slides/c-libraries/c-libraries.tex
@@ -82,6 +82,23 @@ compare the size
   \end{itemize}
 \end{frame}
 
+\begin{frame}{glibc vs uclibc vs musl (static)}
+  Let's compile and strip BusyBox 1.26.2 {\bf statically} and compare the size
+  \begin{itemize}
+    \item With gcc 6.3, armel, musl 1.1.16:\\
+          {\bf 183348} bytes
+    \item With gcc 6.3, armel, uclibc-ng 1.0.22 :\\
+          {\bf 210620} bytes.\\
+    \item With gcc 6.2, armel, glibc:\\
+          {\bf 755088} bytes
+  \end{itemize}
+  Notes:
+  \begin{itemize}
+    \item BusyBox is automatically compiled with \code{-Os} and stripped.
+    \item Compiling with shared libraries will mostly eliminate size differences
+  \end{itemize}
+\end{frame}
+
 \begin{frame}
   \frametitle{Other smaller C libraries}
   \begin{itemize}




More information about the training-materials-updates mailing list