23

I wonder which is a better choice for implementing tabs in a web browser? (Ex: Firefox use multi-threading for their tabs, while Google Chrome use multi-processes ... )

  • 3
    You may want to make the question appear less subjective. What are the advantages and disadvantages of thread/process tab separation in browsers, and perhaps not mention them by name... – Matt Joiner Nov 24 '10 at 03:09
  • 1
    Note that Firefox is in the process of [implementing](https://wiki.mozilla.org/Electrolysis) this. – Matthew Flaschen Nov 24 '10 at 03:16
  • @ Matthew Flaschen : Thank you Matthew, this is what i'm looking for. Seems like chrome is leading ahead of Firefox in general use for its stability and other stuffs .... –  Nov 24 '10 at 03:21
  • 1
    @tsubasa: Hardly... Firefox is an epic browser, and presently much more stable than Chrome. Take it from a fan of both. – Matt Joiner Nov 24 '10 at 03:24
  • Why does this sound like a dupe... – IAbstract Nov 24 '10 at 03:50
  • Yep: http://stackoverflow.com/questions/201674/tabs-in-their-own-process-with-c-and-winforms-closed which also references: http://stackoverflow.com/questions/197182?sort=newest. – IAbstract Nov 24 '10 at 03:53
  • 1
    @dboarman: Don't be ridiculous. – Matt Joiner Nov 24 '10 at 14:13
  • @Matt: what do you mean? This post is covering the same ground as 2 previous questions. There is nothing specific about the languages that would make answers any better than those previously posted, nor would there be any significant addition to improve the content of the answers. – IAbstract Nov 24 '10 at 15:45
  • @dboarman: To paraphrase: "Tabs in their own process with C# and WinForms", "Is there anyway to use C# to build a container app where each tab is actually its own process like with Google chrome.". This question asks "Which is better ... in C". Not how, and not using Windows-only Winforms crap. – Matt Joiner Nov 25 '10 at 01:19
  • @Matt: Technically, the OP isn't even asking a question...simply pondering an idea that begs to be subjective. Just look at the answers. – IAbstract Nov 25 '10 at 23:24
  • @dboarman: Yes, I'll agree it's subjective. A real answer would discuss the differences between threads and processes. http://stackoverflow.com/questions/3609469/what-are-the-thread-limitations-when-working-on-linux-compared-to-processes-for-n/3705919#3705919 – Matt Joiner Nov 26 '10 at 02:20
  • @Matt: good answer...and your answer would fit here for this OP, IMO. Again, although the OP suggests 'C' as the language, the OP isn't actually asking a question specific to C; therefore, I contend that this is still a duplicate. I am certainly willing to admit that we agree to disagree. Good answer nonetheless... ;) – IAbstract Nov 26 '10 at 03:20

6 Answers6

25

It depends on the quality of your implementation and your priorities. Threads have the potential to use less memory/share more, and might perform better or worse than processes depending on synchronization primitives you use. On the other hand, with the utter crap quality of browser implementations, do you really want the whole browser and all your tabs crashing when one bad site tricks the browser into allocating unbounded amounts of memory or worse?

Multi-process browser implementations are a lot like the privilege separation model in OpenSSH, vsftpd, etc. You're sacrificing some resources to have the kernel protect you against bugs in your code.

R.. GitHub STOP HELPING ICE
  • 208,859
  • 35
  • 376
  • 711
  • +1 on the isolation point. Due to threads sharing the same address space, an illegal operation performed by a thread can crash the entire process. Therefore, one misbehaving thread can disrupt the processing of all the other threads. – truongnm May 21 '22 at 03:20
20

It depends on what your needs are.

If you are

  • Looking for a resource minimal browser
  • Not running heavy javascripts
  • Not having a lot of memory

Then you are probably going to go with multi threading.

However, if you are

  • Running many pages at once
  • Running resource intensive web applications

You probably are going to want multi-process. Since most computers and web applications fit in the second category today, Multi-Process is probably, today the better choice. This is because processes allow you to separate each tab in its own sandbox. That means if one tab crashes, you aren't going to lose the other tabs.

xaav
  • 7,876
  • 9
  • 30
  • 47
3

Answer: It's a tradeoff.

Threads: on Windows are usually best no matter what. Processes are resource hungry implementations on those systems.

Processes: are good if security / stability is a chief concern. Because one process going down is much less likely to bring the whole browser down. (But why should the browser be expected to crash?) And is easier to securely isolate using OS primitives, but at a cost of more system resources (how much depends on the OS).

Hybrid: AKA Using Processes and Threads. This is the best approach. Loading a certain number of components, using threads until the process becomes large enough to justify the additional overhead of another process (depending on the OS), and then creating another process.

unixman83
  • 9,421
  • 10
  • 68
  • 102
2

What do you mean, 'which is a better choice'? You have to define "better" before you can discuss why one is better than the other. What are you goals, and what are their relative priorities? Which is most important, stability, memory usage, CPU time, number of kernel objects in use? The answer you want will require you to provide these priorities first. That is, you need to define what "better" is before we can help you decide which one is better.

George
  • 2,034
  • 1
  • 15
  • 16
-1

Well i think every time we open a new tab , it creates a thread , and it is benificial as thread will not require another resoces and will not use more memory and your system spped will not get more affected.

-2

I think a multi-process is a better approach. In multi-thread there are security issues, and we don't want some one to steal our credit card number. If one process becomes slow, due that whole browser would crash down,does not make sense. Where as if our browser is very specific to certain application like research only, which deals with only a subset of internet we can analyse the pros and cons of process and thread based browser. A multi-thread browser would sure be fast and easily synchronized.

Rishabh
  • 34
  • 8