diff --git a/core/src/main/java/com/taobao/arthas/core/command/monitor200/ProfilerCommand.java b/core/src/main/java/com/taobao/arthas/core/command/monitor200/ProfilerCommand.java index 0ca0f4e75d..69c9b4737b 100644 --- a/core/src/main/java/com/taobao/arthas/core/command/monitor200/ProfilerCommand.java +++ b/core/src/main/java/com/taobao/arthas/core/command/monitor200/ProfilerCommand.java @@ -117,6 +117,11 @@ public class ProfilerCommand extends AnnotatedCommand { */ private Integer jstackdepth; + /** + * wall clock profiling interval + */ + private Long wall; + /** * profile different threads separately */ @@ -335,6 +340,13 @@ public void setJfrsync(String jfrsync) { this.jfrsync = jfrsync; } + @Option(longName = "wall", flag = true) + @Description("wall clock profiling interval") + @DefaultValue("10000000") + public void setWall(Long wall) { + this.wall = wall; + } + @Option(shortName = "t", longName = "threads", flag = true) @Description("profile different threads separately") public void setThreads(boolean threads) { @@ -619,7 +631,9 @@ private String executeArgs(ProfilerAction action) { if (this.end != null) { sb.append("end=").append(this.end).append(COMMA); } - + if (this.wall != null) { + sb.append("wall=").append(this.wall).append(COMMA); + } if (this.title != null) { sb.append("title=").append(this.title).append(COMMA); } diff --git a/site/docs/doc/profiler.md b/site/docs/doc/profiler.md index 0e0f2d2298..f6e76efac3 100644 --- a/site/docs/doc/profiler.md +++ b/site/docs/doc/profiler.md @@ -350,3 +350,22 @@ profiler start --loop 1h -f /var/log/profile-%t.jfr ## `--timeout` 选项 这个选项指定 profiling 自动在多久后停止。该选项和 `--loop` 选项的格式一致,可以是时间点,也可以是一个时间间隔。这两个选项都是用于 `start` action 而不是 `collect` action 的。可参考 [async-profiler Github Discussions](https://github.com/async-profiler/async-profiler/discussions/789) 了解更多信息。 + +## `--wall` 选项 + +通过 --wall 选项,可以同时进行 CPU 和 Wall Clock 的性能分析。 + +1. 这种联合分析有助于更全面地识别和理解应用程序的性能瓶颈。 +2. 允许用户独立于 CPU 分析设置 Wall Clock 分析的采样间隔。比如,可以通过设置 -e cpu -i 10 --wall 200,将 CPU 采样间隔设为 10 毫秒,墙钟采样间隔设为 200 毫秒。 +3. 联合进行 CPU 和 Wall Clock 分析时,输出格式必须设置为 jfr。这一格式支持记录线程的状态信息(如 STATE_RUNNABLE 或 STATE_SLEEPING),从而区分不同类型的采样事件。 + +可参考 [async-profiler Github pr#740](https://github.com/async-profiler/async-profiler/issues/740) 了解更多信息。 + +影响: + +Linux 平台: 这个新功能仅在 Linux 平台上有效。macOS 上的 CPU 分析引擎已经基于 Wall clock 模式,因此没有额外的收益。 +性能开销: 启用 Wall clock 分析会增加性能开销,因此在同时分析 CPU 和 Wall clock 时,建议增加 Wall clock 的间隔。 + +```bash +profiler start -e cpu -i 10 --wall 100 -f out.jfr +``` diff --git a/site/docs/en/doc/profiler.md b/site/docs/en/doc/profiler.md index fa7318a276..69f225e2b5 100644 --- a/site/docs/en/doc/profiler.md +++ b/site/docs/en/doc/profiler.md @@ -352,3 +352,17 @@ profiler start --loop 1h -f /var/log/profile-%t.jfr This option specifies the time when profiling will automatically stop. The format is the same as in loop: it is either a wall clock time (12:34:56) or a relative time interval (2h). Both `--loop` and `--timeout` are used for `start` action but not for `collect` action, for further information refer to [async-profiler Github Discussions](https://github.com/async-profiler/async-profiler/discussions/789). + +## `--wall` option + +The -- wall option allows for simultaneous performance analysis of both CPU and Wall Clock. This joint analysis helps to more comprehensively identify and understand performance bottlenecks in applications. +--The wall option allows users to set the sampling interval for Wall Clock analysis independently of CPU analysis. For example, by setting - e cpu-i 10-- wall 200, the CPU sampling interval can be set to 10 milliseconds, and the wall clock sampling interval can be set to 200 milliseconds. +When conducting joint CPU and Wall Clock analysis, the output format must be set to jfr. This format supports recording the state information of threads (such as State_SUNNABLE or State_SLEEPING) to distinguish between different types of sampling events. + +influence +Linux platform: This new feature is only available on the Linux platform. The CPU analysis engine on macOS is already based on Wall clock mode, so there are no additional benefits. +Performance overhead: Enabling Wall clock analysis will increase performance overhead, so when analyzing both CPU and Wall clock simultaneously, it is recommended to increase the interval between Wall clocks. + +```bash +profiler start -e cpu -i 10 --wall 100 -f out.jfr +```