Microsoft IE8 and Google Chrome - Processes are the New Threads
I happened to install Google Chrome (Alpha) the same day I installed Internet Explorer 8 (Beta). I noticed immediately, as I'm sure many of you have, that both browsers isolate tabs in different processes.
Unix folks have known about the flexibility of forking a process forever. In Unix, fork() is just about the easiest thing you can do. Also, fork()ing in Unix will copy the whole process and all variables into a new space. Everything after the fork happens twice. Multitasking made easy.
In Windows, you call CreateProcess() and you don't get a copy or clone. You just start up a whole new universe, starting from the very beginning - NOT from the call to CreateProcess().
What processes in Windows and Unix do have in common is that they each get their own protected virtual memory space. They are all alone and isolated. If a process crashes it's less of a crisis than if a thread within a process crashes.
(In .NET, AppDomains are like mini-processes, but they just aren't as completely isolated as a process is, so you can still bork an AppDomain enough that the whole process dies.)
Why does all this matter? Well, back in the day, most folks on Windows would recommend that developers interested in multi-tasking use threads. There's even been talk about fibers (really tiny threads within threads...like superstrings ;) ) However, darnnit, processes are easy.
Ah! But they're slow! They're slow to start up, and they are slow to communicate between, right? Well, kind of, not really anymore. There's this thing called Moore's Law that keeps marching on. Making a new process and talking to it in any of the myriad IPC (Inter-process Communication) methods available just isn't that much of a problem these days. Just open up Process Explore and enter "Tree View" sometime to see how many programs you use every day are actually multiple .exe's working together.
You can learn more about IE8 and how their multiple-process model works in both IE7 and IE8. (IE7 had this process isolation feature also...except one tab per security zone.)
You can learn more about Chrome and how they talk between their multiple "Render" processes in this architectural overview. They are using named pipes if you were wondering how Chrome talks to itself.
Tab/Process Isolation
I'll open up an instance of IE8 and open one tab with cnn.com and other with hanselman.com. I'll do the same with Google Chrome. Here's what Process Explorer shows.
Why are some of the processes brown? Those are jobs, a new kind of process added in Windows 2000. Jobs are made with CreateJobObject and AssignProcessToJobObject. You can also get a Job using CreateProcess as unless you specify the CREATE_BREAKAWAY_FROM_JOB flag. Jobs in Windows can be controlled as a group and resource limits can be set on them. You can learn more about Jobs and why they can be more secure up on MSDN.
Crash Protection
The whole point of having more than one process for a browser is for crash protection. I've had every browser I've ever used crash in one tab while I was hoping to keep my other 49 tabs open.
Let's blow away some processes manually and see what the browsers do. I'll blow away the non-job process for Chrome.exe.
Looks like that process hosted Flash. See how the Flash object has been replaced on the cnn.com home page with a sad puzzle piece? Cool. Chrome hosts plugins in their own process also.
Lets blow away another Chrome.exe process. Ah, looks like that particular process was rendering hanselman.com. It's been replaced by a sad-page icon.
OK, let's blow away an IE8 process....
Ah, looks like the FIRST time a page crashes in IE8, it dumps the process, the tab disappears, then the tab comes back automatically to try to put the user where they were before. I'll kill the new process...
Looks like IE8b2 will only try a few times to automatically restore the bad tab then it gives up and gives its equivalent sad-tab and says "the website continues to have a problem." Also cool. This beta includes an option to turn "automatic crash recovery" off or on.
If the parent process dies (or, in this case, I kill it myself!) then I'll get a dialog from IE8 offering to restore the last session.
I'll get this similar message in Google Chrome.
Very cool. Now I have two browsers that I can open up a buttload of tabs in and not worry about maxing-out process limits or having one bad tab messing up the whole bunch.
PS: If you are poking around in Chrome, try visiting pages like: "about:network", "about:stats", "about:dns" and "about:memory"
About Scott
Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. He is a failed stand-up comic, a cornrower, and a book author.
About Newsletter
And you wouldn't want to be searching for that single process that host Adobe Flash, you'd just close all the chrome.exe you could find.
Damien - Let's pass that info on to the IE8 team.
On a sidenote, your comment box is broken on IE8. I can't see what I'm typing without looking at the Live Preview.
http://www.ie7pro.com/
> before browsers had tabs, every window was already in it's own process
Browsers as far back as I remember (my first website was early 1994), have spawned new windows in the _same_ process whenever you ctrl-N, or File->New Window or even click on click on the browser in the Quick Launch toolbar down by the Start button. This was so that new windows (and popup windows) shared session cookies. Only when you double clicked on the .exe, or selected the browser from the Start->Programs menu did a new process start.
Their crash recovery doesn't quite work in this case.
These crashes have been mostly flash-related. I never had this happen in Firefox - possibly because I used a flash-blocker/ad-blocker.
Never used IE7 or IE8 so no experiences there...
Google Chrome also has about:cache and about:histograms
> Chrome assigns a process to a specific tab
> ....
> So Chrome's method isolates better from a security perspective
There are many caveat's with Chrome's current isolation. It will only ever create 20 processes. Thereafter, tabs are assigned randomly to one of the 20 processes. Frames (same origin or not) are always in the same process. Hyperlinking from one frame to another does not change process. Some cross-domain JavaScript calls which should be allowed (on the window object) currently do not work.
So Google have a lot of work to do to sort all this out. I have no idea how this compares with IE8's LCIE.
Anyway, not sure I understand the difference between fork() and CreateProcess() completely. I have used fork(), but I have never written anything for Win32 (except via Visual Basic 6 and REALbasic).
<div id="test"></div>
..
t = document.getElementById("test");
while(true)
{
t.innerHTML += "a";
}
Chrome deals *much* better with this. Even Firefox and Safari are able to find their way out of it after 10 or so seconds. IE8 b2 just sits there, pale and unresponsive.
I posted the same question on IEBlog recently (it was first comment on the post) but nobody said a word :(
Chrome's V8 benchmarks are biased towards recursion. Perhaps google tends to use more recursive javascript in their products? I compared the performance of IE8's javascript engine vs. V8 on Chrome using http://dromaeo.com and found IE8's performance to be better. The dromaeo tests are a more realistic real world javascript usage.
My question is, Do users really care any more how fast javascript is anymore?
Plus, do any of these browsers have Recycle Bin / Trash can? (The feature that lets you open a mistakenly closed tab). Opera does.
I have a similar rant on OO programming. When was the last time you actually (and I mean really did it, not just talked about or planned on doing it) made use of all that abstraction you over-designed into your application. Except for connecting different databases and one or two other biggies, most of that abstraction is a big waste of time and complexity. Hopefully everybody will wake up to that too sometimes soon.
OO isn't about abstraction. It's about modelling real-world artifacts into OO types. I find that when I take a procedural application and make it OO, I loose 30% of the code. I've done this on a couple of significant applications. So OO often makes code simpler and less abstract.
For example, strongly typing with a state pattern is infintely less abstract (more concrete) than representing those states as a set of integers.
This is a feature that require that every page is in a different thread/process.
Context switches are quite expensive, and since every process runs on a different address space, depending on how the operating systems implements the memory management and the location of the data in the virtual memory, cache locality can be a big problem, and the operating system may need to flush the cache every time a context switch occours due to cache misses or conflicts (specially when running on horrible architectures, as the P4).
Of course that on these days, a few more cycles don't affect the performance that much, and since most of the programmers don't know how to free memory properly (they are used to this monster called garbage collector and are too lazy to write good software), it looks like a good idea to isolate every tab in a different process.
But I still would like to see a real paper about this, with real arguments and profiling numbers.
What's the connection per-host limitation on Chrome? Is it configurable or hard-coded?
And what's the impact - or potential impact - of the 20-process limit on the connection limit?
Lori
And consider: you've got multiple cores or god forbid actual multiple processors. Who's context switching?
And again, I've played the thread game, and unless you really take a lot of care to do it just right (again, more expensive programming time) you end up wasting a lot of time locking and unlocking resources that you wouldn't have to waste time doing, if you'd just waste the memory on another process.
On my silly little apple II, a INC accumulator took 2 cycles, a 1Mhz chip, I could do a lot of those in one second.
Now imagine a 4 Ghz chip with all that fancy read ahead stuff that they do that I don't even keep up on anymore. Explain to me why anybody should really even care wasting a few billion cycles here and there on a garbage collector.
In the quick tests I have done, it appears that Chrome is happy to pass the username and password to each new tab, but IE8 requires you to re-enter username and password.
I'm not sure which way is better. I wonder if there is a security vs convenience trade-off. I think I like the convenience.
I imagine this issue will become increasingly important with the spread of web applications. I also wonder how authentication for ajax calls is handled.
Much to my surprise (once I corrected for cache line effects) there was essentially no difference in performance.
Obviously the 20 processes took up more memory, but the measurements I took indicated that an inter-process context switch took about the same amount of time as an intra-process context switch.
I wouldn't be too worried about the CPU overhead between threads and processes.
Processors without simultaneous multithreading do a context switch every time they switch between threads. Then you lose the locality benefits within one thread anyway, as the stuff loaded by the new thread starts to flush out the old thread's stuff from cache.
"Moore's Law" unfortunately doesn't apply to RAM capacity, which thus far has failed to scale with number of cores and will only fail harder. This is because DRAM is power intensive (it can easily dominate the power usage of an efficient CPU). Considering the growth of the mobile and netbook markets, it's surprising to me that browser architects are planning on using MORE memory.
http://blog.aggregatedintelligence.com/2008/09/ie8-beta-and-chrome-initial-thoughts.html
PS Completely agree about not using OO-programming as well, don't add complexity, keep things simple and flat. If it's to complex, you're doing it wrong !
http://crypto.stanford.edu/websec/chromium/chromium-security-architecture.pdf
Its 10 densely packed pages long and has a paragraph that discusses IE8's approach.
While the separate process per tab thing is very interesting in Chrome (and the ability to drag drop tabs, leaving the YouTube video or whatever running) - the fact that the rendering engine runs separately to the browser kernel (which has the file system access) is very interesting.
Also - the choice of installing Chrome into %AppData% is very interesting. It means that a user doesn't need admin rights to install the browser but it does mean that the installed browser executables do not get the same protection from malware that something installed in %ProgramFiles% would in Vista. Not sure if this is overall a good or bad thing yet - just interesting :-)
That whole 'dumb user' mentality is fine if you're one of the 0.00000001% of people who are using a PC for the first time, but for the rest of us it always makes using MS products very annoying.
The presumption that the user is necessarily ignorant and stupid is getting much worse with every new version of Windows, especially vista. its one of the biggest reasons I now mostly use Linux.
This article is a perfect example of how useless all Microsoft error messages are.
I don't think it's useless. The actual "cause" of the problem is something the IE developers need to worry about, why should you care? The crash report gets sent to them (assuming you allow it) so what more do you want to know?
I don't think Linux is any better, anyway. I use Ubuntu at home, and one of the most frustrating things with it is when you've got a CD in the drive, it won't let you eject the CD if something has a file open, but it won't tell you what file, or what has a handle to it (certainly not that I could find anyway). Windows is actually better in this respect -- at least on Windows, I can press the "Eject" hardware button on the drive and the CD will eject. Linux just pops up a message saying the device is busy and it can eject it...
http://blog.chromium.org/2008/09/multi-process-architecture.html
Anyway you can see what files are open, if you goto system monitor, in the menu bar you'll find: Monitor and the first item would be: search for open files. Also you can list all open files of a process there too.
Not to completely hijack this thread, but if OO is making your applications more complicated, you are using it wrong :) The whole point of OO is to make programming simpler, by breaking up concepts into individual pieces which are easy to reason about in isolation. This makes it easier to understand any particular segment of the application without having to understand the whole thing to the same degree.
@Mark Lindell, I can tell you for sure that I care about javascript performace. As we work on making more application like websites, such as Zillow, differences in javascript performance are noticable. While there is a lot of heavy lifting that we do on the server-side to make "thin" clients perform reasonbaly well, some things can only be determined from the client-side on demand.
I can't find the source now, but I remember reading that IE will only "optimize" for 3 processes. I guess this is a bit like the 20 process limit of Chrome, but these shared instances still are limits. I think I prefer Chrome's system since it allows you to tear off threads and recombine them in other browser groups. I can't tell you how many times I've wanted to move a tab from one window to another and Chrome lets me do precisely that. I think that there are many things Google still has to do before I will use Chrome as my primary browser, but I already use it on a regular basis as my "research" browser. Work tends to stay in IE and I tend to use FF for test, but Chrome gives me a place to keep private things (much like Flock did), and then with the ability to tear off tabs, it really is ideally suited for researching different topics. Each browser group then becomes a topic.
Comments are closed.
[)amien