Discussion:
Is there only one V8 instances ?
Ashish Negi
2013-09-23 10:33:01 UTC
Permalink
When we open a new tab in chromium it starts a new process. Does it makes
it own instance of v8 engine or Do all of them share one v8 engine ?

Somebody told me there is only one v8 engine. Just asking here for the
accurate answer

Thanks in advance.
--
--
Chromium Developers mailing list: chromium-***@chromium.org
View archives, change email options, or unsubscribe:
http://groups.google.com/a/chromium.org/group/chromium-dev

To unsubscribe from this group and stop receiving emails from it, send an email to chromium-dev+***@chromium.org.
Jakob Kummerow
2013-09-23 11:28:32 UTC
Permalink
Every renderer process has its own V8 instance.
When several tabs share a renderer, they also share that renderer's V8
instance, but a feature called "isolates" is used to give them completely
isolated environments in V8.
From a website's point of view all of this is an invisible implementation
detail -- no JavaScript state is shared between tabs either way.
When we open a new tab in chromium it starts a new process. Does it makes
it own instance of v8 engine or Do all of them share one v8 engine ?
Somebody told me there is only one v8 engine. Just asking here for the
accurate answer
Thanks in advance.
--
--
http://groups.google.com/a/chromium.org/group/chromium-dev
--
--
Chromium Developers mailing list: chromium-***@chromium.org
View archives, change email options, or unsubscribe:
http://groups.google.com/a/chromium.org/group/chromium-dev

To unsubscribe from this group and stop receiving emails from it, send an email to chromium-dev+***@chromium.org.
Ashish Negi
2013-09-23 11:45:20 UTC
Permalink
So when many tabs use same v8, Does all of them push the javascript code on
the main thread or can their be multi-threaded execution for each of these
single-threaded tabs?
Post by Jakob Kummerow
When several tabs share a renderer, they also share that renderer's V8
instance,
--
--
Chromium Developers mailing list: chromium-***@chromium.org
View archives, change email options, or unsubscribe:
http://groups.google.com/a/chromium.org/group/chromium-dev

To unsubscribe from this group and stop receiving emails from it, send an email to chromium-dev+***@chromium.org.
PhistucK
2013-09-23 11:51:06 UTC
Permalink
As far as I have experienced, all of them execute on the same main thread.


☆*PhistucK*
Post by Ashish Negi
So when many tabs use same v8, Does all of them push the javascript code
on the main thread or can their be multi-threaded execution for each of
these single-threaded tabs?
Post by Jakob Kummerow
When several tabs share a renderer, they also share that renderer's V8
instance,
--
--
http://groups.google.com/a/chromium.org/group/chromium-dev
To unsubscribe from this group and stop receiving emails from it, send an
--
--
Chromium Developers mailing list: chromium-***@chromium.org
View archives, change email options, or unsubscribe:
http://groups.google.com/a/chromium.org/group/chromium-dev

To unsubscribe from this group and stop receiving emails from it, send an email to chromium-dev+***@chromium.org.
Ashish Negi
2013-09-23 11:57:32 UTC
Permalink
I am making an application with v8 as a library. I created 2 threads with
each of them having different isolates. And it was "able" to run javascript
in both the threads. Was that just by chance or it is possible ? When
different threads ask for executing code to v8 parallely, would they get
into a line automatically ? Is there a chance of them getting lost ?
Post by PhistucK
As far as I have experienced, all of them execute on the same main thread.
☆*PhistucK*
Post by Ashish Negi
So when many tabs use same v8, Does all of them push the javascript code
on the main thread or can their be multi-threaded execution for each of
these single-threaded tabs?
Post by Jakob Kummerow
When several tabs share a renderer, they also share that renderer's V8
instance,
--
--
http://groups.google.com/a/chromium.org/group/chromium-dev
To unsubscribe from this group and stop receiving emails from it, send an
--
--
Chromium Developers mailing list: chromium-***@chromium.org
View archives, change email options, or unsubscribe:
http://groups.google.com/a/chromium.org/group/chromium-dev

To unsubscribe from this group and stop receiving emails from it, send an email to chromium-dev+***@chromium.org.
Ashish Negi
2013-09-23 11:58:40 UTC
Permalink
I think this is the situation of different tabs sharing the same v8.
--
--
Chromium Developers mailing list: chromium-***@chromium.org
View archives, change email options, or unsubscribe:
http://groups.google.com/a/chromium.org/group/chromium-dev

To unsubscribe from this group and stop receiving emails from it, send an email to chromium-dev+***@chromium.org.
PhistucK
2013-09-23 12:02:58 UTC
Permalink
Perhaps when they are not from the same domain.
I have experienced lock downs in a tab due to the fact that another tab
(that share the same Chrome process, which means the same V8 engine) was
executing long operations.
Perhaps this is more of a Blink thread than a V8 thread, though. Perhaps if
both of them were executing JavaScript only code (meaning, no DOM and other
web platform features), they could go on in parallel.


☆*PhistucK*
Post by Ashish Negi
I think this is the situation of different tabs sharing the same v8.
--
--
http://groups.google.com/a/chromium.org/group/chromium-dev
To unsubscribe from this group and stop receiving emails from it, send an
--
--
Chromium Developers mailing list: chromium-***@chromium.org
View archives, change email options, or unsubscribe:
http://groups.google.com/a/chromium.org/group/chromium-dev

To unsubscribe from this group and stop receiving emails from it, send an email to chromium-dev+***@chromium.org.
Torne (Richard Coles)
2013-09-23 12:17:10 UTC
Permalink
Post by Ashish Negi
I am making an application with v8 as a library. I created 2 threads with
each of them having different isolates. And it was "able" to run javascript
in both the threads. Was that just by chance or it is possible ? When
different threads ask for executing code to v8 parallely, would they get
into a line automatically ? Is there a chance of them getting lost ?
Someone correct me if I'm wrong, but my understanding is:

You can run different isolates on different threads at the same time with
V8, yes. However, there is only one Blink thread per renderer process in
Chromium, and because V8 shares the DOM with Blink, V8 must run on the
single Blink thread.

So, if you're just embedding V8 in your app standalone, then what you're
doing is fine, but Chromium can't do that because our V8 shares state with
the non-multithreaded rendering engine; even though they are separate
isolates only one can run at a time.
Post by Ashish Negi
Post by PhistucK
As far as I have experienced, all of them execute on the same main thread.
☆*PhistucK*
Post by Ashish Negi
So when many tabs use same v8, Does all of them push the javascript code
on the main thread or can their be multi-threaded execution for each of
these single-threaded tabs?
Post by Jakob Kummerow
When several tabs share a renderer, they also share that renderer's V8
instance,
--
--
http://groups.google.com/a/**chromium.org/group/chromium-**dev<http://groups.google.com/a/chromium.org/group/chromium-dev>
To unsubscribe from this group and stop receiving emails from it, send
--
--
http://groups.google.com/a/chromium.org/group/chromium-dev
To unsubscribe from this group and stop receiving emails from it, send an
--
--
Chromium Developers mailing list: chromium-***@chromium.org
View archives, change email options, or unsubscribe:
http://groups.google.com/a/chromium.org/group/chromium-dev

To unsubscribe from this group and stop receiving emails from it, send an email to chromium-dev+***@chromium.org.
Mikhail Naganov
2013-09-23 12:45:37 UTC
Permalink
See V8 API docs in
https://code.google.com/p/chromium/codesearch#chromium/src/v8/include/v8.h

/**
* Isolate represents an isolated instance of the V8 engine. V8
* isolates have completely separate states. Objects from one isolate
* must not be used in other isolates. When V8 is initialized a
* default isolate is implicitly created and entered. The embedder
* can create additional isolates and use them in parallel in multiple
* threads. An isolate can be entered by at most one thread at any
* given time. The Locker/Unlocker API must be used to synchronize.
*/

/**
* Multiple threads in V8 are allowed, but only one thread at a time is
allowed
* to use any given V8 isolate, see the comments in the Isolate class. The
* definition of 'using a V8 isolate' includes accessing handles or holding
onto
* object pointers obtained from V8 handles while in the particular V8
isolate.
* It is up to the user of V8 to ensure, perhaps with locking, that this
* constraint is not violated. In addition to any other synchronization
* mechanism that may be used, the v8::Locker and v8::Unlocker classes must
be
* used to signal thead switches to V8.
*/



On Mon, Sep 23, 2013 at 1:17 PM, Torne (Richard Coles)
Post by Torne (Richard Coles)
Post by Ashish Negi
I am making an application with v8 as a library. I created 2 threads with
each of them having different isolates. And it was "able" to run javascript
in both the threads. Was that just by chance or it is possible ? When
different threads ask for executing code to v8 parallely, would they get
into a line automatically ? Is there a chance of them getting lost ?
You can run different isolates on different threads at the same time with
V8, yes. However, there is only one Blink thread per renderer process in
Chromium, and because V8 shares the DOM with Blink, V8 must run on the
single Blink thread.
So, if you're just embedding V8 in your app standalone, then what you're
doing is fine, but Chromium can't do that because our V8 shares state with
the non-multithreaded rendering engine; even though they are separate
isolates only one can run at a time.
Post by Ashish Negi
Post by PhistucK
As far as I have experienced, all of them execute on the same main thread.
☆*PhistucK*
Post by Ashish Negi
So when many tabs use same v8, Does all of them push the javascript
code on the main thread or can their be multi-threaded execution for each
of these single-threaded tabs?
Post by Jakob Kummerow
When several tabs share a renderer, they also share that renderer's
V8 instance,
--
--
http://groups.google.com/a/**chromium.org/group/chromium-**dev<http://groups.google.com/a/chromium.org/group/chromium-dev>
To unsubscribe from this group and stop receiving emails from it, send
--
--
http://groups.google.com/a/chromium.org/group/chromium-dev
To unsubscribe from this group and stop receiving emails from it, send an
--
--
http://groups.google.com/a/chromium.org/group/chromium-dev
--
--
Chromium Developers mailing list: chromium-***@chromium.org
View archives, change email options, or unsubscribe:
http://groups.google.com/a/chromium.org/group/chromium-dev

To unsubscribe from this group and stop receiving emails from it, send an email to chromium-dev+***@chromium.org.
Joshua Bell
2013-09-23 16:32:46 UTC
Permalink
On Mon, Sep 23, 2013 at 5:17 AM, Torne (Richard Coles)
Post by Torne (Richard Coles)
Post by Ashish Negi
I am making an application with v8 as a library. I created 2 threads with
each of them having different isolates. And it was "able" to run javascript
in both the threads. Was that just by chance or it is possible ? When
different threads ask for executing code to v8 parallely, would they get
into a line automatically ? Is there a chance of them getting lost ?
You can run different isolates on different threads at the same time with
V8, yes. However, there is only one Blink thread per renderer process in
Chromium, and because V8 shares the DOM with Blink, V8 must run on the
single Blink thread.
So, if you're just embedding V8 in your app standalone, then what you're
doing is fine, but Chromium can't do that because our V8 shares state with
the non-multithreaded rendering engine; even though they are separate
isolates only one can run at a time.
Workers[1] are an example of multiple threads running JavaScript via V8
within a single Chromium process, with the threads and V8-fu managed by
Blink.

[1] technically, "Dedicated Workers". Shared Workers get their own
"headless" renderer process AND a Worker thread.
Post by Torne (Richard Coles)
Post by Ashish Negi
Post by PhistucK
As far as I have experienced, all of them execute on the same main thread.
☆*PhistucK*
Post by Ashish Negi
So when many tabs use same v8, Does all of them push the javascript
code on the main thread or can their be multi-threaded execution for each
of these single-threaded tabs?
Post by Jakob Kummerow
When several tabs share a renderer, they also share that renderer's
V8 instance,
--
--
http://groups.google.com/a/**chromium.org/group/chromium-**dev<http://groups.google.com/a/chromium.org/group/chromium-dev>
To unsubscribe from this group and stop receiving emails from it, send
--
--
http://groups.google.com/a/chromium.org/group/chromium-dev
To unsubscribe from this group and stop receiving emails from it, send an
--
--
http://groups.google.com/a/chromium.org/group/chromium-dev
--
--
Chromium Developers mailing list: chromium-***@chromium.org
View archives, change email options, or unsubscribe:
http://groups.google.com/a/chromium.org/group/chromium-dev

To unsubscribe from this group and stop receiving emails from it, send an email to chromium-dev+***@chromium.org.
Torne (Richard Coles)
2013-09-23 16:48:52 UTC
Permalink
Post by Joshua Bell
Post by Torne (Richard Coles)
Post by Ashish Negi
I am making an application with v8 as a library. I created 2 threads
with each of them having different isolates. And it was "able" to run
javascript in both the threads. Was that just by chance or it is possible
? When different threads ask for executing code to v8 parallely, would they
get into a line automatically ? Is there a chance of them getting lost ?
You can run different isolates on different threads at the same time with
V8, yes. However, there is only one Blink thread per renderer process in
Chromium, and because V8 shares the DOM with Blink, V8 must run on the
single Blink thread.
So, if you're just embedding V8 in your app standalone, then what you're
doing is fine, but Chromium can't do that because our V8 shares state with
the non-multithreaded rendering engine; even though they are separate
isolates only one can run at a time.
Workers[1] are an example of multiple threads running JavaScript via V8
within a single Chromium process, with the threads and V8-fu managed by
Blink.
Right, but the "normal" non-worker JS running on web pages in different
tabs that share a renderer process are all running on the same Blink main
thread, no?
Post by Joshua Bell
[1] technically, "Dedicated Workers". Shared Workers get their own
"headless" renderer process AND a Worker thread.
Post by Torne (Richard Coles)
Post by Ashish Negi
Post by PhistucK
As far as I have experienced, all of them execute on the same main thread.
☆*PhistucK*
Post by Ashish Negi
So when many tabs use same v8, Does all of them push the javascript
code on the main thread or can their be multi-threaded execution for each
of these single-threaded tabs?
Post by Jakob Kummerow
When several tabs share a renderer, they also share that renderer's
V8 instance,
--
--
http://groups.google.com/a/**chromium.org/group/chromium-**dev<http://groups.google.com/a/chromium.org/group/chromium-dev>
To unsubscribe from this group and stop receiving emails from it, send
--
--
http://groups.google.com/a/chromium.org/group/chromium-dev
To unsubscribe from this group and stop receiving emails from it, send
--
--
http://groups.google.com/a/chromium.org/group/chromium-dev
--
Torne (Richard Coles)
***@google.com
--
--
Chromium Developers mailing list: chromium-***@chromium.org
View archives, change email options, or unsubscribe:
http://groups.google.com/a/chromium.org/group/chromium-dev

To unsubscribe from this group and stop receiving emails from it, send an email to chromium-dev+***@chromium.org.
Joshua Bell
2013-09-23 17:55:03 UTC
Permalink
Post by Torne (Richard Coles)
On Mon, Sep 23, 2013 at 5:17 AM, Torne (Richard Coles) <
Post by Torne (Richard Coles)
Post by Ashish Negi
I am making an application with v8 as a library. I created 2 threads
with each of them having different isolates. And it was "able" to run
javascript in both the threads. Was that just by chance or it is possible
? When different threads ask for executing code to v8 parallely, would they
get into a line automatically ? Is there a chance of them getting lost ?
You can run different isolates on different threads at the same time
with V8, yes. However, there is only one Blink thread per renderer process
in Chromium, and because V8 shares the DOM with Blink, V8 must run on the
single Blink thread.
So, if you're just embedding V8 in your app standalone, then what you're
doing is fine, but Chromium can't do that because our V8 shares state with
the non-multithreaded rendering engine; even though they are separate
isolates only one can run at a time.
Workers[1] are an example of multiple threads running JavaScript via V8
within a single Chromium process, with the threads and V8-fu managed by
Blink.
Right, but the "normal" non-worker JS running on web pages in different
tabs that share a renderer process are all running on the same Blink main
thread, no?
Correct. Only one Blink main thread per renderer process, used as the UI
thread for tabs (and iframes) and hence non-Worker JS.

(I was just being nitpicky since the thread seemed to be implying that
multi-threaded use of V8 was foreign to Chromium/Blink and that the OP was
doing something unusual. Workers are a counter-example.)
Post by Torne (Richard Coles)
[1] technically, "Dedicated Workers". Shared Workers get their own
"headless" renderer process AND a Worker thread.
Post by Torne (Richard Coles)
Post by Ashish Negi
Post by PhistucK
As far as I have experienced, all of them execute on the same main thread.
☆*PhistucK*
Post by Ashish Negi
So when many tabs use same v8, Does all of them push the javascript
code on the main thread or can their be multi-threaded execution for each
of these single-threaded tabs?
Post by Jakob Kummerow
When several tabs share a renderer, they also share that renderer's
V8 instance,
--
--
http://groups.google.com/a/**chromium.org/group/chromium-**dev<http://groups.google.com/a/chromium.org/group/chromium-dev>
To unsubscribe from this group and stop receiving emails from it,
--
--
http://groups.google.com/a/chromium.org/group/chromium-dev
To unsubscribe from this group and stop receiving emails from it, send
--
--
http://groups.google.com/a/chromium.org/group/chromium-dev
--
Torne (Richard Coles)
--
--
Chromium Developers mailing list: chromium-***@chromium.org
View archives, change email options, or unsubscribe:
http://groups.google.com/a/chromium.org/group/chromium-dev

To unsubscribe from this group and stop receiving emails from it, send an email to chromium-dev+***@chromium.org.
Mingwei Zhang
2018-11-03 07:37:21 UTC
Permalink
I has been quite a while since the last reply.

So I am wondering whether there a way to have two V8 instances when two
tabs are sharing the same process? I understand that site isolation is now
enforced. So i am curious that if I disable 1) site-isolation and 2) --process-per-site
or --process-per-tab, how many V8 instances in one renderer process in
current Chrome implementation?

Thanks.
Post by Joshua Bell
Post by Torne (Richard Coles)
On Mon, Sep 23, 2013 at 5:17 AM, Torne (Richard Coles) <
Post by Torne (Richard Coles)
Post by Ashish Negi
I am making an application with v8 as a library. I created 2 threads
with each of them having different isolates. And it was "able" to run
javascript in both the threads. Was that just by chance or it is possible
? When different threads ask for executing code to v8 parallely, would they
get into a line automatically ? Is there a chance of them getting lost ?
You can run different isolates on different threads at the same time
with V8, yes. However, there is only one Blink thread per renderer process
in Chromium, and because V8 shares the DOM with Blink, V8 must run on the
single Blink thread.
So, if you're just embedding V8 in your app standalone, then what
you're doing is fine, but Chromium can't do that because our V8 shares
state with the non-multithreaded rendering engine; even though they are
separate isolates only one can run at a time.
Workers[1] are an example of multiple threads running JavaScript via V8
within a single Chromium process, with the threads and V8-fu managed by
Blink.
Right, but the "normal" non-worker JS running on web pages in different
tabs that share a renderer process are all running on the same Blink main
thread, no?
Correct. Only one Blink main thread per renderer process, used as the UI
thread for tabs (and iframes) and hence non-Worker JS.
(I was just being nitpicky since the thread seemed to be implying that
multi-threaded use of V8 was foreign to Chromium/Blink and that the OP was
doing something unusual. Workers are a counter-example.)
Post by Torne (Richard Coles)
[1] technically, "Dedicated Workers". Shared Workers get their own
"headless" renderer process AND a Worker thread.
Post by Torne (Richard Coles)
Post by Ashish Negi
Post by PhistucK
As far as I have experienced, all of them execute on the same main thread.
☆*PhistucK*
Post by Ashish Negi
So when many tabs use same v8, Does all of them push the javascript
code on the main thread or can their be multi-threaded execution for each
of these single-threaded tabs?
Post by Jakob Kummerow
When several tabs share a renderer, they also share that
renderer's V8 instance,
--
--
http://groups.google.com/a/chromium.org/group/chromium-dev
To unsubscribe from this group and stop receiving emails from it,
--
--
http://groups.google.com/a/chromium.org/group/chromium-dev
To unsubscribe from this group and stop receiving emails from it, send
--
--
http://groups.google.com/a/chromium.org/group/chromium-dev
--
Torne (Richard Coles)
--
--
Chromium Developers mailing list: chromium-***@chromium.org
View archives, change email options, or unsubscribe:
http://groups.google.com/a/chromium.org/group/chromium-dev
---
You received this message because you are subscribed to the Google Groups "Chromium-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to chromium-dev+***@chromium.org.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/chromium-dev/c58487ce-8f7f-44be-8ca9-9f5f9707d6b6%40chromium.org.
Loading...