Skip to content

Commit 59b87ca

Browse files
authored
profiler command support --wall option(#2905)
1 parent 925cf17 commit 59b87ca

File tree

3 files changed

+48
-1
lines changed

3 files changed

+48
-1
lines changed

core/src/main/java/com/taobao/arthas/core/command/monitor200/ProfilerCommand.java

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,11 @@ public class ProfilerCommand extends AnnotatedCommand {
117117
*/
118118
private Integer jstackdepth;
119119

120+
/**
121+
* wall clock profiling interval
122+
*/
123+
private Long wall;
124+
120125
/**
121126
* profile different threads separately
122127
*/
@@ -335,6 +340,13 @@ public void setJfrsync(String jfrsync) {
335340
this.jfrsync = jfrsync;
336341
}
337342

343+
@Option(longName = "wall", flag = true)
344+
@Description("wall clock profiling interval")
345+
@DefaultValue("10000000")
346+
public void setWall(Long wall) {
347+
this.wall = wall;
348+
}
349+
338350
@Option(shortName = "t", longName = "threads", flag = true)
339351
@Description("profile different threads separately")
340352
public void setThreads(boolean threads) {
@@ -619,7 +631,9 @@ private String executeArgs(ProfilerAction action) {
619631
if (this.end != null) {
620632
sb.append("end=").append(this.end).append(COMMA);
621633
}
622-
634+
if (this.wall != null) {
635+
sb.append("wall=").append(this.wall).append(COMMA);
636+
}
623637
if (this.title != null) {
624638
sb.append("title=").append(this.title).append(COMMA);
625639
}

site/docs/doc/profiler.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -350,3 +350,22 @@ profiler start --loop 1h -f /var/log/profile-%t.jfr
350350
## `--timeout` 选项
351351

352352
这个选项指定 profiling 自动在多久后停止。该选项和 `--loop` 选项的格式一致,可以是时间点,也可以是一个时间间隔。这两个选项都是用于 `start` action 而不是 `collect` action 的。可参考 [async-profiler Github Discussions](https://github.com/async-profiler/async-profiler/discussions/789) 了解更多信息。
353+
354+
## `--wall` 选项
355+
356+
通过 --wall 选项,可以同时进行 CPU 和 Wall Clock 的性能分析。
357+
358+
1. 这种联合分析有助于更全面地识别和理解应用程序的性能瓶颈。
359+
2. 允许用户独立于 CPU 分析设置 Wall Clock 分析的采样间隔。比如,可以通过设置 -e cpu -i 10 --wall 200,将 CPU 采样间隔设为 10 毫秒,墙钟采样间隔设为 200 毫秒。
360+
3. 联合进行 CPU 和 Wall Clock 分析时,输出格式必须设置为 jfr。这一格式支持记录线程的状态信息(如 STATE_RUNNABLE 或 STATE_SLEEPING),从而区分不同类型的采样事件。
361+
362+
可参考 [async-profiler Github pr#740](https://github.com/async-profiler/async-profiler/issues/740) 了解更多信息。
363+
364+
影响:
365+
366+
Linux 平台: 这个新功能仅在 Linux 平台上有效。macOS 上的 CPU 分析引擎已经基于 Wall clock 模式,因此没有额外的收益。
367+
性能开销: 启用 Wall clock 分析会增加性能开销,因此在同时分析 CPU 和 Wall clock 时,建议增加 Wall clock 的间隔。
368+
369+
```bash
370+
profiler start -e cpu -i 10 --wall 100 -f out.jfr
371+
```

site/docs/en/doc/profiler.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -352,3 +352,17 @@ profiler start --loop 1h -f /var/log/profile-%t.jfr
352352
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).
353353

354354
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).
355+
356+
## `--wall` option
357+
358+
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.
359+
--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.
360+
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.
361+
362+
influence
363+
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.
364+
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.
365+
366+
```bash
367+
profiler start -e cpu -i 10 --wall 100 -f out.jfr
368+
```

0 commit comments

Comments
 (0)