Slashdot Mirror


In IE8 and Chrome, Processes Are the New Threads

SenFo writes "To many of the people who downloaded Google Chrome last week, it was a surprise to observe that each opened tab runs in a separate process rather than a separate thread. Scott Hanselman, Lead Program Manager at Microsoft, discusses some of the benefits of running in separate processes as opposed to separate threads. A quote: '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.'"

18 of 397 comments (clear)

  1. So... by Anonymous Coward · · Score: 5, Insightful

    ...his argument that processes aren't really slower than threads anymore is because your processor is faster?

    1. Re:So... by moderatorrater · · Score: 3, Insightful

      Yep, kind of like how anti-aliasing isn't really slower than straight rendering any more because I've got a better video card.

  2. Deja vu by overshoot · · Score: 5, Insightful
    I remember the "processes vs. threads" argument, but last time around wasn't it Microsoft arguing that a threaded process model was superior to an isolated task model like Linux had? Weren't the Linux camp blowing the horn for the superior robustness and security of full task isolation?

    My head hurts, I'm confused.

    --
    Lacking <sarcasm> tags, /. substitutes moderation as "Troll."
    1. Re:Deja vu by FishWithAHammer · · Score: 4, Insightful

      Both have pluses and minuses, as with anything. (I won't speak to the Unix model as I am not terribly conversant with it, but I know a good bit about the Windows model of threaded processes.)

      A threaded process model has one enormous advantage: you stay within the same address space. Inter-process communication is annoying at best and painful at worse; you have to do some very ugly things like pipes, shared memory, or DBus (on Linux, that is). Using the threaded process model, I can do something like the following (it's C#-ish and off the cuff, so it probably won't compile, but it should be easy to follow):

      class Foo
      {
          Object o = new Object(); // mutex lock, functionality built into C#
          SomeClass c = new SomeClass();
       
          static void Main(String[] args)
          {
              Thread t = new Thread(ThreadFunc1);
              Thread t2 = new Thread(ThreadFunc2);
              t.Start();
              t2.Start();
              while (t.IsRunning || t2.IsRunning) { Thread.Sleep(0); } // cede time
          }
       
          static void ThreadFunc1()
          {
              while (true)
              {
                  lock (o)
                  {
                      c.DoFunc1();
                  }
              }
          }
       
          static void ThreadFunc2()
          {
              while (true)
              {
                  lock (o)
                  {
                      c.DoFunc2();
                  }
              }
          }
      }

      In an isolated task model, this is nowhere near as simple. The problem, though, is that one thread can, at least in C++, take down the whole damn process if something goes sour. (You can get around that in .NET with stuff like catching NullPointerExceptions, but you'll almost certainly be left in an unrecoverable state and have to either kill the thread or kill the program.) The Loosely Coupled Internet Explorer (LCIE) model is forced to use processes to avoid taking everything down when one tab barfs up its lunch.

      --
      "You can either have software quality or you can have pointer arithmetic, but you cannot have both at the same time."
    2. Re:Deja vu by shird · · Score: 4, Insightful

      For the majority of local applications, a threaded model is superior. This is because local applications can be "trusted" in the sense they don't need to run each child thread sandboxed etc, so they gain the benefits of greater efficiency without worrying about reduced security. A browser is quite a different beast - it is effectively an OS to run remote "applications" (read: web 2.0 style web sites). So it kind of makes sense to run each as a seperate process.

      Windows the OS still runs each application in its own process. So it's not right to compare it to Chrome and argue that it doesn't use seperate processes, because it does - where it counts.

      --
      I.O.U One Sig.
    3. Re:Deja vu by ratboy666 · · Score: 4, Insightful

      Yes, you are correct. Unix started with a process model based on fork() and explicit IPC. Threads were "grafted on" later. It tends to result in more robust software (good multi-threading is HARD).

      In Linux a "thread" is a "process", just with more sharing. Thread creation is cheaper in Windows; process creation is cheaper in Linux. I tend to like the isolation that processes offer (multithreading brings with it the joy of variables that can appear to just change by themselves).

      There was never any good reason to NOT use multiple processes in a browser, except one. The GUI was "unified" amongst the browser Windows, and it has always been presumed that it would be too difficult to co-ordinate the drawing of multiple browsers. Also, the menu bars and controls would have to assigned to a separate process for each of the browsers. This can be done with an IPC channel, but that code would not have been portable between Unix and Windows at all.

      Since process creation was SO expensive in Windows (in days of old), the "thread" or "lightweight thread" approach was used instead (to maximize portability).

      It is an amazing testament to Google that they have achieved the multi-process, single UI model (I just don't know how they did the portability part).

      --
      Just another "Cubible(sic) Joe" 2 17 3061
    4. Re:Deja vu by The+Raven · · Score: 5, Insightful

      This is a misunderstanding of the application.

      Microsoft said 'Threads are better than Processes for a web server', where you're wasting a ton of resources creating a new process for every CGI script that's run. They were right! Now every major web server supports in-process applications that are created once per server (perhaps with a pool of shared app space) rather than once per request.

      Microsoft has never said that all the applications on your computer should run in one thread... that's just crazy talk.

      This is simply a decision by Microsoft and Google to treat a browser tab as an application, rather than as a document. Now that web pages do a lot more processing (and crashing), this makes more sense than the old way. There's nothing particularly bad about using threads instead... Firefox is just fine with threads, I see no reason for them to undertake a massive change due to misplaced hype.

      It really has to do with how much the processes share. If most of the memory per process could be shared, threads are probably more efficient. If not, processes. I'm no browser architect though, so I'll leave it up to Google, Mozilla, and Microsoft to make their own decisions.

      --
      "I will trust Google to 'do no evil' until the founders no longer run it." Hello Alphabet.
  3. Re:Processes by ergo98 · · Score: 5, Insightful

    Running each instance in a seperate process is NOT new technology

    Well of course. It isn't even new in the browser world. In fact it's where we started.

    The earliest browsers required you to run a new instance for each concurrently opened site. This presented onerous resource demands, so they made it more efficient by having multiple window instances run under one process, and then with tabs that obviously carried over to tabs running under one shared process.

    This is so much ado about nothing. I can count on one hand the number of times I've had a problem with Firefox that would have been solved by it being in its own process.

    Every bandwagoner, technical lightweight is now stomping their feet that Firefox needs to get on this yesterday, but really this is pretty low on the list of things that make a real improvement in people's lives. In fact I would go so far as to call it a gimmick. Presuming that the sandbox of a browser automatically stops sites from doing stupid stuff (unlike IE that will let a site kill just by going into a perpetual loop in JavaScript), and plug-ins are created by an idiot, this is completely unnecessary.

    Chrome's great JavaScript is a real story, one upped by Firefox's ThreadMonkey doing one better. Those are real improvements that really do matter.

  4. Cheap and Dirty Crash Isolation... by nweaver · · Score: 5, Insightful

    The real reason for processes instead of threads is cheap & dirty crash isolation. Who cares about RPC time, you don't do THAT much of it in a web browser.

    But with more and more apps being composed IN the browser, you need isolation to get at least some crash isolation between "apps"

    --
    Test your net with Netalyzr
  5. Limitations by truthsearch · · Score: 4, Insightful

    There are some details to Chrome's sandboxing implementation that limit its security benefits:

    - The process limit is 20. Anything requiring an additional process once this limit is reached, such as opening another tab, will be assigned randomly to any of the existing 20 processes.

    - Frames are run within the same process as the parent window, regardless of domain. Hyperlinking from one frame to another does not change processes.

    There are also some problems where valid cross-site JavaScript doesn't work. Of course it's still only a beta. Some specific details are documented by Google.

  6. Re:Processes by ThePhilips · · Score: 4, Insightful

    Running each instance in a separate process is NOT new technology [...]

    True, *nix does that for last 3 decades.

    The point here (and of RTFA) is that finally on Windows processes are becoming cheaper, making them usable for all the nasty stuff *nix was indulging itself for all the time.

    On NT 3.5, creation of new process was taking sometime as long as 300ms. Imaging Chrome on NT: if you open three tabs and start three new processes, on NT in the times, that alone would have taken about one second.

    Unix never had the problem. It's Windows specific. And they are improving.

    --
    All hope abandon ye who enter here.
  7. Slow to start a process!? by Sloppy · · Score: 4, Insightful

    They [processes] 're slow to start up

    It's hilarious anyone would think that. We're talking about a web browser, not a web server. Even on platforms where process creation is "slow", it's still going to be instantaneous from a single human's point of view. It's not like the user is opening 100 tabs per second.

    --
    As copyright owner of this comment, I authorize everyone to defeat any technological measure which limits access to it.
  8. Re:Only one benefit discussed: isolation by ceoyoyo · · Score: 4, Insightful

    From the other perspective, having used IE in the past, I know how easy it is for a page to open lots of popups. In fact, you could open so many popups that it would crash the browser.

    Now that the browser likes opening new processes, an out of control web page can crash my whole OS instead?

  9. Requirements/Trade-offs by bill_mcgonigle · · Score: 4, Insightful

    There are at least three problems here.

    One is efficiency. Nobody will argue that a properly implemented multi-threaded software project is going to be less efficient than a new process per job. If you're writing a server to handle 100,000 connections simultaneously you probably want to use threads.

    One is necessity. If you're only going to have at most a couple hundred threads you don't need to think in terms of 100,000 processes - orders of magnitude change things.

    The last is correctness. Most multi-threaded browsers aren't actually implemented correctly. So they grow in resource consumption over time and you have to do horrendous things like kill the main process and start over, which loses at least some state with current implementations.

    So theory vs. reality vs. scale. There's no "one true" answer.

    --
    My God, it's Full of Source!
    OUTSIDE_IP=$(dig +short my.ip @outsideip.net)
  10. Re:Processes by FishWithAHammer · · Score: 4, Insightful

    It's primarily improvements in computer speed. Threads are very cheap in Windows (and this is why .NET in particular is so heavily dependent on spawning tons of threads for many types of tasks) and processes remain fairly expensive, but that expense is somewhat minimized by being about to throw ten kajillion bogomips at the problem.

    --
    "You can either have software quality or you can have pointer arithmetic, but you cannot have both at the same time."
  11. Re:Processes by gnud · · Score: 3, Insightful

    This is so much ado about nothing. I can count on one hand the number of times I've had a problem with Firefox that would have been solved by it being in its own process.

    I own a fairly old computer, and every time I open or close a javascript-heavy page, or open a PDF file, all the rest of my tabs become unusable for some seconds. It's not the end of the world, but I can't think of anything that I'd rather firefox devs spend their time on.

  12. Re:Processes by apoc.famine · · Score: 4, Insightful

    Currently that's spelled "half of the internet". The other half is flash.

    --
    Velociraptor = Distiraptor / Timeraptor
  13. Re:quite ironic by the_B0fh · · Score: 4, Insightful

    And debugging threads is easy? Oh boy, talk about a crack pipe.