需先从 MyPerf4J-ASM.zip 解压并修改 app_name、metrics.log.xxx 和 filter.packages.include 配置;JDK9 及以上需额外添加 --add-opens java.base/java.lang=ALL-UNNAMED;Grafana 展示效果需另行安装配置 InfluxDB

MyPerf4J
LinShunKangBSD-3-Clause活跃维护基于 ASM 字节码增强的高性能 Java APM,以 Java Agent 方式无侵入采集方法耗时、JVM 和线程指标,帮你在生产环境低成本做性能监控与诊断。
High performance Java APM. Powered by ASM. Try it. Test it. If you feel its better, use it.
java -javaagent:/path/to/MyPerf4J-ASM.jar -DMyPerf4JPropFile=/path/to/MyPerf4J.properties -jar yourApp.jarREADME 未说明硬件要求,仅需可运行 Java 应用的环境
基于 JavaAgent 的高性能 Java APM,无侵入采集方法耗时与 JVM 指标,快速定位性能瓶颈
基于 ASM 字节码增强的高性能 Java APM,以 Java Agent 方式无侵入采集方法耗时、JVM 和线程指标,帮你在生产环境低成本做性能监控与诊断。
核心能力
- 用 JavaAgent 字节码增强实现无侵入接入
- 单线程每秒记录 1600 万次响应时间,每次 63 纳秒
- 内存复用减少临时对象,不影响应用 GC
- 支持秒级全量统计,最低统计粒度 1 秒
- 采集 RPS、TP50~TP9999 等方法指标与 JVM 指标
容易踩的坑
- 3.6.0最新正式版2025-11-16 · 2025-11-16 13:18 UTC
Refactor
- Clean codes @LinShunKang
Dependency Upgrade
- Upgrading the artifact org.ow2.asm:asm-commons:9.9
- 3.5.02025-10-18 · 2025-10-18 08:30 UTC
查看更新说明
Features
- Support V3 JVM GC @LinShunKang
- 3.4.02024-09-08 · 2024-09-08 14:04 UTC
查看更新说明
Features
- Support SpringBoot 3.x @LinShunKang
Dependency Upgrade
- Upgrading the artifact org.ow2.asm:asm-commons:9.7
- 3.3.02023-09-24 · 2023-09-24 13:12 UTC
查看更新说明
Features
- Support JDK17 ZGC Cycles and ZGC Pauses by @LinShunKang
- Support InfluxDB 2.x by @LinShunKang
Performance
- Introduce AtomicIntHashCounter to reduce memory footprint by @LinShunKang
- Optimize JVM Thread Metrics collection performance by @LinShunKang
BugFix
- Fix windows env getConfigFileDir is empty by @JiaRG https://github.com/LinShunKang/MyPerf4J/pull/88
Dependency Upgrade
- Upgrading the artifact org.ow2.asm:asm-commons:9.5
- Upgrading the artifact org.openjdk.jmh:jmh-core:1.34
- Upgrading the artifact org.openjdk.jmh:jmh-generator-annprocess:1.34
- 3.2.02021-05-15 · 2021-05-15 06:22 UTC
查看更新说明
Features
- Enhance the configuration of
http.server.portto support the specified port range - Try to create InfluxDB databse at startup
- Add
Filter,Handler,ProcessorandDispatcherlevel mappings
Fix
- Fix the IndexOutOfBoundsException in
IntBuf#setInt(int, int)
- Enhance the configuration of
用户点评
登录用户的真实使用记录,可按版本和硬件筛选还没有人点评。第一个说出真实体验的人最有价值。
简体中文 | English
一个针对高并发、低延迟应用设计的高性能 Java 性能监控和统计工具。
价值
- 快速定位性能瓶颈
- 快速定位故障原因
优势
- 高性能: 单线程支持每秒 1600 万次 响应时间的记录,每次记录只花费 63 纳秒
- 无侵入: 采用 JavaAgent 方式,对应用程序完全无侵入,无需修改应用代码
- 低内存: 采用内存复用的方式,整个生命周期只产生极少的临时对象,不影响应用程序的 GC
- 高实时: 支持秒级统计,最低统计粒度为 1 秒,并且是全量统计,不丢失任何一次记录
文档
监控指标
MyPerf4J 为每个应用收集数十个监控指标,所有的监控指标都是实时采集和展现的。
下面是 MyPerf4J 目前支持的监控指标列表:
-
Method Metrics RPS,Count,Avg,Min,Max,StdDev,TP50, TP90, TP95, TP99, TP999, TP9999, TP100

-
JVM Metrics Thread,Memory,ByteBuff,GC,Class,Compilation,FileDescriptor

快速启动
MyPerf4J 采用 JavaAgent 配置方式,透明化接入应用,对应用代码完全没有侵入。
下载
- 下载并解压 MyPerf4J-ASM.zip
- 阅读解压出的
README文件 - 修改解压出的
MyPerf4J.properties配置文件中app_name、metrics.log.xxx和filter.packages.include的配置值
配置
在 JVM 启动参数里加上以下两个参数
- -javaagent:/path/to/MyPerf4J-ASM.jar
- -DMyPerf4JPropFile=/path/to/MyPerf4J.properties
形如:java -javaagent:/path/to/MyPerf4J-ASM.jar -DMyPerf4JPropFile=/path/to/MyPerf4J.properties
-jar yourApp.jar注意:如果您使用 JDK9 及其之上的版本,请额外添加
--add-opens java.base/java.lang=ALL-UNNAMED
运行
启动应用,监控日志输出到 /path/to/log/method_metrics.log:
MyPerf4J Method Metrics [2020-01-01 12:49:57, 2020-01-01 12:49:58]
Method[6] Type Level TimePercent RPS Avg(ms) Min(ms) Max(ms) StdDev Count TP50 TP90 TP95 TP99 TP999 TP9999
DemoServiceImpl.getId2(long) General Service 322.50% 6524 0.49 0 1 0.50 6524 0 1 1 1 1 1
DemoServiceImpl.getId3(long) General Service 296.10% 4350 0.68 0 1 0.47 4350 1 1 1 1 1 1
DemoServiceImpl.getId4(long) General Service 164.60% 2176 0.76 0 1 0.43 2176 1 1 1 1 1 1
DemoServiceImpl.getId1(long) General Service 0.00% 8704 0.00 0 0 0.00 8704 0 0 0 0 0 0
DemoDAO.getId1(long) DynamicProxy DAO 0.00% 2176 0.00 0 0 0.00 2176 0 0 0 0 0 0
DemoDAO.getId2() DynamicProxy DAO 0.00% 2176 0.00 0 0 0.00 2176 0 0 0 0 0 0
卸载
在 JVM 启动参数中去掉以下两个参数,重启即可卸载此工具。
- -javaagent:/path/to/MyPerf4J-ASM.jar
- -DMyPerf4JPropFile=/path/to/MyPerf4J.properties
构建
您可以自行构建 MyPerf4J-ASM.jar
- git clone [email protected]:LinShunKang/MyPerf4J.git
- mvn clean package
MyPerf4J-ASM-${MyPerf4J-version}.jar 在 MyPerf4J-ASM/target/ 目录下
问题
如果您有任何问题、疑问或者建议,您可以 提交Issue 或者 发送邮件 :)
注意,为了保障大家的时间,请保证您已经完整阅读过以下内容:
已知用户
如果您在使用 MyPerf4J,请告诉我,您的使用对我来说非常重要:https://github.com/LinShunKang/MyPerf4J/issues/30(按登记顺序排列)
鸣谢
感谢 JetBrains OpenSourceSupport 所提供的支持 : )
项目捐赠
如果 MyPerf4J 对您有帮助,可以使用微信扫描下面的赞赏码,请我喝杯咖啡 : )
参考项目
MyPerf4J 是受以下项目启发而来:
更多信息
想更深入的了解 MyPerf4J?请看 https://github.com/LinShunKang/MyPerf4J/wiki/Chinese-Doc。