jvmti

使用TProfiler分析并调优项目中的Fastjson序列化代码

北城以北 提交于 2019-11-29 01:25:20
新项目年后就上线了,现在业务上没什么问题,就用 TProfiler 做了下性能分析,果然有坑。 ##一、TProfiler入门 高手请自觉略过本节。 ###1.简介 TProfiler是阿里巴巴开源的一款性能分析工具。号称可以用于生产环境进行长期的性能分析。测试程序部署后,在低峰期对响应时间影响20%,在高峰期对QPS影响30%。详细介绍请见 官方WIKI 。 ###2.简要的实现原理 TProfiler的实现基于JAVA的 Instrumentation 和ASM。 Instrumentation可以理解为一种虚拟机级别的AOP实现 ,无需对项目代码和JDK有任何改动就可以实现AOP功能。TProfiler利用Instrumentation提供的入口,调用ASM将待分析的类的字节码进行修改,加入分析记录方法。在Profiler运行时即可抽样收集到相关类方法的调用信息。使用Instrumentation时也可以通过JVMTI提供的接口实现对类的完全控制。至于 为什么TProfiler会选择ASM ,我想可能有两方面的考虑: 1)性能上更高效。使用JVMTI在每个类装入时都要执行hook程序,而ASM没有明显的性能代价。 2)使用JVMTI对编程难度要求较高,要求对class文件结构和java字节码有深刻了解,而ASM虽然也有一些难度,但是相对来说还是小一些。 ###3.配置

Unloading a JVMTI agent at runtime?

我是研究僧i 提交于 2019-11-27 18:03:42
问题 I'm using the attach API to load a JVMTI agent at runtime. I'd like to unload the JVMTI agent when my program is done without terminating the JVM the agent is loaded in. According to this documentation there is no way to do this from the attach API. Are there any other ways to force an agent to unload its self either through a Java API or from within the JVMTI agent? 回答1: JVMTI spec says unloading (without JVM termination) is possible, but platform-dependent and out of specification's scope.

Java: How do you really force a GC using JVMTI's ForceGargabeCollection?

旧时模样 提交于 2019-11-27 09:01:48
I'm not looking for the usual "you can only hint the GC in Java using System.gc() " answers, this is not at all what this question is about. My questions is not subjective and is based on a reality: GC can be forced in Java for a fact. A lot of programs that we use daily do it: IntelliJ IDEA, NetBeans, VisualVM. They all can force GC to happen. How is it done? I take it they're all using JVMTI and more specifically the ForceGarbageCollection (notice the "Force") but how can I try it for myself? http://java.sun.com/javase/6/docs/platform/jvmti/jvmti.html#ForceGarbageCollection Also note that

Java: How do you really force a GC using JVMTI's ForceGargabeCollection?

烂漫一生 提交于 2019-11-26 17:47:54
问题 I'm not looking for the usual "you can only hint the GC in Java using System.gc() " answers, this is not at all what this question is about. My questions is not subjective and is based on a reality: GC can be forced in Java for a fact. A lot of programs that we use daily do it: IntelliJ IDEA, NetBeans, VisualVM. They all can force GC to happen. How is it done? I take it they're all using JVMTI and more specifically the ForceGarbageCollection (notice the "Force") but how can I try it for