JVM + Linux +英特尔的超线程 =

发布于 2024-12-17 21:36:47 字数 157 浏览 2 评论 0原文

我注意到由于某些原因,JVM 线程在 Linux 下作为进程运行(如果我错了,请纠正我)。此外,事实上,英特尔的超线程仅为属于同一进程的两个线程提供额外的并行化。

这是否意味着单个多线程 JVM 程序不会从 Linux 下的超线程中获益,因为从 CPU“角度”来看,它的线程不是线程?

I noticed that JVM threads run as processes under Linux for some reasons (correct me if I'm wrong). Furthermore, it is a fact that Intel's Hyperthreading provides additional parallelization only for two threads belonging to same process.

Does that mean that a single multitheraded JVM program would not profit from Hyperthreading under Linux, because its threads are no threads from the CPUs "point of view"?

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

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

发布评论

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

评论(2

滥情哥ㄟ 2024-12-24 21:36:47

Linux 中的调度程序对进程和线程的处理方式没有区别。有一系列资源可以被进程共享,如 clone 系统调用。通常使用的线程和进程只是常用配方的名称。

如果您将线程视为 JVM 中的进程,那么这只是术语的混合。根据通常的定义,如果进程共享虚拟地址空间,那么它们就是进程内的“线程”。

无论使用什么术语,所有硬件调度都将受益于超线程。另外,为了完全公平,超线程不允许您并行运行更多线程:它使上下文切换更快,为进程提供更多运行时间。

Processes and threads are not treated differently by the scheduler in Linux. There are a range of resources that can be shared by processes, as defined by the clone system call. Threads and processes as they're typically used are just names for commonly used recipes.

If you're observing threads as processes in the JVM, this is just a mixing of nomenclature. By the usual definition if processes are sharing a virtual address space, then they are "threads" within a process.

All hardware scheduling will benefit from hyper-threading, regardless of the terminology used. Also to be completely fair, hyper threading does not allow you to run more threads in parallel: it makes context switches faster, giving processes more run time.

养猫人 2024-12-24 21:36:47

“JVM 线程在 Linux 下作为进程运行”——不,它们作为 LWP(轻量级进程)运行。

Java 线程在内部实现为本地线程,即 LWP(在 Linux 中),您可以使用 ps -eLf 来查看它们。尽管本机线程和 Java 线程之间的映射很困难。唯一可以轻松映射的线程是主线程,因为它的 id 与进程 id 相同。

JVM 肯定会从 HT 中获益。
来自关于 Java 中的 HT 的文章:

SMT 有望显着提高 Java 的服务器端性能
通过更充分地利用现有处理器周期来提高性能
多线程应用程序。

"JVM threads run as processes under Linux "-- No they run as LWP(Light Weight Process).

Java threads are internally implemented as native threads i.e. LWP (in linux) and you can see them using ps -eLf. Though mapping between a native thread and a java thread is difficult. The only thread that can be mapped easily is the main-thread as it will have the id same as the process id.

JVM will definitely profit from HT.
From an article on HT in java:

SMT holds the promise of significantly increasing Java's server-side
performance by more completely utilizing existing processor cycles in
multithreaded applications.

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