浏览器选项卡哪个更好:多线程还是多进程?

发布于 2024-10-04 06:33:13 字数 1432 浏览 3 评论 0原文

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(6

℉絮湮 2024-10-11 06:33:13

这取决于您的实施质量和您的优先事项。线程有可能使用更少的内存/共享更多的内存,并且可能比进程执行得更好或更差,具体取决于您使用的同步原语。另一方面,由于浏览器实现的质量非常糟糕,当一个坏网站欺骗浏览器分配无限量的内存或更糟的情况时,您真的希望整个浏览器和所有选项卡崩溃吗?

多进程浏览器实现很像 OpenSSH、vsftpd 等中的权限分离模型。您需要牺牲一些资源来让内核保护您免受代码中的错误的影响。

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.

情深已缘浅 2024-10-11 06:33:13

这取决于您的需求。

如果您正在

  • 寻找资源最少的浏览器,
  • 不运行繁重的 JavaScript,
  • 没有大量内存

,那么您可能会选择多线程。

但是,如果您

  • 同时运行多个页面,
  • 运行资源密集型 Web 应用程序,

您可能需要多进程。由于当今大多数计算机和 Web 应用程序都属于第二类,因此多进程可能是当今更好的选择。这是因为进程允许您将每个选项卡分隔在其自己的沙箱中。这意味着如果一个选项卡崩溃,您不会丢失其他选项卡。

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.

仙女 2024-10-11 06:33:13

答案:这是一种权衡。

线程:无论如何,在 Windows 上通常是最好的。进程是这些系统上资源匮乏的实现。

流程:如果安全/稳定性是主要考虑因素,那么流程就很好。因为一个进程宕机导致整个浏览器宕机的可能性要小得多。 (但是为什么浏览器会崩溃?)并且使用操作系统原语更容易安全地隔离,但是以更多系统资源为代价(多少取决于操作系统)。

混合:又称为使用进程和线程。这是最好的方法。加载一定数量的组件,使用线程,直到进程变得足够大,足以证明另一个进程的额外开销(取决于操作系统),然后创建另一个进程。

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.

原来分手还会想你 2024-10-11 06:33:13

“哪个是更好的选择”是什么意思?在讨论为什么一个比另一个更好之前,你必须先定义“更好”。您的目标是什么?它们的相对优先事项是什么?稳定性、内存使用、CPU 时间、使用的内核对象数量哪个最重要?您想要的答案将要求您首先提供这些优先级。也就是说,您需要先定义什么是“更好”,然后我们才能帮助您决定哪一个更好。

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.

想你只要分分秒秒 2024-10-11 06:33:13

好吧,我认为每次我们打开一个新选项卡时,它都会创建一个线程,这是有益的,因为线程不需要另一个资源,也不会使用更多内存,并且您的系统速度不会受到更大的影响。

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.

小伙你站住 2024-10-11 06:33:13

我认为多进程是更好的方法。在多线程中存在安全问题,我们不希望有人窃取我们的信用卡号。如果一个进程变慢,整个浏览器就会崩溃,这是没有意义的。就好像我们的浏览器非常特定于某些应用程序(例如仅研究),它只处理互联网的一个子集,我们可以分析基于进程和线程的浏览器的优缺点。多线程浏览器肯定会快速且轻松同步。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文