►
Description
In this talk we are going to take a deep dive into the Node.js bootstrap process. We will cover the recent effort of bootstrap refactoring and V8 snapshot integration in Node.js core that have significantly improved the startup performance, and will also look into new approaches of Node.js application distribution that can be enabled by this effort.
A
Excuse
me,
sir
I'm
joy.
Thank
you
for
coming.
In
this
talk,
we
are
going
to
take
a
look
at
something
that
I've
been
doing
a
lot
of
great
factorial,
which
is
the
bootstrap.
Oh
no
Gordon,
so
allow
me
to
introduce
myself
I'm
Joey
I
work
on
the
competitors,
team,
agalya
I
in
on
denote
technicals
during
the
midday
and
I'm
via
committee.
A
So
in
the
past
year
I've
been
working
on
the
startup
performance
initiative,
note,
which
involves
a
lot
of
work
related
to
the
bootstrap
or
milk,
or
you
can
find
me
on
Twitter
by
the
Hindu
Deutsch.
So
enough
about
me,
let's
talk
about
them,
okay,
so
this
is
the
process
model
of
node
and
also
the
goal
of
the
bootstrap
process.
So
in
a
new
process
you
usually
have
one
main
node
instance
running
on
the
main
thread,
which
includes
an
inspector
agent
I'll,
be
a
context,
a
be
a
isolate,
le
pavillon
dope
and
a
node
environment.
A
So
don't
worry
about
all
those
lingos
if
you're
not
familiar
with
them.
Well
get
them
later.
There
is
also
a
sick
user.
One
watchdog
thread
for
handling
the
signal
that
you're
saying
to
know
to
make
the
inspector
start
listening
on
the
port.
There
also
one
prep
pole
for
v8
and
is
test
schedule
fed
and
one
purple
for
Livi
to
serve
a
synchronous
file
system
operations.
A
So
starting
from
the
temp,
you
can
spawn
worker
instances
in
addition
to
the
minions
in
one
node
process,
and
this
is
what
spawning
worker
looks
like-
we
basically
just
create
a
new
thread
when
the
worker
instance
inside
and
share
all
of
the
threads
in
process,
so
compared
to
that
spawning.
A
child
process
is
more
extensive
because
we
need
to
set
up
more
stuff.
A
A
First,
we
initialize
the
live
event
loop
on
the
main
thread,
but
we
only
add
handles
to
it
later
when
we
initialize
the
environment,
so
the
main
instance
simply
use
the
default
libuv
event
loop
and
after
the
process
and
one
default
event,
loop
has
been
initialized.
Next,
we'll
move
on
to
setup
the
VA
isolate
for
the
main
instance.
So
the
isolates
are
instances
of
the
v8
JavaScript
engine.
It
encapsulates,
for
example,
and
Jasmine
heap
a
micro
task
queue
for
the
promises
and
pending
exceptions,
and
so
on
so
to
set
up
the
way
isolate.
A
We
will
first
configure
the
resource
constraints,
including
how
much
memory
this
way
engine
instance
can
use.
We'll
also
create
an
array
buffer,
a
locator
that
is
in
charge
of
allocating
external
memory
for
preference
and
other
typed
arrays
mva
will
deserialized
isolate
from
a
nice.
Little
snapshot
will
cover
snapshots
later
then,
we'll
set
up
several
price
like
compacts
in
C
purpose,
but
most
of
them
are
not
ready
to
be
called
at
this
point
because
they
will
have
to
work
with
JavaScript
callbacks
initialize
nature.
A
So
this
dude,
the
garbage
collection,
callbacks
uncaught
exception,
the
listeners,
promise,
rejection,
callbacks,
etc,
and
after
the
VA
Iceland
is
initialized,
no
Dan
starts
to
initialize
the
VA
context.
So
a
VN
context
is
a
sandbox
execution
context
that
encapsulate
starts
with
buildings,
aka
prime
models,
including
gobo
des
array,
object
and
others.
So
when
you
call
VA
VM
that
tray
context
from
the
years
low
end
later
after
the
node
has
been
promised
wrapped.
This
is
what
the
return
result
includes:
its
new
contacts
with
a
different
set
of
buildings.
A
So
what
does
no
dude
initialize
this
context?
It
creates
an
immutable
copy
for
the
my
prime
adios,
so
that
internals
can
use
them
and
won't
be
affected
when
your
students
monkey
patch
these
buildings.
He
also
initializes
the
Jung
exception
for
web
guys
to
use
its
some
of
funny.
That
note
has
done
exceptions
when
there
is
no
done,
but
this
is
done
to
be
expect.
Wyant.
A
So
each
node
instance
has
a
main
context
where
most
of
the
JavaScript
is
executed
in,
but
it
can
also
contain
contacts
created
with
via
module.
The
main
contest
contains
a
pointer
to
is
associated
node
environment.
This
will
be
assigned
later
when
the
environment
is
created
in
context.
On
the
other
hand,
do
not
have
this
pointer
and
they
are
not
abstract
further
beyond
this
point,
so
contacts
can
be.
A
This
realized
from
the
startups
nashit
know
that
this
is
different
from
the
heap
snapshots
that
you
use
for
a
memory
debugging
before
we
integrated
the
startups
nasha
into
node.
We
had
to
run
a
few
contacts
per
contacts
scripts
in
order
to
initialize
these
Prem
Mario's
and
the
darling
exception,
and
now
we
run
the
scripts
a
real
time
and
serialize
the
context
after
initializing
has
been
done
and
we
sterilize.
The
contact
is
into
a
blob
that
gets
embedded
into
the
node
executable.
A
Why
we're
doing
this
at
this
point
so
to
bootstrap
itself
with
JavaScript
no
needs
to
create
an
internal
loader
system
to
load
throws
bindings
and
internal
trotsky
modules.
The
windings
are
looked
up
for
an
old
link
with
linear
search,
while
the
native
JavaScript
modules
provided
through
the
internal
version
of
require
are
looked
up
from
the
map,
so
no
recently
integrated
vehicle
cache
to
speed
up
the
compilation
of
internal
Java
modules.
A
So
before
the
integration
we
needed
to
parse
and
compile
the
source
code
of
these
modules
at
runtime
before
executing
them
to
create
native
modules,
now
we
compile
them
at
Build
time,
and
this
realize
the
compilation
data
which
is
embedded
into
the
insecure
table
at
runtime.
We
can
directly
deserialize
the
population
data
and
execute
the
just
code
to
create
these
internal
modules.
This
speeds
up
the
book
strap
about
40
to
60%,
since
parsing
and
combination
used
to
take
up
a
lot
of
time
during
bootstrap
after
we
have
an
internal
loader
system,
setup
note
can
start
initializing.
A
A
A
A
So
during
bootstrap
we
need
to
create
the
tick
you
and
the
tick
callback
and
store
the
tickle
back
in
the
environment
so
that
it
can
be
caught
later.
We
initializing
the
run
time
independent
states,
no
ticks
should
be
added
to
the
Takeo.
We
are
just
initializing
the
machinery
to
process
the
TQ
and,
after
the
run
time,
independent
components
are
initialized.
We
didn't
want
to
setup
the
event
loop.
A
At
this
point,
we
need
to
initialize
a
few
handles.
Some
are
activated
immediately.
Some
are
activated
on
the
man
later
and
we
only
initialize
a
fixed
number
of
handles,
durable,
strap,
more
hair.
Dos
specifically
the
ones
for
I/o,
are
added
on
demand
on
demand
later
so
the
live
event
event
loop
has
many
different
phases
in
each
iteration,
and
this
is
what
roughly,
what
it
looks
like.
A
A
So
after
the
van
loop
is
fully
initialized,
we
then
initialize
the
VA
inspector,
which
is
used
for
JavaScript
debugging.
This
includes
initializing
the
inspector
agent,
which
is
done
even
when
the
inspector
is
not
active,
ok
and
will
spawn
a
secure.
One
watchdog
thread
that
wakes
up
and
asked
Ming
thread
to
start
listening
on
expect
report.
When
user
sends
us
accuse
someone
to
the
process,
this
is
only
done
for
the
main
node
instances
and
not
down
for
workers.
A
At
this
point,
we'll
need
to
handle
various
runtime
configurations,
including
command
line
flags
and
environment
variables.
This
phase
is
also
called
pre
execution,
for
example.
This
is
what
the
initialization
of
there's
no
warnings
look
like.
If
the
user
asked
no
not
to
write
warnings,
STD
error,
we
don't
invest
all
the
warning
listener.
That
does
this.
If
the
user
does
not
configure
no
to
stop
doing,
this
will
install
the
Meixner
other
than
initializations
other
english
license.
Initialization
is
done
during
the
pre
execution.
A
Phase
include
setting
up
IPC
channels
for
clusters
and
child
processes
initializing
the
userland
module
loaders,
including
both
the
CJS
modular
and
ESM
orders.
So
only
after
this
point,
any
useful
and
module
can
be
executed
and
will
right
after
that
will
also
load
any
preloaded
module
specified
with
test
required
after
the
pre
execution
is
done.
The
node
environment
is
ready
and
we
can
start
the
execution.
A
A
If
the
instant
launched
is
a
worker
instance,
will
load
a
different
Ming
script
that
set
up
various
listeners
on
the
message,
port
and
start
listening.
So
when
the
worker
thread
receives
the
scripts
from
the
port,
it
will
compile
it
and
start
execution
from
there
and
after
the
main
script
is
run,
will
kick
off
the
event
loop
and
run
it
until
nothing
keeps
it
open.
The
lip,
UV
thread
pool
will
be
created
if
any
asynchronous
first
assistant
operation
is
used.
A
So
a
quick
summary
of
what
we
covered
in
this
talk
to
initialize
a
know,
process
from
scratch.
We
first
run
per
process,
setups
and
then
setup
a
VI
slit
via
contacts
and
the
new
environment.
The
majority
of
the
work
is
done
in
the
environment
setup,
which
includes
initializing
the
runtime
independent
States,
develop
the
in
v8
inspector
and
handling
runtime,
dependant
configurations
then
select
and
a
secure
the
main
script
and
start
in
the
loop.
Ok.
A
So
as
mentioned
earlier,
we're
now
have
integrated
the
V
a
start
up
snapshot
into
node,
but
at
the
moment
the
snapshot
we
have
only
includes
the
contact
setups
we're
currently
working
on,
including
the
run
time
independent
part
of
the
environment
bootstrap
into
the
step.
A
start
up
snapshot
to
speed
up
the
bootstrap
further.
So
this
is
currently
the
focus
of
the
startup
performance
initiative.
You
can
check
out
the
link
if
you
want
to
know
more.
Thank
you.