about ChromeOS's startup process

3,366 views
Skip to first unread message

SubHero

unread,
Dec 22, 2011, 2:17:01 AM12/22/11
to Chromium OS discuss
Since ChromeOS launch, its startup speed is very fast. I really want
to know what is our Chrome OS's startup process. For example, the
system in which steps are optimized, which complex start service are
reduced or removed.

Sonny Rao

unread,
Dec 22, 2011, 2:51:50 AM12/22/11
to 3649...@qq.com, Chromium OS discuss
Pretty much everything in the boot process from the firmware to kernel
to user startup and chrome startup have been analyzed and optimized.
Anything not required is stripped out in each of those phases of boot.
One challenging aspect is that we still have to keep the boot secure
by verifying every piece of data read off the disk at each stage.

Boot time is tracked for every release and any regressions are
flagged. There's still some work going on for optimizing our I/O
patterns during boot on the Atom Chromebooks, but we are somewhat
limited by the hardware (CPU and Disk) as well.

> --
> Chromium OS discuss mailing list: chromium-...@chromium.org
> View archives, change email options, or unsubscribe:
> http://groups.google.com/a/chromium.org/group/chromium-os-discuss?hl=en

Richard Barnette

unread,
Dec 22, 2011, 1:41:47 PM12/22/11
to 3649...@qq.com, Chromium OS discuss

OK. I can give you the low-down on the basics of the boot process.

At the highest level, boot divides into these three phases:

Phase 1: BIOS startup/kernel load (1.5 seconds)
This phase begins when the CPU powers on and starts fetching. It
ends when control transfers to the decompressed Linux kernel.

For x86 based systems, large parts of this startup are implemented
in proprietary code owned by third parties (not Google). Source
code isn't publicly available.

For ARM based systems, U-boot does a lot of the work. The Chromium
OS U-boot sources are part of the public source tree.

Phase 2: Start the kernel and exec /sbin/init (1.3 seconds)
This phase starts in the kernel, and continues until /sbin/init
(Upstart) kicks off the first Chromium OS specific processing in
a script called /sbin/chromeos_startup.

The bulk of the source code for this phase is in the Chromium OS
kernel source tree. These sources are derived directly from the
Linux kernel.

Phase 3: User process startup (4.6 seconds)
This phase begins roughly at the moment the Chromium logo splash
screen is displayed. The two longest operations in this phase of
startup are starting the X server (2.5 seconds) and starting the
Chrome Browser (1.7 seconds).

The key code responsible for sequencing this phase is a collection
of upstart jobs and scripts in the chromeos-init package. In the
final image, the upstart jobs live in /etc/init.
==

The numbers above are for the R16 (stable channel) builds. The
times above don't include a small but significant amount of time
spent by the hardware between the time you push the power button
and the time when BIOS starts executing. The time summaries also
aren't perfect; some time in the kernel is attributed to the
firmware, and some time in user process startup is attributed to
the kernel.

As for what makes it fast: There's no one single thing. A few
key features:
* The custom Chrome OS firmware is faster than a standard BIOS.
One obvious improvement: A typical BIOS will wait for a few
seconds to allow users to press a key (like F1) in order to
to go to BIOS setup. The Chrome OS BIOS doesn't do this.
* The user process startup leaves out some services commonly
started in a standard Linux distribution. Other services are
simply delayed until after Chrome's login screen is ready.


> --
> Chromium OS discuss mailing list: chromium-...@chromium.org
> View archives, change email options, or unsubscribe:
> http://groups.google.com/a/chromium.org/group/chromium-os-discuss?
> hl=en

-- jrb
"Il semble que la perfection soit atteinte non quand il n'y a plus
rien à ajouter, mais quand il n'y a plus rien à retrancher."
(Antoine de Saint-Exupéry, "Terre des hommes")

Richard Barnette

unread,
Dec 22, 2011, 10:37:25 PM12/22/11
to "周龙", Chromium OS discuss
On Dec 22, 2011, at 5:26 PM, 周龙 wrote:

>
> Thank you for giving me so much help. ChromeOS start on the three
> phases, I feel it is very similar with the standard linux boot. I
> really want to know how to start the process. As you said, what
> services are started, what services are being postponed. So I can
> use it with the traditional linux for a comparison. I think it is
> best that if you could give me a flow chart about the ChromeOS's
> startup progress..
> ------------------
> 周龙

(re-added chromium-...@chromium.org so that all
the interested parties can continue to benefit from
the discussion).

I can't speak directly to either BIOS or kernel startup,
as I don't know them very well. A few key pointers if
these phases interest you:
* As I mentioned, the BIOS contains a fair amount
of proprietary code, so there's not as much to talk
about. If you're interested in ARM, you can dive
into the U-boot sources.
* I believe there's very little startup customization
in the Chromium OS Linux kernel build. If you're
familiar with the Linux kernel, you know how it works.

Regarding user process startup, it's driven by a collection
of upstart jobs custom-written for Chromium OS. There are
two key upstart jobs worth knowing about up front:
boot-services.conf
system-services.conf

Comments in these two files describe their roles in the boot
process. The key observation is this: jobs that depend
on 'boot-services' start early in the boot flow and run
in parallel with the X server and Chromium browswer startup;
jobs that depend on 'system-services' are delayed until after
the browser displays the login screen.

Jobs that start with 'boot-services' are generally critical
to logging in to the system, and include principally these items:
* Access to encrypted user directories (cryptohome.conf).
* Network services (flimflam.conf).
* The X server, including initialization for human-interface
devices (ui.conf).
* Chromium.

X server and Chromium startup are handled by the session
manager. The starting point is an upstart job called 'ui.conf',
which starts a script called session_manager_setup.sh.

One final piece of magic worth knowing about: after the
browser displays the login screen it notifies session_manager,
which then emits an upstart event called 'login-screen-visible';
that event is what eventually triggers the 'system-services'
jobs.

==== Source code references
The core upstart jobs can be found at this path in a standard
source repository:
src/platform/init
You can browse them online here:
http://git.chromium.org/gitweb/?p=chromiumos/platform/init.git;a=tree

The session manager is here:
src/platform/login_manager
http://git.chromium.org/gitweb/?p=chromiumos/platform/login_manager.git;a=tree


==== Additional online references

There's a summary of how to test Chromium OS boot performance here:
http://www.chromium.org/chromium-os/how-tos-and-troubleshooting/measuring-boot-time-performance
The summary mentions the events that mark the boot time critical
path, and roughly where to find them in the source code. There's
also sample data that can give a sense of where the time goes to.

Additionally, if you want to generate a graphical representation
of the boot process, there are instructions about how to generate
a run time graph with 'timechart':
http://www.chromium.org/chromium-os/how-tos-and-troubleshooting/a-brief-perf-how-to
To do this you'll need your own hardware and a custom build of
Chromium OS. The instructions may have molded a bit; let me know
if they don't still work.

Enjoy!


>
>
>
> ------------------ Original ------------------
> From: "Richard Barnette"<jrbar...@chromium.org>;
> Date: Fri, Dec 23, 2011 02:41 AM
> To: "364902036"<3649...@qq.com>;
> Cc: "Chromium OS discuss"<chromium-...@chromium.org>;
> Subject: Re: [cros-discuss] about ChromeOS's startup process

Sam Lin

unread,
Jan 21, 2013, 10:08:08 PM1/21/13
to chromium-...@chromium.org, 周龙
Hi Barnette, You did a really well explanation.

Richard Barnette於 2011年12月23日星期五UTC+8上午11時37分25秒寫道:
Reply all
Reply to author
Forward
This conversation is locked
You cannot reply and perform actions on locked conversations.
0 new messages