Skip to content

Commit fcdd44d

Browse files
committed
Dropping os page caches between iterations
1 parent 39bef27 commit fcdd44d

File tree

3 files changed

+104
-2
lines changed

3 files changed

+104
-2
lines changed
Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
name: async-profiler #https://github.com/apangin/async-profiler.git
2+
scripts:
3+
4+
async-profiler-configure:
5+
- sh: sudo sh -c "echo 1 > /proc/sys/kernel/perf_event_paranoid"
6+
- sh: sudo sh -c "echo 0 > /proc/sys/kernel/kptr_restrict"
7+
8+
# downloads the latest async-profiler release to ${{baseDir:/tmp}}/${{targetDir:async-profiler}} and
9+
async-profiler-install:
10+
- sh: cd ${{baseDir:/tmp}}
11+
- sh: if test -d ${{targetDir:async-profiler}} ; then rm -rf ${{targetDir:async-profiler}}; fi
12+
- sh: mkdir -p ${{targetDir:async-profiler}}
13+
- sh: cd ${{targetDir:async-profiler}}
14+
# moved to https://api.github.com/repositories/56894212/releases/latest but using --location to preserve name
15+
- sh: curl --location -o async-profiler.tar.gz $(curl --silent --location https://api.github.com/repos/jvm-profiling-tools/async-profiler/releases/latest | jq -r '.assets[] | select(.name | contains ("linux-x64.tar.gz")) | .browser_download_url') 2>/dev/null
16+
# curl 8.6.0 no longer says 'Saved to filename' also I'm getting invalid gzip
17+
- sh: tar xvf async-profiler.tar.gz
18+
then:
19+
- regex: (?<subDir>^[^/]+)/
20+
then:
21+
- sh: mv ${{subDir}}/* ./
22+
23+
#waits for ${{WAIT_START}} then ${{DELAY}}, creates a profile using the configured parameters then downloads it immediately
24+
#works with 3.x, not 2.x
25+
async-profiler-run:
26+
- sh: cd ${{asyncHome:${{baseDir:/tmp}}/${{targetDir:async-profiler}}}}
27+
- wait-for: ${{wait_start:}} # don't wait by default
28+
- sleep: ${{delay:0}}
29+
- sh: >
30+
bin/asprof
31+
-d ${{duration__10}}
32+
-f /tmp/flamegraph.${{suffix__html}}
33+
-o ${{format__flamegraph}}
34+
-e ${{events__cpu}}
35+
${{="${{enableTotal __ }}".toLowerCase() == "true" ? "--total" : ""}}
36+
--title ${{title__async-profiler}}
37+
${{pid}}
38+
separator: __
39+
- download: /tmp/flamegraph.${{suffix:html}}
40+
41+
42+
async-profiler-build:
43+
- script: async-profiler-configure
44+
- sh: mkdir -p /tmp/async-profiler && cd /tmp/async-profiler
45+
- upload: ${{ENV.SCRIPT_DIR}}/assets/async-profiler.Dockerfile /tmp/async-profiler/Dockerfile
46+
- sh: "podman build -t async-profiler:${{GIT_BRANCH:master}} --build-arg branch=${{GIT_BRANCH:master}} ."
47+
- sh: podman run --rm -v /tmp/async-profiler:/mnt/async-profiler:rw,Z async-profiler:${{GIT_BRANCH:master}} cp /tmp/async-profiler/profiler.sh /mnt/async-profiler/
48+
- sh: podman run --rm -v /tmp/async-profiler:/mnt/async-profiler:rw,Z async-profiler:${{GIT_BRANCH:master}} cp -R /tmp/async-profiler/build /mnt/async-profiler/
49+
- sh: podman run --rm -v /tmp/async-profiler:/mnt/async-profiler:rw,Z async-profiler:${{GIT_BRANCH:master}} cp -r /tmp/async-profiler/* /mnt/async-profiler/
50+
- log: Async Profiler Version
51+
- read-state: ${{GIT_BRANCH:master}}
52+
- regex: v2.7
53+
then:
54+
- sh: /tmp/async-profiler/profiler.sh -v
55+
else:
56+
- sh: /tmp/async-profiler/build/bin/asprof -v
57+
58+
async-profiler: # ROOT_PASSWORD GIT_REPO WAIT_START PID TITLE ASYNC_PROFILE_DURATION BUILD_NUMBER ASYNC_PROFILE_EVENTS GIT_BRANCH FORMAT ENABLE_ASYNC_PROFILER_TOTAL_PARAM
59+
- script: async-profiler-impl
60+
with:
61+
FORMAT: flamegraph
62+
63+
async-profiler-impl: # ROOT_PASSWORD GIT_REPO WAIT_START PID TITLE ASYNC_PROFILE_DURATION BUILD_NUMBER ASYNC_PROFILE_EVENTS GIT_BRANCH FORMAT ENABLE_ASYNC_PROFILER_TOTAL_PARAM DELAY GIT_BRANCH
64+
# Commented out: we don't want to necessarily pollute system with Java from DNF
65+
# If you need to build anything please use containerized build
66+
# - sh: sudo dnf groupinstall -q -y 'Development Tools'
67+
- wait-for: ${{WAIT_START:}} # dont wait
68+
- sleep: ${{DELAY:0}}
69+
- read-state: ${{ENABLE_ASYNC_PROFILER_TOTAL_PARAM}}
70+
then:
71+
- regex: true
72+
then:
73+
- sh: echo ' --total '
74+
- set-state: TOTAL_PARAM
75+
- sh: cd /tmp/async-profiler
76+
- read-state: ${{GIT_BRANCH:master}}
77+
- regex: v2.7
78+
then:
79+
- sh: ./profiler.sh -d ${{ASYNC_PROFILE_DURATION:10}} -f /tmp/flamegraph.${{BUILD_NUMBER:00000}} -o ${{FORMAT:flamegraph}} -e ${{ASYNC_PROFILE_EVENTS:cpu}} ${{TOTAL_PARAM:}} --title ${{TITLE:async-profiler}} ${{PID:jps}}
80+
else:
81+
- sh: ./build/bin/asprof -d ${{ASYNC_PROFILE_DURATION:10}} -f /tmp/flamegraph.${{BUILD_NUMBER:00000}} -o ${{FORMAT:flamegraph}} -e ${{ASYNC_PROFILE_EVENTS:cpu}} ${{TOTAL_PARAM:}} --title ${{TITLE:async-profiler}} ${{PID:jps}}
82+
- read-state: ${{FORMAT:flamegraph}}
83+
then: # cater for the lowest common denominators, add more if needed (flat,traces,collapsed,tree)
84+
- regex: flamegraph
85+
then:
86+
- sh: mv /tmp/flamegraph.${{BUILD_NUMBER:00000}} /tmp/${{ASYNC_PROFILE_EVENTS:cpu}}.flamegraph.${{BUILD_NUMBER:00000}}.html
87+
- queue-download: /tmp/${{ASYNC_PROFILE_EVENTS:cpu}}.flamegraph.${{BUILD_NUMBER:00000}}.html
88+
- regex: jfr
89+
then:
90+
- sh: mv /tmp/flamegraph.${{BUILD_NUMBER:00000}} /tmp/javaflightrecorder.${{BUILD_NUMBER:00000}}.jfr
91+
- queue-download: /tmp/javaflightrecorder.${{BUILD_NUMBER:00000}}.jfr

benchmarks/helpers/os.yml

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,4 +44,13 @@ scripts:
4444
- abort: "Unable to install package: ${{package}}"
4545

4646
install-package:
47-
- script: install-package-${{os}}
47+
- script: install-package-${{os}}
48+
49+
sync-drop-fs-cache-linux:
50+
- sh: sync && sudo sh -c "echo 3 > /proc/sys/vm/drop_caches"
51+
52+
sync-drop-fs-cache-macos:
53+
- sh: sync && sudo purge
54+
55+
sync-drop-fs-cache:
56+
- script: sync-drop-fs-cache-${{os}}

benchmarks/main.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,7 @@ scripts:
177177
- set-state: TYPE ${{RUNTIME.type}}
178178
- for-each: ITERATION ${{=[...Array(${{ITERATIONS}}).keys()]}}
179179
then:
180+
- script: sync-drop-fs-cache
180181
- sh: /usr/bin/time -p ${{RUNTIME.buildCmd}} 2>&1 >${{REPO_DIR}}/logs/build-times-${{RUNTIME.name}}-${{ITERATION}}.log | grep real | awk '{ print $2}'
181182
- set-state: BUILD_TIME
182183
- script: state-array-push
@@ -245,7 +246,7 @@ scripts:
245246
- sh: ${{RUNTIME.buildCmd}}
246247
- for-each: ITERATION ${{=[...Array(${{ITERATIONS}}).keys()]}}
247248
then:
248-
- log: ${{= \"${{RUNTIME.runCmd}}\".trim().replace(/ +/g, ' ') }}\" ${{TARGET_URL}} | awk '{print $1}'
249+
- script: sync-drop-fs-cache
249250
- sh: node ${{SCRIPTS_DIR}}/time.js "${{= "${{RUNTIME.runCmd}}".trim().replace(/ +/g, ' ') }}" ${{TARGET_URL}} | awk '{print $1}'
250251
then:
251252
- set-state: START_TIME
@@ -266,6 +267,7 @@ scripts:
266267
- sh: ${{RUNTIME.buildCmd}}
267268
- for-each: ITERATION ${{=[...Array(${{ITERATIONS}}).keys()]}}
268269
then:
270+
- script: sync-drop-fs-cache
269271
- sh: ${{RUNTIME.runCmd}} 2>&1 >${{REPO_DIR}}/logs/measure-rss-${{RUNTIME.name}}-${{ITERATION}}.log &
270272
- sh: APP_PID=$!
271273
- log: $APP_PID

0 commit comments

Comments
 (0)