alibaba / alibaba/arthas

火焰图的--include和--exclude选项不生效

Open
#2,003 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
37.5k
Forks
7.6k
Avg merge
1d 22h
Merged PRs (30d)
4

Description

- [ ] 我已经在 [issues](https://github.com/alibaba/arthas/issues) 里搜索,没有重复的issue。

### 环境信息

* `arthas-boot.jar` 或者 `as.sh` 的版本:3.5.4
* Arthas 版本: 3.5.4
* 操作系统版本:
Linux version 4.20.13-1.el7.elrepo.x86_64 (mockbuild@Build64R7) (gcc version 4.8.5 20150623 (Red Hat 4.8.5-36) (GCC)) #1 SMP Wed Feb 27 10:02:05 EST 2019
* 目标进程的JVM版本:
[18:13:26][root@192:1.0]# java -version
java version "1.8.0_261"
Java(TM) SE Runtime Environment (build 1.8.0_261-b12)
Java HotSpot(TM) 64-Bit Server VM (build 25.261-b12, mixed mode)
* 执行`arthas-boot`的版本: 3.5.4

### 重现问题的步骤

1. 启动测试代码,如下所示:
```
import java.util.Arrays;
import java.util.List;

public class LoadExecutor {

public static List list = Arrays.asList("1", "2", "3", "4", "5", "6");

public static void main(String[] args) throws Exception {
while (true) {
costlyMethodA();
Thread.sleep(0, 100);
nonCostlyMethodA();
}
}

public static void costlyMethodA() {
costlyMethodB();
costlyMethodC();
}

public static void nonCostlyMethodA() {
nonCostlyMethodB();
nonCostlyMethodC();
}

public static void costlyMethodB() {
costlyMethodD();
}

public static void nonCostlyMethodB() {
nonCostlyMethodD();
}

public static void costlyMethodC() {
costlyMethodD();
}

public static void nonCostlyMethodC() {
nonCostlyMethodD();
}

public static void nonCostlyMethodD() {
for (int i = 0; i < 10; i++) {
// nothing.
}
}

public static void costlyMethodD() {
costTimeForAWhile(2);
}

public static void costTimeForAWhile(long timeInMs) {
long startTime = System.currentTimeMillis();
while (true) {
long elapsedTime = System.currentTimeMillis() - startTime;
if (elapsedTime > timeInMs) {
break;
}
list.subList(0, 2);
}
}
}
```
2. 使用`java -jar arthas-boot.jar`启动arthas,并选中第一步中启动的Java进程
3. 执行profiler命令如下:
```
[arthas@14254]$ profiler start --framebuf 5000000 i:1000000 --include '*MethodB*'
```
并执行一段时间后,执行`profiler stop`命令,生成svg文件。
4. 查看svg文件发现,不匹配`*MethodB*`的方法执行也被采样了。svg截图如下所示:
![image](https://user-images.githubusercontent.com/20662392/137114940-e7051c70-7c74-4032-aeef-40157654a2f6.png)

### 期望的结果
不匹配`*MethodB*`的方法不会被采样

### 实际运行的结果
不匹配`*MethodB*`的方法执行也被采样了

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the issue with the provided LoadExecutor program and the `profiler start --include '*MethodB*'` command, then inspect the profiler command and sampling/filtering entry points. Compare the generated SVG with the include pattern and verify that methods not matching `*MethodB*` are excluded; the profiler stop output should reflect only matching samples.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
devtools, observability
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.