chore: temporary probe workflow (do not merge) #1
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Probe samply vs file capabilities | |
| on: | |
| push: | |
| branches: [probe/samply-caps] | |
| jobs: | |
| probe: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 | |
| with: | |
| submodules: true | |
| - uses: ./.github/actions/install-rust | |
| - name: Kernel / PMU facts | |
| run: | | |
| uname -r | |
| echo "suid_dumpable=$(cat /proc/sys/fs/suid_dumpable)" | |
| echo "perf_event_paranoid=$(cat /proc/sys/kernel/perf_event_paranoid)" | |
| sudo apt-get install -y linux-tools-common linux-tools-generic >/dev/null 2>&1 || true | |
| echo "--- perf stat with hardware events (does the PMU exist?)" | |
| sudo perf stat -e cpu-cycles,instructions true 2>&1 | tail -12 || echo "perf unavailable" | |
| - name: Build codspeed CLI | |
| run: cargo build --release | |
| - name: Build burner and set capabilities | |
| run: | | |
| printf '#include <time.h>\nint main(){struct timespec a,b;clock_gettime(CLOCK_MONOTONIC,&a);volatile double x=0;for(;;){for(int i=0;i<1000000;i++)x+=i*0.5;clock_gettime(CLOCK_MONOTONIC,&b);if(b.tv_sec-a.tv_sec>=3)break;}return (int)x&1;}' > burn.c | |
| gcc -O1 -o "$HOME/burn_nocap" burn.c | |
| cp "$HOME/burn_nocap" "$HOME/burn_cap" | |
| sudo setcap cap_sys_admin,cap_bpf,cap_perfmon+ep "$HOME/burn_cap" | |
| getcap "$HOME/burn_cap" | |
| - name: Sample counts, 4 combinations | |
| run: | | |
| count() { python3 -c " | |
| import gzip,json,sys | |
| p=json.load(gzip.open(sys.argv[1])) | |
| print(sum(t['samples']['length'] for t in p['threads']), 'samples across', len(p['threads']), 'threads') | |
| " "$1"; } | |
| for v in nocap cap; do | |
| for priv in user root; do | |
| o="/tmp/p_${v}_${priv}.json.gz" | |
| if [ "$priv" = root ]; then | |
| sudo --preserve-env ./target/release/codspeed samply record --no-open --save-only --rate 997 -o "$o" -- "$HOME/burn_$v" >/dev/null 2>&1 || true | |
| else | |
| ./target/release/codspeed samply record --no-open --save-only --rate 997 -o "$o" -- "$HOME/burn_$v" >/dev/null 2>&1 || true | |
| fi | |
| echo "$v / samply-as-$priv: $( [ -f "$o" ] && count "$o" || echo 'no profile written' )" | |
| done | |
| done | |
| - name: Same, with software events instead of hardware | |
| env: | |
| SAMPLY_PERF_EVENTS: "cpu-clock:0:0x0" | |
| run: | | |
| sudo --preserve-env ./target/release/codspeed samply record --no-open --save-only --rate 997 -o /tmp/p_sw.json.gz -- "$HOME/burn_nocap" >/dev/null 2>&1 || true | |
| python3 -c " | |
| import gzip,json | |
| p=json.load(gzip.open('/tmp/p_sw.json.gz')) | |
| print('software-event samples:', sum(t['samples']['length'] for t in p['threads'])) | |
| " |