Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add performance profiling pipeline to perf tests #1392

Merged
merged 130 commits into from
Jan 18, 2024
Merged
Show file tree
Hide file tree
Changes from 109 commits
Commits
Show all changes
130 commits
Select commit Hold shift + click to select a range
1cca288
create py spy pipeline
YunchuWang Jan 3, 2024
515def1
fix
YunchuWang Jan 3, 2024
402da15
setup profiling pipeline
YunchuWang Jan 4, 2024
292daa8
update pipeline name
YunchuWang Jan 4, 2024
490848c
fix
YunchuWang Jan 4, 2024
b55e1f0
fix
YunchuWang Jan 4, 2024
9a6743f
Update profiling.yml
YunchuWang Jan 4, 2024
6724dbe
Update perf-testing-setup.yml
YunchuWang Jan 4, 2024
3563fb3
Update perf-testing-setup.yml
YunchuWang Jan 4, 2024
aa3cbcd
Update perf-testing-setup.yml
YunchuWang Jan 4, 2024
6095eb4
Update perf-testing-setup.yml
YunchuWang Jan 4, 2024
dc27bd4
Update perf-testing-setup.yml
YunchuWang Jan 4, 2024
3b7ee0e
Update perf-testing-setup.yml
YunchuWang Jan 4, 2024
b04112a
Update perf-testing-setup.yml
YunchuWang Jan 4, 2024
9a3b35c
Update perf-testing-setup.yml
YunchuWang Jan 4, 2024
f429266
Update perf-testing-setup.yml
YunchuWang Jan 4, 2024
5d42f6e
Update perf-testing-setup.yml
YunchuWang Jan 4, 2024
0475bf8
Update perf-testing-setup.yml
YunchuWang Jan 4, 2024
8088a0d
Update perf-testing-setup.yml
YunchuWang Jan 4, 2024
3f34723
Update perf_tests.Dockerfile
YunchuWang Jan 4, 2024
13bb394
Update perf_tests.Dockerfile
YunchuWang Jan 5, 2024
d8882d9
Update perf_tests.Dockerfile
YunchuWang Jan 5, 2024
edfe0b9
Update perf_tests.Dockerfile
YunchuWang Jan 5, 2024
7e0fb2b
Update perf-testing-setup.yml
YunchuWang Jan 5, 2024
c74ec1d
Update perf-testing-setup.yml
YunchuWang Jan 5, 2024
9b67694
Update perf_tests.Dockerfile
YunchuWang Jan 5, 2024
5b0bddf
Update perf-testing-setup.yml
YunchuWang Jan 5, 2024
a370113
Update perf-testing-setup.yml
YunchuWang Jan 5, 2024
e02cccd
logging
YunchuWang Jan 5, 2024
0bb2b6c
Update perf-testing-setup.yml
YunchuWang Jan 5, 2024
4ca1a98
Update perf-testing-setup.yml
YunchuWang Jan 5, 2024
6343921
Update perf-testing-setup.yml
YunchuWang Jan 5, 2024
c6c2b61
Update perf_tests.Dockerfile
YunchuWang Jan 5, 2024
c729ca9
Update perf_tests.Dockerfile
YunchuWang Jan 5, 2024
f3fe293
Update perf-testing-setup.yml
YunchuWang Jan 5, 2024
7945de9
Update SyncHttpTriggerHelloWorld.js
YunchuWang Jan 5, 2024
e6a97c3
Update perf-testing-setup.yml
YunchuWang Jan 5, 2024
b63992b
Update perf-testing-setup.yml
YunchuWang Jan 5, 2024
68c49cd
Update perf-testing-setup.yml
YunchuWang Jan 5, 2024
fb4b719
Update perf-testing-setup.yml
YunchuWang Jan 5, 2024
88f8422
Update perf-testing-setup.yml
YunchuWang Jan 5, 2024
78d1a8c
Update perf-testing-setup.yml
YunchuWang Jan 6, 2024
0759724
Update perf-testing-setup.yml
YunchuWang Jan 6, 2024
3de22b9
Update perf-testing-setup.yml
YunchuWang Jan 6, 2024
1cc2b23
fix
YunchuWang Jan 6, 2024
fba036a
rename
YunchuWang Jan 6, 2024
34014f1
Update perf-testing-setup.yml
YunchuWang Jan 6, 2024
060fd4b
Update perf-testing-setup.yml
YunchuWang Jan 6, 2024
242bc15
Update perf-testing-setup.yml
YunchuWang Jan 6, 2024
05ad2ac
Update perf-testing-setup.yml
YunchuWang Jan 6, 2024
e14ddb5
Update perf-testing-setup.yml
YunchuWang Jan 6, 2024
7757eb1
Update perf-testing-setup.yml
YunchuWang Jan 6, 2024
32f19df
Update perf-testing-setup.yml
YunchuWang Jan 6, 2024
59c3c0e
Update perf-testing-setup.yml
YunchuWang Jan 7, 2024
415b591
Update perf-testing-setup.yml
YunchuWang Jan 7, 2024
5088cc8
Update perf-testing-setup.yml
YunchuWang Jan 7, 2024
8325a99
Update perf-testing-setup.yml
YunchuWang Jan 7, 2024
e73b25e
Update perf-testing-setup.yml
YunchuWang Jan 7, 2024
896d54d
Update perf-testing-setup.yml
YunchuWang Jan 7, 2024
c6bcafb
Update perf-testing-setup.yml
YunchuWang Jan 7, 2024
04e594b
Update perf-testing-setup.yml
YunchuWang Jan 7, 2024
7cdeb1e
Update perf-testing-setup.yml
YunchuWang Jan 7, 2024
38ee2b7
Update perf-testing-setup.yml
YunchuWang Jan 7, 2024
fdbf460
Update perf-testing-setup.yml
YunchuWang Jan 7, 2024
aa94fa7
Update perf-testing-setup.yml
YunchuWang Jan 7, 2024
3621ece
Update perf-testing-setup.yml
YunchuWang Jan 7, 2024
ee0b510
Update perf-testing-setup.yml
YunchuWang Jan 7, 2024
adedd72
Update perf-testing-setup.yml
YunchuWang Jan 8, 2024
a7345e4
Update perf-testing-setup.yml
YunchuWang Jan 9, 2024
661b2ea
Update perf-testing-setup.yml
YunchuWang Jan 9, 2024
f1e3c02
Update perf-testing-setup.yml
YunchuWang Jan 9, 2024
1a26d4e
Update perf-testing-setup.yml
YunchuWang Jan 9, 2024
586cc90
Update perf-testing-setup.yml
YunchuWang Jan 9, 2024
7995480
Update perf-testing-setup.yml
YunchuWang Jan 9, 2024
2067472
Update perf-testing-setup.yml
YunchuWang Jan 9, 2024
f31a786
Update perf-testing-setup.yml
YunchuWang Jan 9, 2024
aea1be6
Update perf-testing-setup.yml
YunchuWang Jan 9, 2024
f11df87
Update perf-testing-setup.yml
YunchuWang Jan 9, 2024
a030f1c
Update perf-testing-setup.yml
YunchuWang Jan 9, 2024
ebd9eda
Update perf-testing-setup.yml
YunchuWang Jan 9, 2024
4999eb9
Update perf-testing-setup.yml
YunchuWang Jan 9, 2024
b20eaae
Update perf-testing-setup.yml
YunchuWang Jan 9, 2024
8cf6502
Update perf-testing-setup.yml
YunchuWang Jan 9, 2024
5751a82
Update perf-testing-setup.yml
YunchuWang Jan 9, 2024
efe0569
Update perf-testing-setup.yml
YunchuWang Jan 9, 2024
5384722
Update perf-testing-setup.yml
YunchuWang Jan 9, 2024
fd2fdf5
Update perf-testing-setup.yml
YunchuWang Jan 9, 2024
2453a87
Update perf-testing-setup.yml
YunchuWang Jan 9, 2024
d81e8ed
Update perf-testing-setup.yml
YunchuWang Jan 9, 2024
1e6a011
Update perf-testing-setup.yml
YunchuWang Jan 9, 2024
ad695f7
Update perf-testing-setup.yml
YunchuWang Jan 9, 2024
92b5d55
Update perf-testing-setup.yml
YunchuWang Jan 9, 2024
e7bf70f
Update perf-testing-setup.yml
YunchuWang Jan 9, 2024
ffb0c1f
Update perf-testing-setup.yml
YunchuWang Jan 9, 2024
ebad3a6
clean up
YunchuWang Jan 9, 2024
4e7340e
fix feedback
YunchuWang Jan 16, 2024
69b77fb
add newline
YunchuWang Jan 16, 2024
691af33
fix feedback
YunchuWang Jan 16, 2024
724d261
fix feedback
YunchuWang Jan 16, 2024
af1e2d4
Merge branch 'dev' into wangbill/py-spy-pipeline
YunchuWang Jan 16, 2024
5305476
fix
YunchuWang Jan 16, 2024
c03764c
Update perf-testing-setup.yml
YunchuWang Jan 16, 2024
3576b16
Update perf-testing-setup.yml
YunchuWang Jan 16, 2024
294be7b
Update perf-testing-setup.yml
YunchuWang Jan 17, 2024
b080280
Update perf-testing-setup.yml
YunchuWang Jan 17, 2024
8faf4d8
Update perf-testing-setup.yml
YunchuWang Jan 17, 2024
346dc44
Update perf-testing-setup.yml
YunchuWang Jan 17, 2024
a9cdaac
Update perf-testing-setup.yml
YunchuWang Jan 17, 2024
eb8e197
Update perf-testing-setup.yml
YunchuWang Jan 17, 2024
7cdf40d
Update .github/workflows/perf-testing-setup.yml
YunchuWang Jan 17, 2024
f9452a3
include br name
YunchuWang Jan 17, 2024
79df75f
Update perf-testing-setup.yml
YunchuWang Jan 17, 2024
306c9f3
Update perf-testing-setup.yml
YunchuWang Jan 17, 2024
8a7d910
Update perf-testing-setup.yml
YunchuWang Jan 17, 2024
8308bfc
Update perf-testing-setup.yml
YunchuWang Jan 17, 2024
17da633
Update perf-testing-setup.yml
YunchuWang Jan 17, 2024
2d113cc
Update perf-testing-setup.yml
YunchuWang Jan 17, 2024
eacf00e
Update perf-testing-setup.yml
YunchuWang Jan 17, 2024
7ccd114
Update perf-testing-setup.yml
YunchuWang Jan 17, 2024
0126ef6
Update perf-testing-setup.yml
YunchuWang Jan 17, 2024
b89d961
Update perf-testing-setup.yml
YunchuWang Jan 17, 2024
822b60e
Update perf-testing-setup.yml
YunchuWang Jan 17, 2024
8ad6add
Update perf-testing-setup.yml
YunchuWang Jan 17, 2024
ab51f58
Update perf_tests.Dockerfile
YunchuWang Jan 17, 2024
8c56fd7
Update perf-testing-setup.yml
YunchuWang Jan 17, 2024
1b19f3e
Update perf-testing-setup.yml
YunchuWang Jan 18, 2024
5bba459
Update perf-testing-setup.yml
YunchuWang Jan 18, 2024
3afc460
Update perf-testing-setup.yml
YunchuWang Jan 18, 2024
f99bce1
Update perf-testing-setup.yml
YunchuWang Jan 18, 2024
e4c4a96
Update perf-testing-setup.yml
YunchuWang Jan 18, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .ci/perf_tests/dockerfiles/perf_tests.Dockerfile
YunchuWang marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ ENV AzureWebJobsScriptRoot=/home/site/wwwroot \
FUNCTIONS_WORKER_SHARED_MEMORY_DATA_TRANSFER_ENABLED=1

RUN apt-get --quiet update && \
apt-get install --quiet -y git && \
apt-get install --quiet -y git procps && \
YunchuWang marked this conversation as resolved.
Show resolved Hide resolved
# Procps is required for displaying worker and profiling processes info
cd /home && \
git clone https://github.com/vrdmr/AzFunctionsPythonPerformance.git && \
mkdir -p /home/site/wwwroot/ && \
Expand Down
25 changes: 0 additions & 25 deletions .ci/perf_tests/dockerfiles/perf_tests_3.6.Dockerfile
YunchuWang marked this conversation as resolved.
Outdated
Show resolved Hide resolved

This file was deleted.

25 changes: 0 additions & 25 deletions .ci/perf_tests/dockerfiles/perf_tests_3.7.Dockerfile

This file was deleted.

3 changes: 2 additions & 1 deletion .ci/perf_tests/dockerfiles/perf_tests_3.9.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,8 @@ VOLUME ["/azure-functions-host/workers/python/3.8/LINUX/X64/azure_functions_work
RUN apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 379CE192D401AB61 && \
echo "deb https://dl.bintray.com/loadimpact/deb stable main" | tee -a /etc/apt/sources.list && \
apt-get update && \
apt-get install -y git k6 && \
apt-get install -y git k6 procps && \
# Procps is required for displaying worker and profiling processes info
cd /home && \
git clone https://github.com/vrdmr/AzFunctionsPythonPerformance.git && \
mkdir -p /home/site/wwwroot/ && \
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export let options = {

// Main function
export default function () {
let response = http.get(`${PROTOCOL}://${HOSTNAME}:${PORT}/api/SyncHttpTriggerHelloWorld`);
let response = http.get(`${PROTOCOL}://${HOSTNAME}:${PORT}/api/SyncHelloWorld`);
YunchuWang marked this conversation as resolved.
Show resolved Hide resolved

// check() returns false if any of the specified conditions fail
let checkRes = check(response, {
Expand All @@ -45,4 +45,4 @@ export default function () {

// We reverse the check() result since we want to count the failures
failureRate.add(!checkRes);
}
}
88 changes: 74 additions & 14 deletions .github/workflows/perf-testing-setup.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,35 +2,33 @@ name: Throughput testing workflow

on:
workflow_dispatch:
pull_request:
YunchuWang marked this conversation as resolved.
Show resolved Hide resolved
branches: [ dev ]

inputs:
profiling_sampling_rate:
description: 'Profiling sampling rate (tps)'
required: false
default: '500'
YunchuWang marked this conversation as resolved.
Show resolved Hide resolved
issue_comment:
types: [created]
env:
TESTS_DIR_PATH: ".ci/perf_tests/k6scripts/"
PYTHON_VERSION: "3.8"
PYTHON_VERSION: "3.11"
PYTHON_FUNCTION_PROFILING_STORAGE_ACCT: "azpyfuncpipelinestorage"
PORT: 8000

jobs:
build:
if: ${{ github.event_name == 'workflow_dispatch' || github.event.issue.pull_request && contains(github.event.comment.body, '/profile') }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
test_to_run: [ SyncHttpTriggerHelloWorld ]
test_to_run: [ SyncHelloWorld ]
steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ env.PYTHON_VERSION }}
uses: actions/setup-python@v2
with:
python-version: ${{ env.PYTHON_VERSION }}
- name: Set up Dotnet 2.x
uses: actions/setup-dotnet@v1
with:
dotnet-version: '3.1.405'
- name: Set up Dotnet 6.x
uses: actions/setup-dotnet@v1
with:
dotnet-version: '6.x'
- name: Setup k6 for throughput testing
run: |
cd $GITHUB_WORKSPACE
Expand All @@ -47,13 +45,75 @@ jobs:
python setup.py extension
YunchuWang marked this conversation as resolved.
Show resolved Hide resolved
- name: Build and Run the Docker image
run: |
echo "Building Docker image with Python version ${{ env.PYTHON_VERSION }}"
docker build --build-arg PYTHON_VERSION=${{ env.PYTHON_VERSION }} --file .ci/perf_tests/dockerfiles/perf_tests.Dockerfile --tag perfimage:latest .
docker run -d --shm-size="2g" --env FUNCTIONS_WORKER_RUNTIME_VERSION=${{ env.PYTHON_VERSION }} -p ${PORT}:80 -v $GITHUB_WORKSPACE/azure_functions_worker:/azure-functions-host/workers/python/${{ env.PYTHON_VERSION }}/LINUX/X64/azure_functions_worker perfimage:latest

echo "Running Docker container..."
container_id=$(docker run -d --privileged --shm-size="2g" --env FUNCTIONS_WORKER_RUNTIME_VERSION=${{ env.PYTHON_VERSION }} -p ${PORT}:80 -v $GITHUB_WORKSPACE/azure_functions_worker:/azure-functions-host/workers/python/${{ env.PYTHON_VERSION }}/LINUX/X64/azure_functions_worker perfimage:latest)
YunchuWang marked this conversation as resolved.
Show resolved Hide resolved
sleep 10 # host needs some time to start.
echo "Container ID is $container_id"

echo "Fetching Docker container logs..."
docker logs $container_id
worker_pid=$(docker exec $container_id sh -c "ps aux | grep '[p]ython'" | awk '{print $2}')
YunchuWang marked this conversation as resolved.
Show resolved Hide resolved
echo "Python worker process id is $worker_pid"

echo "container_id=$container_id" >> $GITHUB_ENV
echo "worker_pid=$worker_pid" >> $GITHUB_ENV

- name: Validate if the functions are now running
run: |
curl --get http://localhost:${PORT}/api/${{ matrix.test_to_run }}

- name: Start py-spy in the background
run: |
docker exec $container_id sh -c "pip install py-spy"
docker exec $container_id sh -c "mkdir /home/profiling_reports"
profiling_sampling_rate=${{ github.event.inputs.profiling_sampling_rate || 800 }}
report_name="azpyfuncpprofiling_${{ github.run_id }}.svg"
YunchuWang marked this conversation as resolved.
Show resolved Hide resolved
docker exec -d $container_id sh -c "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 &"
sleep 2 # Give it a moment to start
py_spy_id=$(docker exec $container_id sh -c "ps aux | grep '[p]y-spy record'" | awk '{print $2}')
YunchuWang marked this conversation as resolved.
Show resolved Hide resolved

echo "py_spy_id=$py_spy_id" >> $GITHUB_ENV
echo "report_name=$report_name" >> $GITHUB_ENV

- name: Run Throughput tests
run: |
chmod 755 .ci/perf_tests/run-perftests.sh
.ci/perf_tests/run-perftests.sh localhost $PORT ${{ env.TESTS_DIR_PATH }} ${{ matrix.test_to_run }}

- name: Stop profiling and generate report
YunchuWang marked this conversation as resolved.
Show resolved Hide resolved
run: |
echo "Tests completed, terminating py-spy..."
docker exec $container_id cat /home/site/wwwroot/py-spy.log
docker exec $container_id sh -c "kill -2 $py_spy_id"
sleep 2

mkdir profiling_reports
chmod 777 profiling_reports
docker cp $container_id:/home/profiling_reports/$report_name profiling_reports

- name: Upload SVG to Azure Blob Storage
uses: bacongobbler/[email protected]
YunchuWang marked this conversation as resolved.
Show resolved Hide resolved
with:
source_dir: 'profiling_reports' # Directory containing the $report_name file
container_name: 'profiling'
connection_string: ${{ secrets.AZURE_STORAGE_CONNECTION_STRING }}
sync: 'false'

- name: Output Blob URL
run: |
blob_url="https://${{ env.PYTHON_FUNCTION_PROFILING_STORAGE_ACCT }}.blob.core.windows.net/profiling/${{ env.report_name }}"
echo "You can view the Blob at: $blob_url"
YunchuWang marked this conversation as resolved.
Show resolved Hide resolved

- name: Upload profiling result to artifact
uses: actions/upload-artifact@v2
with:
name: py-spy-output
path: 'profiling_reports/${{ env.report_name }}'

- name: Create Artifact Link
run: |
echo "You can download the SVG artifact from the Actions run page."
echo "Link to the Actions run page: https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}"
Loading