可以将 Davlik 移入 Linux 内核以提高性能吗?

发布于 2024-10-30 05:49:38 字数 169 浏览 6 评论 0原文

这是一个非常高级的架构问题。为什么没有将 JVM 移入 Linux 内核,它可以更高效(包括即时编译的代码)。

我意识到这对于最小内核粉丝来说是令人厌恶的,但 Linux 不是这些操作系统之一, 它似乎。可以通过 /dev 条目控制 JVM 内核模块。

为什么不呢?

This is a very high-level architecture question. Why hasn't a JVM been moved into
the linux kernel, where it could be more efficient (including just-in-time compiled code).

I realize this is abhorrent to minimal-kernel fans, but Linux is not one of those OSs,
it seems. A JVM kernel module that could be controlled via a /dev entry would be possible.

Why not?

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

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

发布评论

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

评论(3

浊酒尽余欢 2024-11-06 05:49:38

将某些内容移入内核本身并不会“使其运行得更快”。在某些特殊情况下,它可以做的是允许使用替代方法。除非您有某种方法可以利用内核的优势,否则内核绝对没有任何好处。

Moving something into the kernel does not, by itself "make it go faster". What it can do in some exceptional cases is allow alternate approaches to be used. Until you have some way of taking advantage of being in kernel, there is absolutely no benefit to being in kernel.

梦毁影碎の 2024-11-06 05:49:38

我至少可以说出几个原因(当然还有更多):

  1. 内核模式下的编程和调试更加复杂和棘手。在用户模式下可以轻松完成的操作将需要大量的手工编码和大量的时间在内核模式下进行调试。
  2. 将 JVM 移至内核模式将消除在本机模块中使用 JNI 的可能性。
  3. 安全原因 - 隔离的单独 JVM 在不同的进程中运行,每个进程具有不同的权限。在内核模式下这是不可能的(没有大量额外的编码)。

I can name at least several reasons (surely there are much more):

  1. programming and debugging in kernel mode is much more complicated and tricky. What you can easily do in user-mode would require lots of hand-coding and significant time for debugging in kernel-mode.
  2. moving JVM to kernel mode would eliminate possibility to use JNI to native modules.
  3. security reasons - isolated separate JVMs run in different processes each having different permissions. This would not be possible (without lots of additional coding) in kernel mode.
停滞 2024-11-06 05:49:38

它可能不会更有效率;它的效率可能较低。每次你想要处理数据时,数据都位于内核之外(除非你也将你的程序和它们想要的任何数据直接加载到内核中),并且至少需要发生两次上下文切换;如果解释器位于内核之外,则不需要上下文切换(除非必须从某处读取数据(文件、用户、网络等)。

此外,那些“从某处读取”的情况将产生额外的上下文即使内核请求,也会进行切换,因为在幕后需要进行很多工作才能获取该数据

(上下文切换非常昂贵。它们有点像踢 CPU 的头,然后再进行切换。当它不再看到星星时,告诉它看别的东西;然后它需要记下你踢它之前它在做什么,然后去阅读它关于你刚刚告诉它做什么的注释。)

It might not be more efficient; it might well be less efficient. Every time you want to work with data, the data lives outside the kernel (unless you've also loaded your programs and whatever data they want directly into the kernel) and at least two context switches will need to happen; if the interpreter is outside of the kernel, no context switches are necessary (unless that data has to be read from somewhere (a file, the user, the network, whatever).

Moreover, those "read from somewhere" cases will incur additional context switches even if requested by the kernel, because there's a lot of stuff going on behind the scenes to get that data.

(Context switches are expensive. They're a bit like kicking the CPU in the head and telling it to look at something else when it stops seeing stars; then it needs to write down what it was doing before you kicked it, and then go read its notes about what you just told it to do.)

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