“java -server"之间的真正区别和“java -client"? [英] Real differences between "java -server" and "java -client"?

查看:26
本文介绍了“java -server"之间的真正区别和“java -client"?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

java -server"和java -client"之间有什么真正的实际区别吗?

我在 Sun 的网站上只能找到一个模糊的信息

<块引用>

-server 启动较慢,但应该运行得更快".

真正的区别是什么?(目前使用 JDK 1.6.0_07.)

解决方案

这实际上与 HotSpot 和默认的 选项值 (Java HotSpot VM 选项) 在客户端和服务器配置之间有所不同.

来自白皮书的第 2 章(Java HotSpot 性能引擎架构):

<块引用>

JDK 包括两种类型的 VM——客户端产品和针对服务器应用程序调整的 VM.这两种解决方案共享 Java HotSpot 运行时环境代码库,但使用不同的编译器,以适应客户端和服务器明显独特的性能特征.这些差异包括编译内联策略和堆默认值.

尽管服务器和客户端虚拟机相似,但服务器虚拟机已经过专门调整以最大限度地提高峰值运行速度.它旨在执行长时间运行的服务器应用程序,这些应用程序需要尽可能快的运行速度,而不是快速启动时间或较小的运行时内存占用.

客户端 VM 编译器用作经典 VM 和先前版本的 JDK 使用的即时 (JIT) 编译器的升级.客户端 VM 为应用程序和小程序提供改进的运行时性能.Java HotSpot 客户端 VM 已经过专门调整,以减少应用程序启动时间和内存占用,使其特别适合客户端环境.一般来说,客户端系统更适合 GUI.

所以真正的区别还在于编译器级别:

<块引用>

客户端 VM 编译器不会尝试执行许多由服务器 VM 中的编译器执行的更复杂的优化,但作为交换,它分析和编译一段代码所需的时间更少.这意味着客户端 VM 可以更快地启动并且需要更小的内存占用.

服务器 VM 包含一个高级自适应编译器,它支持由优化 C++ 编译器执行的许多相同类型的优化,以及一些传统编译器无法完成的优化,例如跨虚拟方法调用的积极内联.这是相对于静态编译器的竞争和性能优势.自适应优化技术的方法非常灵活,通常甚至优于高级静态分析和编译技术.

注意:jdk6 update 10 的发布(参见更新发行说明:1.6.0_10 中的更改) 试图缩短启动时间,但出于与热点选项不同的原因,使用更小的内核进行了不同的打包.


G.Demecki 指出 在评论,在 64 位版本的 JDK 中,-client 选项多年来被忽略.
请参阅 Windows java 命令:

-客户端

<块引用>

选择 Java HotSpot 客户端虚拟机.
支持 64 位的 JDK 当前忽略此选项,而是使用 Java Hotspot Server VM.

Is there any real practical difference between "java -server" and "java -client"?

All I can find on Sun's site is a vague

"-server starts slower but should run faster".

What are the real differences? (Using JDK 1.6.0_07 currently.)

解决方案

This is really linked to HotSpot and the default option values (Java HotSpot VM Options) which differ between client and server configuration.

From Chapter 2 of the whitepaper (The Java HotSpot Performance Engine Architecture):

The JDK includes two flavors of the VM -- a client-side offering, and a VM tuned for server applications. These two solutions share the Java HotSpot runtime environment code base, but use different compilers that are suited to the distinctly unique performance characteristics of clients and servers. These differences include the compilation inlining policy and heap defaults.

Although the Server and the Client VMs are similar, the Server VM has been specially tuned to maximize peak operating speed. It is intended for executing long-running server applications, which need the fastest possible operating speed more than a fast start-up time or smaller runtime memory footprint.

The Client VM compiler serves as an upgrade for both the Classic VM and the just-in-time (JIT) compilers used by previous versions of the JDK. The Client VM offers improved run time performance for applications and applets. The Java HotSpot Client VM has been specially tuned to reduce application start-up time and memory footprint, making it particularly well suited for client environments. In general, the client system is better for GUIs.

So the real difference is also on the compiler level:

The Client VM compiler does not try to execute many of the more complex optimizations performed by the compiler in the Server VM, but in exchange, it requires less time to analyze and compile a piece of code. This means the Client VM can start up faster and requires a smaller memory footprint.

The Server VM contains an advanced adaptive compiler that supports many of the same types of optimizations performed by optimizing C++ compilers, as well as some optimizations that cannot be done by traditional compilers, such as aggressive inlining across virtual method invocations. This is a competitive and performance advantage over static compilers. Adaptive optimization technology is very flexible in its approach, and typically outperforms even advanced static analysis and compilation techniques.

Note: The release of jdk6 update 10 (see Update Release Notes:Changes in 1.6.0_10) tried to improve startup time, but for a different reason than the hotspot options, being packaged differently with a much smaller kernel.


G. Demecki points out in the comments that in 64-bit versions of JDK, the -client option is ignored for many years.
See Windows java command:

-client

Selects the Java HotSpot Client VM.
A 64-bit capable JDK currently ignores this option and instead uses the Java Hotspot Server VM.

这篇关于“java -server"之间的真正区别和“java -client"?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆