|
| 1 | +name: async-profiler #https://github.com/apangin/async-profiler.git |
| 2 | +scripts: |
| 3 | + async-profiler-configure: |
| 4 | + - read-state: ${{os}} |
| 5 | + then: |
| 6 | + - regex: linux |
| 7 | + then: |
| 8 | + - sh: sudo sh -c "echo 1 > /proc/sys/kernel/perf_event_paranoid" |
| 9 | + - sh: sudo sh -c "echo 0 > /proc/sys/kernel/kptr_restrict" |
| 10 | + |
| 11 | + # downloads the latest async-profiler release to ${{BASE_DIR}}/${{ASYNC_PROFILER}} |
| 12 | + download-unpack-async-profiler: |
| 13 | + - read-state: ${{os}} |
| 14 | + then: |
| 15 | + - regex: linux |
| 16 | + then: |
| 17 | + - set-state: platform linux-x64 |
| 18 | + - set-state: filesuffix .tar.gz |
| 19 | + - set-state: unpack_command tar xvf |
| 20 | + else: |
| 21 | + - set-state: platform macos |
| 22 | + - set-state: filesuffix .zip |
| 23 | + - set-state: unpack_command unzip |
| 24 | + - sh: curl -L -o ${{ASYNC_PROFILER}}${{filesuffix}} $(curl -s -L https://api.github.com/repos/${{ASYNC_PROFILER}}/${{ASYNC_PROFILER}}/releases/latest | jq -r '.assets[] | select(.name | contains ("${{platform}}${{filesuffix}}")) | .browser_download_url') 2>/dev/null |
| 25 | + - sh: ${{unpack_command}} ${{ASYNC_PROFILER}}${{filesuffix}} |
| 26 | + then: |
| 27 | + - regex: (?<subDir>^[^/]+)/ |
| 28 | + then: |
| 29 | + - sh: mv ${{subDir}}/ ${{ASYNC_PROFILER}} |
| 30 | + |
| 31 | + async-profiler-install: |
| 32 | + - sh: if test -d ${{ASYNC_PROFILER_DIR}} ; then rm -rf ${{ASYNC_PROFILER_DIR}}; fi |
| 33 | + - sh: cd ${{BASE_DIR}} |
| 34 | + - script: download-unpack-async-profiler |
| 35 | + |
| 36 | + #waits for ${{WAIT_START}} then ${{DELAY}}, creates a profile using the configured parameters then downloads it immediately |
| 37 | + #works with 3.x, not 2.x |
| 38 | + async-profiler-run: |
| 39 | + - sh: cd ${{ASYNC_PROFILER_DIR}} |
| 40 | + - wait-for: ${{wait_start:}} # don't wait by default |
| 41 | + - sleep: ${{delay:0}} |
| 42 | + - sh: > |
| 43 | + bin/asprof |
| 44 | + -d ${{duration__10}} |
| 45 | + -f /tmp/flamegraph.${{suffix__html}} |
| 46 | + -o ${{format__flamegraph}} |
| 47 | + -e ${{events__cpu}} |
| 48 | + ${{="${{enableTotal __ }}".toLowerCase() == "true" ? "--total" : ""}} |
| 49 | + --title ${{title__async-profiler}} |
| 50 | + ${{pid}} |
| 51 | + separator: __ |
| 52 | + - download: /tmp/flamegraph.${{suffix:html}} |
0 commit comments