Intent to Ship: Create V8 contexts from snapshot by default

113 views
Skip to first unread message

Hitoshi Yoshida

unread,
Jan 30, 2018, 3:29:49 AM1/30/18
to blink-dev

Contact emails

pe...@chromium.org


Explainer

We want to enable V8ContextSnapshot feature by default on Windows, MacOSX, Linux platforms.

Currently, we create V8 contexts from a snapshot of a context skeleton. If this feature is enabled, we substitute a snapshot that is set up for Blink. This change makes the creation faster.


Summary

This intent is to create V8 contexts for Blink from snapshot by default. The feature to do it is already implemented and shipped, but is enabled behind a flag.

According to Finch experiments, this feature makes metrics(*) of Blink.Binding.CreateV8ContextForMainFrame 36% shorter at 95th percentile and Blink.Binding.InitializeMainLocalWindowProxy 24% shorter at 75th percentile.

It seems a good evidence to improve their performance.


(*)

Blink.Binding.CreateV8ContextForMainFrame figures time to create an instance of v8::Context. We have to set up Window interface as a global object in this task.

Blink.Binding.InitializeMainLocalWindowProxy figures time to set up V8 environment for Blink. We prepare “document” object and wire some V8 objects with Blink objects in this task.


Link to “Intent to Implement” blink-dev discussion

Intent to Implement: V8 context snapshot


Is this feature supported on all six Blink platforms (Windows, Mac, Linux, Chrome OS, Android, and Android WebView)?

This feature is supported on Windows, Mac, and Linux.

For other platforms, i.e. Android and ChromeOS, we would like to support them separately in future.




--
Hitoshi Yoshida (Peria)

Mostyn Bramley-Moore

unread,
Jan 30, 2018, 4:21:06 AM1/30/18
to Hitoshi Yoshida, blink-dev
Not an owner, but since this introduces a significant build-time increase I feel like this needs some comments.  Can you:
1) Confirm that we will keep a GN argument for developers who want to disable it?
2) Describe the situations in which the build-time increase happens.  Only when cross-compiling, right?
3) Describe the situations in which the run-time performance improves.

(Perhaps comments on 2 and 3 could be added to tools/v8_context_snapshot/v8_context_snapshot.gni ?)


-Mostyn.

--
You received this message because you are subscribed to the Google Groups "blink-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to blink-dev+unsubscribe@chromium.org.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/blink-dev/CAJnxdXCWTtvhBbXW%3Dv07hg7wbBWNAf9tvnfOAn5g2uLscZ-4Ww%40mail.gmail.com.



--
Mostyn Bramley-Moore
Vewd Software

Hitoshi Yoshida

unread,
Jan 30, 2018, 9:35:25 AM1/30/18
to Mostyn Bramley-Moore, blink-dev
Let me emphasize that this intent does not matter with the build time.
This intent is to flip the default value of chrome://flags/#enable-v8-context-snapshot


2018-01-30 18:20 GMT+09:00 Mostyn Bramley-Moore <mos...@vewd.com>:
Not an owner, but since this introduces a significant build-time increase I feel like this needs some comments.  Can you: 
1) Confirm that we will keep a GN argument for developers who want to disable it?
Each developer can avoid creating the snapshot for Blink by adding a GN argument "v8_context_snapshot=false" if they wants.
But for non-cross-compile builds, time to build Chrome will not change so much.

2) Describe the situations in which the build-time increase happens.  Only when cross-compiling, right?
Correct. Only cross-compiling can increase build time, because it requires to build Blink twice.
But please note that we do not create a snapshot with Blink on major cross-compiling platforms, i.e. Android and ChromeOS,  by default.
You can check the detailed condition in tools/v8_context_snapshot/v8_context_snapshot.gni

3) Describe the situations in which the run-time performance improves.
Assume you have a snapshot for Blink named "v8_context_snapshot.bin" and enable the feature from chrome://flags/#enable-v8-context-snapshot
This feature speedup LocalWindowProxy::Initialize() which is called at the beginning of every HTML page loading. 
It means this feature does not improve performance for Workers and loading XML documents.

Kentaro Hara

unread,
Jan 30, 2018, 9:33:49 PM1/30/18
to Hitoshi Yoshida, Mostyn Bramley-Moore, blink-dev
We should definitely address the build time issue before enabling the context snapshotting on Android, Chrome OS and other platforms that require cross-compiling.

However, this Intent-to-Ship is only about Window, Mac and Linux, so I think this is fine. Also the performance impact is amazing (36% reduction per frame creation at 95%-tile!).




Yoav Weiss

unread,
Feb 1, 2018, 3:39:48 AM2/1/18
to Kentaro Hara, Hitoshi Yoshida, Mostyn Bramley-Moore, blink-dev
Excited about the perf benefits for frame creation! :) (but less excited about potential build slowdown...)
Is this change web exposed, besides the side-effect of making things faster?

To unsubscribe from this group and stop receiving emails from it, send an email to blink-dev+...@chromium.org.



--
Mostyn Bramley-Moore
Vewd Software



--
Hitoshi Yoshida (Peria)

--
You received this message because you are subscribed to the Google Groups "blink-dev" group.
--
You received this message because you are subscribed to the Google Groups "blink-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to blink-dev+...@chromium.org.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/blink-dev/CABg10jxFnsTLa3tyGh094bi1iGMCdQcaj%2B1a1zin2OfEss6vgQ%40mail.gmail.com.

Kentaro Hara

unread,
Feb 1, 2018, 3:44:42 AM2/1/18
to Yoav Weiss, Hitoshi Yoshida, Mostyn Bramley-Moore, blink-dev
No, this is just a performance optimization :) No change in web-exposed behavior.



To unsubscribe from this group and stop receiving emails from it, send an email to blink-dev+unsubscribe@chromium.org.



--
Mostyn Bramley-Moore
Vewd Software



--
Hitoshi Yoshida (Peria)

--
You received this message because you are subscribed to the Google Groups "blink-dev" group.



--
Kentaro Hara, Tokyo, Japan

--
You received this message because you are subscribed to the Google Groups "blink-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to blink-dev+unsubscribe@chromium.org.

PhistucK

unread,
Feb 1, 2018, 3:53:28 AM2/1/18
to Kentaro Hara, Yoav Weiss, Hitoshi Yoshida, Mostyn Bramley-Moore, blink-dev
I may have asked this already -
Forget about operating-system-level-cache-optimizations for a moment - is the context snapshot file loaded from the disk every time you spawn a new renderer?


PhistucK

Yoav Weiss

unread,
Feb 1, 2018, 3:55:13 AM2/1/18
to Kentaro Hara, Hitoshi Yoshida, Mostyn Bramley-Moore, blink-dev
On Thu, Feb 1, 2018 at 9:44 AM Kentaro Hara <har...@chromium.org> wrote:
No, this is just a performance optimization :) No change in web-exposed behavior.


In that case, I'd argue it doesn't really need LGTMs, and can be considered a PSA.
 


To unsubscribe from this group and stop receiving emails from it, send an email to blink-dev+...@chromium.org.



--
Mostyn Bramley-Moore
Vewd Software



--
Hitoshi Yoshida (Peria)

--
You received this message because you are subscribed to the Google Groups "blink-dev" group.



--
Kentaro Hara, Tokyo, Japan

--
You received this message because you are subscribed to the Google Groups "blink-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to blink-dev+...@chromium.org.

Hitoshi Yoshida

unread,
Feb 1, 2018, 3:59:38 AM2/1/18
to PhistucK, Kentaro Hara, Yoav Weiss, Mostyn Bramley-Moore, blink-dev
2018-02-01 17:52 GMT+09:00 PhistucK <phis...@gmail.com>:
I may have asked this already -
Forget about operating-system-level-cache-optimizations for a moment - is the context snapshot file loaded from the disk every time you spawn a new renderer?

No. The snapshot file is loaded by the browser process on launching Chrome, and each renderer process reads mmapped blob data.

PhistucK

unread,
Feb 1, 2018, 4:01:08 AM2/1/18
to Hitoshi Yoshida, Kentaro Hara, Yoav Weiss, Mostyn Bramley-Moore, blink-dev
Cool!


PhistucK

Hitoshi Yoshida

unread,
Feb 1, 2018, 4:01:36 AM2/1/18
to Yoav Weiss, Kentaro Hara, Mostyn Bramley-Moore, blink-dev
I got it. Thank you. :)

To unsubscribe from this group and stop receiving emails from it, send an email to blink-dev+unsubscribe@chromium.org.



--
Mostyn Bramley-Moore
Vewd Software



--
Hitoshi Yoshida (Peria)

--
You received this message because you are subscribed to the Google Groups "blink-dev" group.



--
Kentaro Hara, Tokyo, Japan

--
You received this message because you are subscribed to the Google Groups "blink-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to blink-dev+unsubscribe@chromium.org.



--
Kentaro Hara, Tokyo, Japan

Ojan Vafai

unread,
Feb 1, 2018, 1:33:46 PM2/1/18
to blink-dev, har...@chromium.org, pe...@chromium.org, mos...@vewd.com
On Thursday, February 1, 2018 at 12:55:13 AM UTC-8, Yoav Weiss wrote:

On Thu, Feb 1, 2018 at 9:44 AM Kentaro Hara <har...@chromium.org> wrote:
No, this is just a performance optimization :) No change in web-exposed behavior.


In that case, I'd argue it doesn't really need LGTMs, and can be considered a PSA.

API owners talked about this today and agreed this doesn't need LGTMs since it doesn't change web exposed behavior.
 
 


To unsubscribe from this group and stop receiving emails from it, send an email to blink-dev+unsubscribe@chromium.org.



--
Mostyn Bramley-Moore
Vewd Software



--
Hitoshi Yoshida (Peria)

--
You received this message because you are subscribed to the Google Groups "blink-dev" group.



--
Kentaro Hara, Tokyo, Japan

--
You received this message because you are subscribed to the Google Groups "blink-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to blink-dev+unsubscribe@chromium.org.
Reply all
Reply to author
Forward
0 new messages