Skip to content

Commit

Permalink
1
Browse files Browse the repository at this point in the history
  • Loading branch information
xinyiZzz committed Nov 3, 2023
1 parent 61edb9e commit 1fb740c
Show file tree
Hide file tree
Showing 2 changed files with 77 additions and 0 deletions.
39 changes: 39 additions & 0 deletions docs/en/community/developer-guide/debug-tool.md
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,10 @@ The directory where the heap dump file is located is `${DORIS_HOME}/log` by defa

##### 3. jemalloc heap dump profiling

```
Requires addr2line 2.35.2, see below QA 1.
```

1. A single heap dump file generates plain text analysis results
```shell
jeprof lib/doris_be heap_dump_file_1
Expand Down Expand Up @@ -282,6 +286,41 @@ The directory where the heap dump file is located is `${DORIS_HOME}/log` by defa
jeprof --pdf lib/doris_be --base=heap_dump_file_1 heap_dump_file_2 > result.pdf
```

##### 4. QA

1. Many errors occurred after running jeprof: `addr2line: Dwarf Error: found dwarf version xxx, this reader only handles version xxx`

After GCC 11, DWARF-v5 is used by default, which requires Binutils 2.35.2 and above. Doris Ldb_toolchain uses GCC 11. See: https://gcc.gnu.org/gcc-11/changes.html.

Replace addr2line to 2.35.2, refer to:
```
// Download addr2line source code
wget https://ftp.gnu.org/gnu/binutils/binutils-2.35.tar.bz2

//Install dependencies, if needed
yum install make gcc gcc-c++ binutils

// Compile & install addr2line
tar -xvf binutils-2.35.tar.bz2
cd binutils-2.35
./configure --prefix=/usr/local
make
make install

// verify
addr2line -h

// Replace addr2line
chmod +x addr2line
mv /usr/bin/addr2line /usr/bin/addr2line.bak
mv /bin/addr2line /bin/addr2line.bak
cp addr2line /bin/addr2line
cp addr2line /usr/bin/addr2line
hash -r
```
Note that you cannot use addr2line 2.3.9, which may be incompatible and cause memory to keep growing.
#### LSAN
[LSAN](https://github.com/google/sanitizers/wiki/AddressSanitizerLeakSanitizer) is an address checking tool, GCC has been integrated. When we compile the code, we can enable this function by turning on the corresponding compilation options. When the program has a determinable memory leak, it prints the leak stack. Doris be has integrated this tool, only need to compile with the following command to generate be binary with memory leak detection version.
Expand Down
38 changes: 38 additions & 0 deletions docs/zh-CN/community/developer-guide/debug-tool.md
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,10 @@ heap dump文件所在目录默认为 `${DORIS_HOME}/log`, 文件名前缀是 `JE

##### 3. heap dump profiling

```
需要 addr2line 版本为 2.35.2, 见下面的 QA 1.
```

1. 单个heap dump文件生成纯文本分析结果
```shell
jeprof lib/doris_be heap_dump_file_1
Expand Down Expand Up @@ -285,6 +289,40 @@ heap dump文件所在目录默认为 `${DORIS_HOME}/log`, 文件名前缀是 `JE
jeprof --pdf lib/doris_be --base=heap_dump_file_1 heap_dump_file_2 > result.pdf
```

##### 4. QA

1. 运行 jeprof 后出现很多错误: `addr2line: Dwarf Error: found dwarf version xxx, this reader only handles version xxx`.

GCC 11 之后默认使用 DWARF-v5 ,这要求Binutils 2.35.2 及以上,Doris Ldb_toolchain 用了 GCC 11。see: https://gcc.gnu.org/gcc-11/changes.html。

替换 addr2line 到 2.35.2,参考:
```
// 下载 addr2line 源码
wget https://ftp.gnu.org/gnu/binutils/binutils-2.35.tar.bz2
// 安装依赖项,如果需要
yum install make gcc gcc-c++ binutils
// 编译&安装 addr2line
tar -xvf binutils-2.35.tar.bz2
cd binutils-2.35
./configure --prefix=/usr/local
make
make install
// 验证
addr2line -h
// 替换 addr2line
chmod +x addr2line
mv /usr/bin/addr2line /usr/bin/addr2line.bak
mv /bin/addr2line /bin/addr2line.bak
cp addr2line /bin/addr2line
cp addr2line /usr/bin/addr2line
hash -r
```
注意,不能使用 addr2line 2.3.9, 这可能不兼容,导致内存一直增长。

#### LSAN

[LSAN](https://github.com/google/sanitizers/wiki/AddressSanitizerLeakSanitizer)是一个地址检查工具,GCC已经集成。在我们编译代码的时候开启相应的编译选项,就能够开启这个功能。当程序发生可以确定的内存泄露时,会将泄露堆栈打印。Doris BE已经集成了这个工具,只需要在编译的时候使用如下的命令进行编译就能够生成带有内存泄露检测版本的BE二进制
Expand Down

0 comments on commit 1fb740c

Please sign in to comment.