Skip to content

Commit 2b6d331

Browse files
authored
Upgrade async profiler to 3.0 (#2903)
1 parent ca2d062 commit 2b6d331

File tree

8 files changed

+8
-95
lines changed

8 files changed

+8
-95
lines changed

.github/workflows/build-async-profiler.yml

Lines changed: 5 additions & 88 deletions
Original file line numberDiff line numberDiff line change
@@ -25,26 +25,26 @@ jobs:
2525
with:
2626
distribution: "liberica"
2727
java-version: "11"
28-
# 从 async-profiler 源码编译出 libasyncProfiler-mac.so(兼容 arthas-core 中 ProfilerCommand.java 固定的 so 文件名称未使用 libasyncProfiler.dylib)
28+
# 从 async-profiler 源码编译出 libasyncProfiler-mac.dylib(兼容 arthas-core 中 ProfilerCommand.java 固定的 so 文件名称未使用 libasyncProfiler.dylib)
2929
# grep -m1 PROFILER_VERSION Makefile 用于输出 async-profiler 版本, 下同
3030
- name: Execute compile inside macOS 12 environment
3131
run: |
3232
grep -m1 PROFILER_VERSION Makefile
3333
echo "JAVA_HOME=${JAVA_HOME}"
3434
java -version
35-
echo "FAT_BINARY variable that make libasyncProfiler-mac.so works both on macOS x86-64 and arm64"
35+
echo "FAT_BINARY variable that make libasyncProfiler-mac.dylib works both on macOS x86-64 and arm64"
3636
make FAT_BINARY=true
3737
LIB_PROFILER_PATH=$(find build -type f \( -name libasyncProfiler.so -o -name libasyncProfiler.dylib \) 2>/dev/null)
3838
[ -z "${LIB_PROFILER_PATH}" ] && echo "Can not find libasyncProfiler.so or libasyncProfiler.dylib file under build directory." && exit 1
3939
echo "LIB_PROFILER_PATH=${LIB_PROFILER_PATH}"
4040
file ${LIB_PROFILER_PATH}
4141
otool -L ${LIB_PROFILER_PATH}
42-
cp ${LIB_PROFILER_PATH} libasyncProfiler-mac.so
43-
# 暂存编译出来的 libasyncProfiler-mac.so 文件
42+
cp ${LIB_PROFILER_PATH} libasyncProfiler-mac.dylib
43+
# 暂存编译出来的 libasyncProfiler-mac.dylib 文件
4444
- uses: actions/upload-artifact@v3
4545
with:
4646
name: async-profiler
47-
path: libasyncProfiler-mac.so
47+
path: libasyncProfiler-mac.dylib
4848
if-no-files-found: error
4949

5050
build-generic-linux-x64:
@@ -143,89 +143,6 @@ jobs:
143143
if-no-files-found: error
144144

145145

146-
build-alpine-linux-x64:
147-
runs-on: ubuntu-20.04
148-
if: ${{ inputs.async-profiler-tag-name }}
149-
steps:
150-
# 检出 async-profiler/async-profiler 项目指定的 tag
151-
- uses: actions/checkout@v3
152-
with:
153-
repository: async-profiler/async-profiler
154-
fetch-depth: 0
155-
- name: Checkout the async-profiler repository by input tag name ${{ inputs.async-profiler-tag-name }}
156-
run: git checkout ${{ inputs.async-profiler-tag-name }}
157-
- name: Setup Alpine Linux x86-64 environment
158-
uses: jirutka/setup-alpine@v1
159-
with:
160-
arch: x86_64
161-
branch: v3.15
162-
shell-name: alpine-x86_64.sh
163-
packages: >
164-
build-base linux-headers openjdk11
165-
# 从 async-profiler 源码编译出适用于 musl-based Linux 主机的 libasyncProfiler-linux-musl-x64.so
166-
# grep -m1 PROFILER_VERSION Makefile 用于输出 async-profiler 版本, 下同
167-
- name: Run script inside Alpine Linux x86-64 environment
168-
run: |
169-
grep -m1 PROFILER_VERSION Makefile
170-
JAVA_HOME=/usr/lib/jvm/java-11-openjdk
171-
java -version
172-
which java
173-
echo "Append -static-libgcc -static-libstdc++ options to CXXFLAGS for user no need to install libstdc++ and libgcc manually."
174-
sed -i 's/CXXFLAGS=/CXXFLAGS=-static-libgcc -static-libstdc++ /' Makefile && make
175-
LIB_PROFILER_PATH=$(find build -type f -name libasyncProfiler.so 2>/dev/null)
176-
[ -z "${LIB_PROFILER_PATH}" ] && echo "Can not find libasyncProfiler.so file under build directory." && exit 1
177-
echo "LIB_PROFILER_PATH=${LIB_PROFILER_PATH}"
178-
file ${LIB_PROFILER_PATH}
179-
ldd ${LIB_PROFILER_PATH}
180-
cp ${LIB_PROFILER_PATH} libasyncProfiler-linux-musl-x64.so
181-
shell: alpine-x86_64.sh {0}
182-
- uses: actions/upload-artifact@v3
183-
with:
184-
name: async-profiler
185-
path: libasyncProfiler-linux-musl-x64.so
186-
if-no-files-found: error
187-
188-
build-alpine-linux-arm64:
189-
runs-on: ubuntu-20.04
190-
if: ${{ inputs.async-profiler-tag-name }}
191-
steps:
192-
# 检出 async-profiler/async-profiler 项目指定的 tag
193-
- uses: actions/checkout@v3
194-
with:
195-
repository: async-profiler/async-profiler
196-
fetch-depth: 0
197-
- name: Checkout the async-profiler repository by input tag name ${{ inputs.async-profiler-tag-name }}
198-
run: git checkout ${{ inputs.async-profiler-tag-name }}
199-
- name: Setup Alpine Linux aarch64 environment
200-
uses: jirutka/setup-alpine@v1
201-
with:
202-
arch: aarch64
203-
branch: v3.15
204-
shell-name: alpine-aarch64.sh
205-
packages: >
206-
build-base linux-headers openjdk11
207-
# 从 async-profiler 源码编译出适用于 musl-based Linux 主机的 libasyncProfiler-linux-musl-arm64.so
208-
# grep -m1 PROFILER_VERSION Makefile 用于输出 async-profiler 版本, 下同
209-
- name: Run script inside Alpine Linux aarch64 environment
210-
run: |
211-
grep -m1 PROFILER_VERSION Makefile
212-
JAVA_HOME=/usr/lib/jvm/java-11-openjdk
213-
java -version
214-
which java
215-
echo "Append -static-libgcc -static-libstdc++ options to CXXFLAGS for user no need to install libstdc++ and libgcc manually."
216-
sed -i 's/CXXFLAGS=/CXXFLAGS=-static-libgcc -static-libstdc++ /' Makefile && make
217-
LIB_PROFILER_PATH=$(find build -type f -name libasyncProfiler.so 2>/dev/null)
218-
[ -z "${LIB_PROFILER_PATH}" ] && echo "Can not find libasyncProfiler.so file under build directory." && exit 1
219-
echo "LIB_PROFILER_PATH=${LIB_PROFILER_PATH}"
220-
file ${LIB_PROFILER_PATH}
221-
ldd ${LIB_PROFILER_PATH}
222-
cp ${LIB_PROFILER_PATH} libasyncProfiler-linux-musl-arm64.so
223-
shell: alpine-aarch64.sh {0}
224-
- uses: actions/upload-artifact@v3
225-
with:
226-
name: async-profiler
227-
path: libasyncProfiler-linux-musl-arm64.so
228-
if-no-files-found: error
229146

230147
upload-libasyncProfiler-files:
231148
runs-on: ubuntu-20.04

async-profiler/libasyncProfiler-linux-arm64.so

100755100644
21.8 KB
Binary file not shown.
-7.69 MB
Binary file not shown.
-7.47 MB
Binary file not shown.

async-profiler/libasyncProfiler-linux-x64.so

100755100644
29.8 KB
Binary file not shown.
725 KB
Binary file not shown.
-660 KB
Binary file not shown.

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

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -236,16 +236,12 @@ public class ProfilerCommand extends AnnotatedCommand {
236236
String profilerSoPath = null;
237237
if (OSUtils.isMac()) {
238238
// FAT_BINARY support both x86_64/arm64
239-
profilerSoPath = "async-profiler/libasyncProfiler-mac.so";
239+
profilerSoPath = "async-profiler/libasyncProfiler-mac.dylib";
240240
}
241241
if (OSUtils.isLinux()) {
242-
if (OSUtils.isX86_64() && OSUtils.isMuslLibc()) {
243-
profilerSoPath = "async-profiler/libasyncProfiler-linux-musl-x64.so";
244-
} else if(OSUtils.isX86_64()){
242+
if (OSUtils.isX86_64()) {
245243
profilerSoPath = "async-profiler/libasyncProfiler-linux-x64.so";
246-
} else if (OSUtils.isArm64() && OSUtils.isMuslLibc()) {
247-
profilerSoPath = "async-profiler/libasyncProfiler-linux-musl-arm64.so";
248-
} else if (OSUtils.isArm64()) {
244+
} else if (OSUtils.isArm64()) {
249245
profilerSoPath = "async-profiler/libasyncProfiler-linux-arm64.so";
250246
}
251247
}

0 commit comments

Comments
 (0)