https://docs.oracle.com/javase/8/docs/technotes/guides/vm/gctuning/ergonomics.html

2 Ergonomics

Ergonomics is the process by which the Java Virtual Machine (JVM) and garbage collection tuning, such as behavior-based tuning, improve application performance. The JVM provides platform-dependent default selections for the garbage collector, heap size, and runtime compiler. These selections match the needs of different types of applications while requiring less command-line tuning. In addition, behavior-based tuning dynamically tunes the sizes of the heap to meet a specified behavior of the application.

This section describes these default selections and behavior-based tuning. Use these defaults first before using the more detailed controls described in subsequent sections.

Garbage Collector, Heap, and Runtime Compiler Default Selections

A class of machine referred to as a server-class machine has been defined as a machine with the following:

  • 2 or more physical processors

  • 2 or more GB of physical memory

On server-class machines, the following are selected by default:

  • Throughput garbage collector

  • Initial heap size of 1/64 of physical memory up to 1 GB

  • Maximum heap size of 1/4 of physical memory up to 1 GB

  • Server runtime compiler

For initial heap and maximum heap sizes for 64-bit systems, see the section Default Heap Size in The Parallel Collector.

The definition of a server-class machine applies to all platforms with the exception of 32-bit platforms running a version of the Windows operating system. Table 2-1, "Default Runtime Compiler", shows the choices made for the runtime compiler for different platforms.

Table 2-1 Default Runtime Compiler

Platform Operating System DefaultFoot1 Default if Server-ClassFootref1

i586

Linux

Client

Server

i586

Windows

Client

ClientFoot2

SPARC (64-bit)

Solaris

Server

ServerFoot3

AMD (64-bit)

Linux

Server

ServerFootref3

AMD (64-bit)

Windows

Server

ServerFootref3

Footnote1Client means the client runtime compiler is used. Server means the server runtime compiler is used.

Footnote2The policy was chosen to use the client runtime compiler even on a server class machine. This choice was made because historically client applications (for example, interactive applications) were run more often on this combination of platform and operating system.

Footnote3Only the server runtime compiler is supported.

Behavior-Based Tuning

For the parallel collector, Java SE provides two garbage collection tuning parameters that are based on achieving a specified behavior of the application: maximum pause time goal and application throughput goal; see the section The Parallel Collector. (These two options are not available in the other collectors.) Note that these behaviors cannot always be met. The application requires a heap large enough to at least hold all of the live data. In addition, a minimum heap size may preclude reaching these desired goals.

Maximum Pause Time Goal

The pause time is the duration during which the garbage collector stops the application and recovers space that is no longer in use. The intent of the maximum pause time goal is to limit the longest of these pauses. An average time for pauses and a variance on that average is maintained by the garbage collector. The average is taken from the start of the execution but is weighted so that more recent pauses count more heavily. If the average plus the variance of the pause times is greater than the maximum pause time goal, then the garbage collector considers that the goal is not being met.

The maximum pause time goal is specified with the command-line option -XX:MaxGCPauseMillis=<nnn>. This is interpreted as a hint to the garbage collector that pause times of <nnn> milliseconds or less are desired. The garbage collector will adjust the Java heap size and other parameters related to garbage collection in an attempt to keep garbage collection pauses shorter than <nnn> milliseconds. By default there is no maximum pause time goal. These adjustments may cause garbage collector to occur more frequently, reducing the overall throughput of the application. The garbage collector tries to meet any pause time goal before the throughput goal. In some cases, though, the desired pause time goal cannot be met.

Throughput Goal

The throughput goal is measured in terms of the time spent collecting garbage and the time spent outside of garbage collection (referred to as application time). The goal is specified by the command-line option -XX:GCTimeRatio=<nnn>. The ratio of garbage collection time to application time is 1 / (1 + <nnn>). For example, -XX:GCTimeRatio=19 sets a goal of 1/20th or 5% of the total time for garbage collection.

The time spent in garbage collection is the total time for both the young generation and old generation collections combined. If the throughput goal is not being met, then the sizes of the generations are increased in an effort to increase the time that the application can run between collections.

Footprint Goal

If the throughput and maximum pause time goals have been met, then the garbage collector reduces the size of the heap until one of the goals (invariably the throughput goal) cannot be met. The goal that is not being met is then addressed.

Tuning Strategy

Do not choose a maximum value for the heap unless you know that you need a heap greater than the default maximum heap size. Choose a throughput goal that is sufficient for your application.

The heap will grow or shrink to a size that will support the chosen throughput goal. A change in the application's behavior can cause the heap to grow or shrink. For example, if the application starts allocating at a higher rate, the heap will grow to maintain the same throughput.

If the heap grows to its maximum size and the throughput goal is not being met, the maximum heap size is too small for the throughput goal. Set the maximum heap size to a value that is close to the total physical memory on the platform but which does not cause swapping of the application. Execute the application again. If the throughput goal is still not met, then the goal for the application time is too high for the available memory on the platform.

If the throughput goal can be met, but there are pauses that are too long, then select a maximum pause time goal. Choosing a maximum pause time goal may mean that your throughput goal will not be met, so choose values that are an acceptable compromise for the application.

It is typical that the size of the heap will oscillate as the garbage collector tries to satisfy competing goals. This is true even if the application has reached a steady state. The pressure to achieve a throughput goal (which may require a larger heap) competes with the goals for a maximum pause time and a minimum footprint (which both may require a small heap).

Contents   Previous   Next

Ergonomics JVM 的一种FullGC的说明的更多相关文章

  1. Java JVM使用哪种编码格式

    Java JVM使用哪种编码格式 A ASCII characters  B Unicode characters C Cp1252 D UTF-8 E GBK F GBK2312 答案:B   在J ...

  2. JIT与JVM的三种执行模式:解释模式、编译模式、混合模式

    Java JIT(just in time)即时编译器是sun公司采用了hotspot虚拟机取代其开发的classic vm之后引入的一项技术,目的在于提高java程序的性能,改变人们“java比C/ ...

  3. Java应用中使用ShutdownHook友好地清理现场、退出JVM的2种方法

    Runtime.getRuntime().addShutdownHook(shutdownHook);    这个方法的含义说明:        这个方法的意思就是在jvm中增加一个关闭的钩子,当jv ...

  4. JVM的7种垃圾收集器:主要特点 应用场景 设置参数 基本运行原理

    原文地址:https://blog.csdn.net/tjiyu/article/details/53983650 下面先来了解HotSpot虚拟机中的7种垃圾收集器:Serial.ParNew.Pa ...

  5. 深入理解JVM,7种垃圾收集器

    本人免费整理了Java高级资料,一共30G,需要自己领取.传送门:https://mp.weixin.qq.com/s/JzddfH-7yNudmkjT0IRL8Q 如果说收集算法是内存回收的方法论, ...

  6. JVM之几种垃圾收集器简单介绍

    本文中的垃圾收集器研究背景为:HotSpot+JDK1.7 一.垃圾收集器概述 如上图所示,垃圾回收算法一共有7个,3个属于年轻代.三个属于年老代,G1属于横跨年轻代和年老代的算法. JVM会从年轻代 ...

  7. JVM(HotSpot) 7种垃圾收集器的特点及使用场景

    这里讨论的收集器基于JDK1.7Update 14之后的HotSpot虚拟机,这个虚拟机包含的所有收集器如下图3-5所示: 上图展示了7种作用于不同分代的收集器,如果两个收集器之间存在连线,就说明它们 ...

  8. JVM的四种GC算法

    程序在运行过程中,会产生大量的内存垃圾(一些没有引用指向的内存对象都属于内存垃圾,因为这些对象已经无法访问,程序用不了它们了,对程序而言它们已经死亡),为了确保程序运行时的性能,java虚拟机在程序运 ...

  9. 直通BAT必考题系列:JVM的4种垃圾回收算法、垃圾回收机制与总结

    垃圾回收算法 1.标记清除 标记-清除算法将垃圾回收分为两个阶段:标记阶段和清除阶段. 在标记阶段首先通过根节点(GC Roots),标记所有从根节点开始的对象,未被标记的对象就是未被引用的垃圾对象. ...

  10. 深入理解JVM,7种垃圾收集器,看完我跪了

    如果说收集算法是内存回收的方法论,那么垃圾收集器就是内存回收的具体实现.Java虚拟机规范中对垃圾收集器应该如何实现并没有任何规定,因此不同的厂商.版本的虚拟机所提供的垃圾收集器都可能会有很大差别,并 ...

随机推荐

  1. 新版以太坊Ethereum库ethersV5.0配合后端Golang1.18实时链接区块链钱包(Metamask/Okc)以及验签操作

    区块链去中心化思想无处不在,比如最近使用个体抗原自检替代大规模的中心化核酸检测,就是去中心化思想的落地实践,避免了大规模聚集导致的交叉感染,提高了检测效率,本次我们使用Ethereum最新的ether ...

  2. 物联网常见协议之Amqp协议及使用场景解析

    摘要:本文围绕AMQP协议,为大家详细解析AMQP协议.核心技术亮点.多协议之间的对比以及使用实践. 本文分享自华为云社区<物联网常见协议之Amqp协议及使用场景解析>,作者:张俭. 引言 ...

  3. CWE发布2021年最危险的25种软件缺陷

    摘要:CWE最危险的25种软件缺陷,是NVD过去两年中遇到的最常见和影响最大的问题指示性的列表. CWE Top25 可以帮助开发人员.测试人员和用户,以及项目经理.安全研究人员和教育工作者深入了解最 ...

  4. 云小课|CDN第5课 CDN入门之—我的网站可以用CDN加速吗?

    摘要:CDN(Content Delivery Network,内容分发网络)通过将源站资源缓存到遍布各地的边缘节点服务器上,用户可以就近获取资源,从而达到加速的效果. 本文分享自华为云社区<[ ...

  5. Spring Boot 接口返回文件流

    import org.springframework.core.io.FileSystemResource; import org.springframework.core.io.Resource; ...

  6. 遇事不决,量子力学;不懂配色,赛博朋克。推荐一个Python可视化库

    遇事不决,量子力学;不懂配色,赛博朋克.推荐一个Python可视化库 12月10日,历经多次跳票后,波兰公司CD Projekt Red制作的<赛博朋克2077>终于正式发售,在Steam ...

  7. CodeFormer一款既能人脸修复、还能视频去码的AI软件,附下载使用教程

    CodeFormer是一款强大的人工智能工具,主要用于图像和视频的修复和增强.它基于深度学习技术,特别是人脸复原模型,可以轻松修复和增强面部图像,提升照片和视频的质量和视觉效果 工作原理 1.通过自动 ...

  8. ABAP使用异步远程RFC实现并行处理

    1.使用场景 当开发复杂报表,需要处理大量数据,不管怎么优化计算和查询语句,程序的运行效率还是达不到用户要求,怎么办? 为了解决这个问题,就需要程序实现并行处理. 本文档就是通过异步调用远程RFC的办 ...

  9. Codeforce 1327A - Sum of Odd Integers

    Example input 6 3 1 4 2 10 3 10 2 16 4 16 5 output YES YES NO YES YES NO 解题思路:首先我们应该知道:偶数个奇数相加一定是偶数, ...

  10. 『NexT』,一款 NexT 风格的 Typora 主题

    很喜欢 Hexo 中的 Next 主题,便想要在 Typora 中书写时获得和在 Hexo 中一样的预览效果,翻了一下Typora的theme仓库发现已经有dalao (知乎@Bill Chen)写了 ...