[FE training-materials-updates] Boot time slides: improvements from the ELC presentation

Michael Opdenacker michael.opdenacker at free-electrons.com
Fri May 2 01:15:07 CEST 2014


Repository : git://git.free-electrons.com/training-materials.git

On branch  : master
Link       : http://git.free-electrons.com/training-materials/commit/?id=3cc3c8e90e75374cc59ccf12b4e2a8ac649cc389

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

commit 3cc3c8e90e75374cc59ccf12b4e2a8ac649cc389
Author: Michael Opdenacker <michael.opdenacker at free-electrons.com>
Date:   Mon Apr 28 21:35:15 2014 +0200

    Boot time slides: improvements from the ELC presentation
    
    Signed-off-by: Michael Opdenacker <michael.opdenacker at free-electrons.com>


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

3cc3c8e90e75374cc59ccf12b4e2a8ac649cc389
 slides/boottime-bootloader/boottime-bootloader.tex |   90 +++++++++++++++++++-
 .../boottime-init-scripts3.tex                     |   82 +++++++++++++++---
 2 files changed, 156 insertions(+), 16 deletions(-)

diff --git a/slides/boottime-bootloader/boottime-bootloader.tex b/slides/boottime-bootloader/boottime-bootloader.tex
index 82fc8af..06e351e 100644
--- a/slides/boottime-bootloader/boottime-bootloader.tex
+++ b/slides/boottime-bootloader/boottime-bootloader.tex
@@ -44,6 +44,19 @@ Recompile U-Boot to remove features not needed in production
 \end{frame}
 
 \begin{frame}
+\frametitle{Bootloader: copy the exact kernel size}
+\begin{itemize}
+\item When copying the kernel from flash to RAM, we still see
+      many systems that copy too many bytes, not taking the
+      exact kernel size into account.
+\item In U-Boot, use the \code{nboot} command:\\
+      \code{nboot ramaddr 0 nandoffset}
+\item U-Boot using the kernel size information stored in the
+      \code{uImage} header to know how many bytes to copy. 
+\end{itemize}
+\end{frame}
+
+\begin{frame}
 \frametitle{U-Boot - Optimize kernel loading}
 \begin{itemize}
 \item After copying the kernel \code{uImage} to RAM,
@@ -94,7 +107,7 @@ Measured between \code{Booting kernel} and \code{Starting kernel ...}
 \begin{frame}
 \frametitle{U-Boot - Remove kernel CRC check}
 \begin{itemize}
-\item Fine in production when you no longer have data corruption
+\item Fine in production when you never have data corruption
       copying the kernel to RAM.
 \item Disable CRC checking with a U-boot environment variable:\\
       \code{setenv verify no}
@@ -123,7 +136,7 @@ Measured between \code{Booting kernel} and \code{Starting kernel ...}
       See \code{doc/README.silent} for details.
 \item Ultimate solution: use U-Boot's {\em Falcon} mode.\\
       U-Boot is split in two parts: the SPL (Secondary Program Loader)
-      and the U-Boot image. U-Boot can then configure to the SPL to load
+      and the U-Boot image. U-Boot can then configure the SPL to load
       the Linux kernel directly, instead of the U-Boot image.\\
       See \code{doc/README.falcon} for details.
 \end{itemize}
@@ -245,6 +258,79 @@ Using \code{AT91bootstrap} to boot the Linux kernel:
 \end{center}
 \end{frame}
 
+
+\subsection{Kernel compression options}
+
+\begin{frame}
+\frametitle{Kernel compression and size optimizations}
+After optimizing the time to load the kernel in the
+bootloader, we are ready to experiment with kernel 
+options impacting size:
+\begin{itemize}
+\item Kernel compression options
+\item Optimizing kernel code for size 
+\end{itemize}
+\end{frame}
+
+\begin{frame}
+\frametitle{Kernel compression options}
+Results on TI AM335x (ARM), 1 GHz, Linux 3.13-rc4
+{\scriptsize
+\begin{tabular}{| l || c | c | c | c | c | c |}
+\hline
+Timestamp & gzip & lzma & xz & lzo & lz4 & uncompressed \\
+\hline
+Size & 4308200 & 3177528 & {\bf 3021928} & 4747560 & 5133224 & 8991104 \\
+Copy & 0.451 s & 0.332 s & {\bf 0.315 s} & 0.499 s & 0.526 s & 0.914 s \\
+Uncompress & 0.945 s & 2.329 s & 2.056 s & 0.861 s & {\bf 0.851 s} & {\bf 0.687 s} \\
+Total & {\bf 5.516 s} & 6.066 s & 5.678 s & 5.759 s & 6.017 s & 8.683 s \\
+\hline
+\end{tabular}
+}
+\vfill{}
+Results on Atmel AT91SAM9263 (ARM), 200 MHz, Linux 3.13-rc4
+{\scriptsize
+\begin{tabular}{| l || c | c | c | c | c | c |}
+\hline
+Timestamp & gzip & lzma & xz & lzo & lz4 & uncompressed \\
+\hline
+Size & 3016192 & 2270064 & {\bf 2186056} & 3292528 & 3541040 & 5775472 \\
+Copy & 4.105 s & 3.095 s & {\bf 2.981 s} & 4.478 s & 4.814 & 7.836 s \\
+Uncompress & 1.737 s & 8.691 s & 6.531 s & {\bf 1.073} s & 1.225 s & N/A \\
+Total & 8.795 s & 14.200 s & 11.865 s & {\bf 8.700 s} & 9.368 s & N/A \\
+\hline
+\end{tabular}
+}
+\newline\newline
+Results indeed depend on I/O and CPU performance!
+\end{frame}
+
+\begin{frame}
+\frametitle{Optimize kernel for size}
+\begin{itemize}
+\item \code{CONFIG_CC_OPTIMIZE_FOR_SIZE}: possibility to compile the kernel
+      with \code{gcc -Os} instead of \code{gcc -O2}.
+\item Such optimizations give priority to code size at
+      the expense of code speed.
+\item Results: the initial boot time is better (smaller
+      size), but the slower kernel code quickly offsets
+      the benefits. Your system will run slower!  
+\end{itemize}
+Results on Atmel SAMA5D3 Xplained (ARM), Linux 3.10, gzip compression:
+\newline\newline
+\begin{tabular}{| l || c | c | c |}
+\hline
+Timestamp & O2 & Os & Diff \\
+\hline
+Starting kernel & 4.307 s & 4.213 s & -94 ms \\
+Starting init & 5.593 s & 5.549 s & -44 ms \\
+Login prompt & 21.085 s & 22.900 s & + 1.815 s \\
+\hline
+\end{tabular}
+\newline\newline
+\small
+\end{frame}
+
 \setuplabframe
 {Reduce bootloader time}
 {
diff --git a/slides/boottime-init-scripts3/boottime-init-scripts3.tex b/slides/boottime-init-scripts3/boottime-init-scripts3.tex
index 60fbdd5..4215b3f 100644
--- a/slides/boottime-init-scripts3/boottime-init-scripts3.tex
+++ b/slides/boottime-init-scripts3/boottime-init-scripts3.tex
@@ -41,6 +41,23 @@ application and then switch to the final root filesystem with
 \end{frame}
 
 \begin{frame}
+\frametitle{Results: after switch to initramfs}
+Before:
+\begin{center}
+    \includegraphics[width=\textwidth]{slides/boottime-init-scripts/timechart-init.pdf}
+\end{center}
+After:
+\begin{center}
+    \includegraphics[width=\textwidth]{slides/boottime-init-scripts3/timechart-initramfs.pdf}
+\end{center}
+\begin{itemize}
+\item U-Boot takes more time because the kernel is bigger
+\item \code{init} is started earlier because UBI is not initialized yet
+      (slow, UBIFS root filesystem)
+\end{itemize}
+\end{frame}
+
+\begin{frame}
 \frametitle{Do not compress your initramfs (1)}
 \begin{itemize}
 \item If you ship your initramfs inside a compressed kernel image, don't compress
@@ -57,7 +74,7 @@ Tests on Linux 3.13-rc4, measuring the penalty of having a
 \code{gzip} compressed initramfs in a \code{gzip} compressed kernel. \\
 \vfill{}
 \scriptsize
-Beagle Bone Black (TI AM3359)
+Beagle Bone Black (ARM, TI AM3359, 1 GHz)
 \begin{tabular}{| l || c | c | c | c | c | }
 \hline
 Mode & Size & Copy & Uncompress & Total & Diff \\
@@ -67,7 +84,7 @@ Initramfs compression & 4309112 & 455 ms & 947 ms & 5.527 s & + 11 ms \\
 \hline
 \end{tabular}
 \newline\newline
-CALAO USB-A9263 (Atmel AT91SAM9263)
+CALAO USB-A9263 (ARM, Atmel AT91SAM9263, 200 MHz)
 \begin{tabular}{| l || c | c | c | c | c | }
 \hline
 Mode & Size & Copy & Uncompress & Total & Diff \\
@@ -78,21 +95,58 @@ Initramfs compression & 3016928 & 4.1050 s & 1.760 s  & 8.813 s & + 18 ms \\
 \end{tabular}
 \end{frame}
 
+\begin{frame}
+\frametitle{Quick splashscreen display (1)}
+Often the first sign of life that you are showing!
+\begin{itemize}
+\item You could use the \code{fbv} program
+      (\url{http://freecode.com/projects/fbv})\\
+      to display your splashscreen.
+\item On \code{armel}, you can just use our statically compiled
+      binary: {\tiny
+\url{http://git.free-electrons.com/users/michael-opdenacker/static-binaries/tree/fbv}}
+\item However, this is slow:\\
+      878 ms on an Atmel AT91SAM9263 system!
+\end{itemize}
+\end{frame}
+
+\begin{frame}[fragile]
+\frametitle{Quick splashscreen display (2)}
+\begin{itemize}
+\item To do it faster, you can dump the framebuffer contents:\\
+      \begin{verbatim}
+fbv -d 1 /root/logo.bmp
+cp /dev/fb0 /root/logo.fb
+lzop -9 /root/logo.fb
+      \end{verbatim}
+\item And then copy it back as early as possible in an initramfs:
+      \begin{verbatim}
+lzopcat /root/logo.fb.lzo > /dev/fb0 
+      \end{verbatim}
+\end{itemize}
+Results on an Atmel AT91SAM9263 system: \\
+\begin{tabular}{| l || c | c | c | }
+\hline
+& \code{fbv} & plain copy (\code{dd}) & \code{lzopcat} \\
+\hline
+Time & 878 ms & 54 ms & 52.5 ms\\
+\hline
+\end{tabular}
+\vfill
+\footnotesize
+\url{http://free-electrons.com/blog/super-fast-linux-splashscreen/}
+\end{frame}
 
 \begin{frame}
-\frametitle{Results: after switch to initramfs}
-Before:
-\begin{center}
-    \includegraphics[width=\textwidth]{slides/boottime-init-scripts/timechart-init.pdf}
-\end{center}
-After:
-\begin{center}
-    \includegraphics[width=\textwidth]{slides/boottime-init-scripts3/timechart-initramfs.pdf}
-\end{center}
+\frametitle{Animated splashscreen}
+Still slow to read and write entire screens. Just draw useful pixels
+and even create an animation!
 \begin{itemize}
-\item U-Boot takes more time because the kernel is bigger
-\item \code{init} is started earlier because UBI is not initialized yet
-      (slow, UBIFS root filesystem)
+\item Create a simple C program that just animates pixels and simple
+      geometric shapes on the framebuffer!
+\item Example: {\small \url{http://free-electrons.com/pub/code/fb/anim.c}}.
+      On a 400 MHz ARM9 system: starts drawing in 10 ms \\
+      size: 24 KB, compiled statically).
 \end{itemize}
 \end{frame}
 



More information about the training-materials-updates mailing list