1111 description : ' List of perf tests to run'
1212 required : false
1313 default : SyncHelloWorld
14+ report_format :
15+ description : ' Format of profiling report'
16+ type : choice
17+ required : true
18+ options :
19+ - speedscope
20+ - flamegraph
1421 issue_comment :
1522 types : [created]
1623env :
2128
2229jobs :
2330 build :
24- if : ${{ github.event_name == 'workflow_dispatch' || github.event.issue.pull_request && contains(github.event.comment.body, '/profile') }}
31+ if : ${{ github.event_name == 'workflow_dispatch' || github.event.issue.pull_request != null && contains(github.event.comment.body, '/profile') }}
2532 runs-on : ubuntu-latest
33+ permissions : read-all
2634 strategy :
2735 fail-fast : false
2836 matrix :
7482 docker exec $container_id sh -c "pip install py-spy"
7583 docker exec $container_id sh -c "mkdir /home/profiling_reports"
7684 profiling_sampling_rate=${{ github.event.inputs.profiling_sampling_rate }}
77- # report_name="${GITHUB_REF#refs/heads/}_${{ github.run_id }}.svg"
78- report_name="${{ github.run_id }}.svg"
79- docker exec -d $container_id sh -c "RUST_BACKTRACE=1 py-spy record -p $worker_pid -o /home/profiling_reports/$report_name -f flamegraph --idle --nonblocking --rate $profiling_sampling_rate > /home/site/wwwroot/py-spy.log 2>&1 &"
85+ report_format=${{ github.event.inputs.report_format }}
86+ if [ "$report_format" == "flamegraph" ]; then
87+ report_name="${{ github.run_id }}.svg"
88+ elif [ "$report_format" == "speedscope" ]; then
89+ report_name="${{ github.run_id }}.speedscope.json"
90+ else
91+ echo "Unsupported report format: $report_format"
92+ exit 1
93+ fi
94+ docker exec -d $container_id sh -c "RUST_BACKTRACE=1 py-spy record -p $worker_pid -o /home/profiling_reports/$report_name -f $report_format --idle --nonblocking --rate $profiling_sampling_rate > /home/site/wwwroot/py-spy.log 2>&1 &"
8095 sleep 2 # Give it a moment to start
8196 py_spy_id=$(docker exec $container_id sh -c "ps aux | grep '[p]y-spy record'" | awk '{print $2}')
8297
@@ -94,11 +109,9 @@ jobs:
94109 docker exec $container_id cat /home/site/wwwroot/py-spy.log
95110 docker exec $container_id sh -c "kill -2 $py_spy_id"
96111 sleep 2
97-
98112 mkdir profiling_reports
99113 chmod 777 profiling_reports
100114 docker cp $container_id:/home/profiling_reports/$report_name profiling_reports
101-
102115 - name : Upload SVG to Azure Blob Storage
103116 uses : bacongobbler/azure-blob-storage-upload@v3.0.0
104117 with :
@@ -111,7 +124,7 @@ jobs:
111124 run : |
112125 blob_url="https://${{ env.PYTHON_FUNCTION_PROFILING_STORAGE_ACCT }}.blob.core.windows.net/profiling/${{ env.report_name }}"
113126 echo "You can view the Blob at: $blob_url"
114-
127+
115128 - name : Upload profiling result to artifact
116129 uses : actions/upload-artifact@v2
117130 with :
0 commit comments