New JVM Option Enables Generation of Mixed-Mode Flame Graphs
转自 https://www.infoq.com/news/2015/08/JVM-Option-mixed-mode-profiles
Java has added a new launch option “-XX:+PreserveFramePointer” in JDK versions 8 and 9, that enables generation of mixed-mode flame graphs.
Flame graphs visually present the data gathered by performance profilers, tools used by developers for performance tuning their applications. In the past, Java developers had to use system profilers such as perf command in Linux, together with JVM profilers such as hprof, to get the full picture of their application performance.
System profilers only trace system code paths, whereas JVM profilers trace only the Java code paths. Netflix performance engineers Brendan Gregg and Martin Spier note that it is desirable for profilers to sample system as well as Java code paths:
To understand all types of CPU consumers, we previously used both types of profilers, creating a flame graph for each. This worked – sort of. While all CPU consumers could be seen, Java methods were missing from the system profile, which was crucial context we needed. Ideally, we would have one flame graph that shows it all: system and Java code together.
The reason profilers could not generate “mixed-mode” profiles (i.e., profile information from both system code path and Java code paths) was a result of how JVM Just In Time (JIT) compilers were implemented.
To understand this, we need to know that the operating system maintains layers of system calls in a “stack frame”. For example, on x86 machines, the most recent call of the stack frame is referenced by the frame pointer register. System profilers traverse the call stack of the process for profiling, and fetch details from the frame pointer register. Compilers and virtual machines (including the JVM JIT implementations) targeting x86 machines often calculate the offset from the stack pointer and hence they don't need to use the frame pointer register. They instead use the frame pointer as a general purpose register as an optimization. However, this optimization by the JVM JIT implementations break the ability of the profiling tools to traverse the stack and fetch call details.
To support mixed-mode profilers, the JVM has added support for the “-XX:+PreserveFramePointer” option. When this option is supplied, the JVM will abide by the frame pointer intended semantics and not use it as a general purpose register. Because this option disables a compiler optimization, there could be a small performance hit when this option is turned on. However, since this option is disabled by default, there is no performance impact for the default configuration of the JVM.
Brendan’s original post on the OpenJDK mailing list provides details of the patch for hotspot JVM.
InfoQ spoke to Brendan about the flame graphs and the new JDK option.
InfoQ: Does the new JDK option: -XX:+PreserveFramePointer help tools other than profilers, such as debuggers?
Brendan: This can make a difference for any debugger or profiler which uses frame pointers as a stack walking method, which is the traditional technique, e.g., gdb.
InfoQ: The Java bug issue supporting this option describes potential performance hit when this option is enabled. Can you elaborate on that?
Brendan: The performance hit should be small: between 0 and 3% depending on the workload. Microbenchmarks that run tight code may hurt more from lacking an extra register for compiler optimizations; whereas real world workloads should hurt less.
The performance hit was much larger in the past. x86 had fewer registers, so by freeing up a register helped more. There were also pipeline stall issues with managing the frame pointer. Both of these problems are much less of a concern with most modern processors.
InfoQ: Can you please share a sample mixed-mode flame graph that was generated with the help of this Java option?
Brendan: I think this is a nice example, and well understood.
With this JVM enhancement, Java developers can now run profilers and generate flame graphs that visualize both system code paths and Java code paths.
The FlameGraph project, which provides flame graph functionality externally, is available as a free download from GitHub. Developers can also download JDK 8(OpenJDK 8u60 - update 60 build 19) and Java 9 early access releases that support the “-XX:+PreserveFramePointer” option.
New JVM Option Enables Generation of Mixed-Mode Flame Graphs的更多相关文章
- jvm.option是什么,它是如何加载的
jvm.option是一些程序里边的java的配置参数的一个集合,不同的应用都会定义自己的jvm.options用来控制一些jvm的参数 以下,以elasticsearch为例,来说明它是如何加载的 ...
- JVM Guide
Java Virtual Machine: the Essential Guide October 8th, 2014 - By Alexey Zhebel Introduction Java Vir ...
- Java (JVM) Memory Model – Memory Management in Java
原文地址:http://www.journaldev.com/2856/java-jvm-memory-model-memory-management-in-java Understanding JV ...
- JVM监测&工具[转]
通过工具及Java api来监测JVM的运行状态, 需要监测的数据:(内存使用情况 谁使用了内存 GC的状况) 内存使用情况--heap&PermGen @ 表示通过jmap –heap pi ...
- Java 7 jstat – JVM Statistics Monitoring Tool【翻译】
原文地址:Java 7 jstat 本文内容 语法 参数 描述 虚拟机标识符 选项 一般选项 输出选项 示例 先发出来,然后慢慢翻译~ 语法 jstat [ generalOption | outpu ...
- JVM系列五:JVM监测&工具[整理中]
前几篇篇文章介绍了介绍了JVM的参数设置并给出了一些生产环境的JVM参数配置参考方案.正如之前文章中提到的JVM参数的设置需要根据应用的特性来进行设置,每个参数的设置都需要对JVM进行长时间的监测,并 ...
- JVM系列五:JVM监测&工具
JVM系列五:JVM监测&工具[整理中] http://www.cnblogs.com/redcreen/archive/2011/05/09/2040977.html 前几篇篇文章介绍了介 ...
- Tomcat 部署安装及JVM调优~
Tomcat 部署Tomcat环境 环境准备 linux: CentOS 7.3 tomcat: 9.0.0.M21 jdk: 1.8.0_131 ip: 192.168.1.5 tomcat官方下载 ...
- 10 Examples of HotSpot JVM Options in Java[z]
There are hundreds of JVM parameters or JVM Options exists inside sun JDK and its virtually impossib ...
随机推荐
- Eclipse 安装JavaEE插件
Oxygen版Eclipse 导入项目会自动安装你项目需要的一些插件,但是有时候会安装失败,需要手动安装: 这里以Dynamic Web Project项目为例 打开Eclipse,依次选择Help ...
- JFR 与 JProfilter Jvmisualvm
只有JFR 是可以在生产环境使用 采用C++独立写的采样手机功能 而 JProfilter/JVisualvm 都只能在测试环境下使用 使用instrument 机制 ,还有debug 框架 最早是 ...
- fio 测试磁盘
root@rook-test:/# ceph osd status+----+-----------------------------+-------+-------+--------+------ ...
- 运行Maven项目时出现invalid LOC header (bad signature)
为Maven小白,今天这问题困扰了我好久,经过多次在网上查询,终于找到了原因.明明一个小问题却耗费很多时间,着实不应该,所以必须记录一下. 报错信息如下: 对话框: 控制台: <span s ...
- Linux Tomcat重新启动
在Linux系统下,重启Tomcat使用命令操作的! 首先,进入Tomcat下的bin目录 cd /usr/local/tomcat/bin 使用Tomcat关闭命令 ./shutdown.sh 查看 ...
- 103041000997维护的是周批,按周合并后再考虑最小采购批量、舍入值、然后回写到SAP系统
描述:103041000997维护的是周批量,但最终没有按周批量来回写数据. 业务逻辑如下: 1.净需求考虑数量按周汇总(也有按日.按3天,具体 要根据物料主数据维护来判断) 2.第1点的结果再加上安 ...
- Cause: org.xml.sax.SAXParseException; lineNumber: 45; columnNumber: 62; 元素内容必须由格式正确的字符数据或标记组成。
三月 09, 2018 12:13:39 下午 org.apache.catalina.core.StandardContext listenerStart严重: Exception sending ...
- for循环语句个人小结
重新看了一下光盘上的用for循环写一个菱形的答案,发现了其实有几点是可以灵活运用的: 1,当定义行数的时候,也可以用相等的间断的数字隔开,比如 for(int a = 5; a >= 1; a- ...
- Ubuntu --- not enough free disk space
Ubuntu系统更新时出现not enough free disk space. 原因是系统的就内核占满了/boot 的空间,只要将旧内核删除就ok了 首先,命令 uname -r 查看当前内核,( ...
- php的反射
我们可以在PHP运行时,通过PHP的反射动态的获取类的方法.属性.参数等详细信息. 用途:插件的设计,文档的自动生成,扩充PHP语言. <?php class Person { const ...