开发者

Could Davlik be moved inside the linux kernel for performance?

开发者 https://www.devze.com 2023-02-22 06:30 出处:网络
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).

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 modu开发者_开发问答le that could be controlled via a /dev entry would be possible.

Why not?


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.


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.


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.)

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号