|
| 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 |
0 commit comments