> There's no reason whatsoever that tab1 needs to not render or
> respond because tab2 is doing something or other.
The reason is the ancient design decision that the UI and behavior would be customizable
through JavaScript extensions. As extensions are global (i.e. they can see and manipulate all
of your tabs and UI elements), they need to live in a single interpreter.
JavaScript has classically been a single-threaded language; making it multi-threaded now would
create a lot of confusion and unexpected race conditions; most developers cannot even begin to
imagine all the ways that, for example, the renderer and concurrent changes to a document's
DOM could interact.
Adding coarse-grained locking does not have much benefit: any interaction between concurrent
threads would still likely cause one to wait for the other to yield a lock. On the other hand,
with fine-grained locking, writing code to handle race conditions would make extensions and
Firefox more complex and more error-prone.
Furthermore, adding concurrent multithreading support to a high-level language is no easy task
and has a significant performance impact on the interpreter alone -- as Perl, Python, Ruby,
Smalltalk etc developers can confirm.
Now, I'm just playing the devil's advocate and pointing out all the problems with this
approach; clearly it is *possible* to rewrite Firefox as a multi-threaded browser, but it's a
decision that has to be made with great precaution.
Posted May 29, 2008 18:13 UTC (Thu) by oak (subscriber, #2786)
[Link]
What would you lose if each Firefox window would be a separate process and
only tabs within same window would be in the same process?
At least moving a tab from one window to another would then be much
harder, maybe even impossible if all the tab state needs to be moved too.
Maybe windows-as-separate-processes could be a config option?
In defense of Firefox
Posted May 29, 2008 18:48 UTC (Thu) by thoffman (subscriber, #3063)
[Link]
How about one thread per source domain?
So if I have a bunch of windows and tabs open -- say, a Google Mail Compose window, plus the
main Google Mail screen in a tab, then those two windows will be rendered by the same single
thread, eliminating dangers of race conditions there.
Meanwhile, in another tab, I have LWN open. It will be rendered by another thread.
So, if Firefox's slow Javascript machine starts to suck wind in GMail, at least LWN will be
nice and snappy on my multicore machine...
In defense of Firefox
Posted May 29, 2008 19:53 UTC (Thu) by tjc (subscriber, #137)
[Link]
The reason is the ancient design decision that the UI and behavior would be customizable through JavaScript extensions. As extensions are global (i.e. they can see and manipulate all of your tabs and UI elements), they need to live in a single interpreter.
That explains a lot!
A repeatable example (at least for me) is linuxjournal.com, which freezes Firefox for about 15 seconds on my system.
In defense of Firefox
Posted Jun 19, 2008 17:01 UTC (Thu) by tjc (subscriber, #137)
[Link]
This is no longer a good example -- the Linux Journal front page loads much faster than it did
a few weeks ago, at least for me.