@@ -2,22 +2,18 @@ name: Daily Memory Tracker Benchmark
22
33on :
44 schedule :
5- # Run daily at 02 :00 UTC
6- - cron : ' 0 2 * * *'
5+ # Run daily at 23 :00 UTC (EOD) to pick up all commits from the day
6+ - cron : ' 0 23 * * *'
77 workflow_dispatch :
88 inputs :
99 target_date :
1010 description : ' Date to get commits from (YYYY-MM-DD, defaults to today)'
1111 required : false
1212 type : string
13- binary_id :
14- description : ' Binary ID to use for benchmarking'
15- required : false
16- default : ' default'
1713 environment_id :
1814 description : ' Environment ID'
1915 required : false
20- default : ' gcc-11 '
16+ default : ' gh_actions '
2117 server_url :
2218 description : ' Memory tracker server URL'
2319 required : false
2622 description : ' CPython repository URL'
2723 required : false
2824 default : ' https://github.com/python/cpython.git'
25+ llvm :
26+ description : ' LLVM version to use for JIT builds'
27+ required : false
28+ default : ' 19'
2929
3030jobs :
31- get-daily-commits :
31+ benchmark-builds :
3232 runs-on : ubuntu-latest
33- outputs :
34- commits : ${{ steps.get-commits.outputs.commits }}
35- commit-count : ${{ steps.get-commits.outputs.commit-count }}
33+ strategy :
34+ matrix :
35+ build_config :
36+ - binary_id : ' default'
37+ configure_flags : ' -C'
38+ description : ' Default build'
39+ install_deps : ' standard'
40+ - binary_id : ' debug'
41+ configure_flags : ' --with-pydebug'
42+ description : ' Debug build'
43+ install_deps : ' standard'
44+ - binary_id : ' jit'
45+ configure_flags : ' --enable-experimental-jit'
46+ description : ' JIT build'
47+ install_deps : ' jit'
48+ - binary_id : ' lto-pgo'
49+ configure_flags : ' --with-lto --enable-optimizations'
50+ description : ' LTO-PGO build'
51+ install_deps : ' standard'
52+ - binary_id : ' nogil'
53+ configure_flags : ' --disable-gil'
54+ description : ' Free-threaded build'
55+ install_deps : ' standard'
56+ fail-fast : false
3657
3758 steps :
38- - name : Clone CPython repository
59+ - name : Checkout memory tracker
60+ uses : actions/checkout@v4
61+
62+ - name : Set up Python
63+ uses : actions/setup-python@v4
64+ with :
65+ python-version : ' 3.11'
66+
67+ - name : Clone CPython repository and get commits
3968 run : |
4069 git clone ${{ github.event.inputs.cpython_repo || 'https://github.com/python/cpython.git' }} cpython
4170 cd cpython
4271 git fetch --all
4372
44- - name : Get commits from target date
45- id : get-commits
46- run : |
47- cd cpython
48-
4973 # Determine target date
5074 if [ -n "${{ github.event.inputs.target_date }}" ]; then
5175 TARGET_DATE="${{ github.event.inputs.target_date }}"
@@ -60,45 +84,30 @@ jobs:
6084
6185 if [ -z "$COMMITS" ]; then
6286 echo "No commits found for date $TARGET_DATE"
63- echo "commits=" >> $GITHUB_OUTPUT
64- echo "commit-count=0" >> $GITHUB_OUTPUT
87+ exit 1
6588 else
66- # Convert to JSON array format for matrix strategy
67- COMMITS_JSON=$(echo "$COMMITS" | jq -R -s -c 'split("\n") | map(select(length > 0))')
6889 COMMIT_COUNT=$(echo "$COMMITS" | wc -l)
90+ FIRST_COMMIT=$(echo "$COMMITS" | head -1)
91+ LAST_COMMIT=$(echo "$COMMITS" | tail -1)
6992
7093 echo "Found $COMMIT_COUNT commits for date $TARGET_DATE"
71- echo "commits=$COMMITS_JSON " >> $GITHUB_OUTPUT
72- echo "commit-count =$COMMIT_COUNT" >> $GITHUB_OUTPUT
94+ echo "COMMIT_RANGE=${FIRST_COMMIT}..${LAST_COMMIT} " >> $GITHUB_ENV
95+ echo "COMMIT_COUNT =$COMMIT_COUNT" >> $GITHUB_ENV
7396
7497 echo "Commits to benchmark:"
7598 echo "$COMMITS"
7699 fi
77-
78- benchmark-commits :
79- needs : get-daily-commits
80- if : needs.get-daily-commits.outputs.commit-count > 0
81- runs-on : ubuntu-latest
82- strategy :
83- matrix :
84- commit : ${{ fromJson(needs.get-daily-commits.outputs.commits) }}
85- fail-fast : false
86- max-parallel : 3
87-
88- steps :
89- - name : Checkout memory tracker
90- uses : actions/checkout@v4
91-
92- - name : Set up Python
93- uses : actions/setup-python@v4
94- with :
95- python-version : ' 3.11'
96100
97- - name : Clone CPython repository
101+ - name : Print environment variables
98102 run : |
99- git clone ${{ github.event.inputs.cpython_repo || 'https://github.com/python/cpython.git' }} cpython
100- cd cpython
101- git fetch --depth=200
103+ echo "=== Environment Variables ==="
104+ echo "COMMIT_RANGE: $COMMIT_RANGE"
105+ echo "COMMIT_COUNT: $COMMIT_COUNT"
106+ echo "Binary ID: ${{ matrix.build_config.binary_id }}"
107+ echo "Description: ${{ matrix.build_config.description }}"
108+ echo "Configure flags: ${{ matrix.build_config.configure_flags }}"
109+ echo "Install deps: ${{ matrix.build_config.install_deps }}"
110+ echo "=========================="
102111
103112 - name : Install memory tracker worker
104113 run : |
@@ -110,6 +119,11 @@ jobs:
110119 # Install CPython dependencies using their script
111120 cd cpython
112121 sudo .github/workflows/posix-deps-apt.sh
122+
123+ # Install JIT dependencies if needed
124+ if [ "${{ matrix.build_config.install_deps }}" = "jit" ]; then
125+ sudo bash -c "$(wget -O - https://apt.llvm.org/llvm.sh)" ./llvm.sh ${{ github.event.inputs.llvm || '19' }}
126+ fi
113127
114128 # Install Memray dependencies
115129 sudo apt-get install -y \
@@ -118,31 +132,34 @@ jobs:
118132 libunwind-dev \
119133 liblz4-dev
120134
121- - name : Run memory benchmark for commit
135+ - name : Run memory benchmark for commit range - ${{ matrix.build_config.description }}
122136 env :
123137 MEMORY_TRACKER_TOKEN : ${{ secrets.MEMORY_TRACKER_TOKEN }}
124138 run : |
125- COMMIT="${{ matrix.commit }}"
139+ if [ "${{ matrix.build_config.install_deps }}" = "jit" ]; then
140+ export PATH="$(llvm-config-${{ github.event.inputs.llvm || '19' }} --bindir):$PATH"
141+ fi
126142
127- # Build command for single commit
128- CMD="memory-tracker benchmark '$COMMIT '"
143+ # Build command for commit range
144+ CMD="memory-tracker benchmark '$COMMIT_RANGE '"
129145 CMD="$CMD --repo-path ./cpython"
130- CMD="$CMD --binary-id '${{ github.event.inputs. binary_id || 'default' }}'"
131- CMD="$CMD --environment-id '${{ github.event.inputs.environment_id || 'gcc-11 ' }}'"
146+ CMD="$CMD --binary-id '${{ matrix.build_config. binary_id }}'"
147+ CMD="$CMD --environment-id '${{ github.event.inputs.environment_id || 'gh_actions ' }}'"
132148 CMD="$CMD --api-base '${{ github.event.inputs.server_url || 'https://memory.python.org' }}'"
133149 CMD="$CMD --output-dir ./benchmark_results"
150+ CMD="$CMD --configure-flags=${{ matrix.build_config.configure_flags }}"
134151 CMD="$CMD --force"
135152 CMD="$CMD -vv"
136153
137- echo "Running benchmark for commit: $COMMIT "
154+ echo "Running ${{ matrix.build_config.description }} benchmark for commit range with $COMMIT_COUNT commits "
138155 echo "Command: $CMD"
139156 eval $CMD
140157
141158 - name : Upload benchmark results (if failed)
142159 if : failure()
143160 uses : actions/upload-artifact@v4
144161 with :
145- name : benchmark-logs-${{ matrix.commit }}
162+ name : benchmark-logs-${{ matrix.build_config.binary_id }}
146163 path : |
147164 *.log
148165 ./benchmark_results/
@@ -152,23 +169,18 @@ jobs:
152169 if : success()
153170 uses : actions/upload-artifact@v4
154171 with :
155- name : benchmark-results-${{ matrix.commit }}
172+ name : benchmark-results-${{ matrix.build_config.binary_id }}
156173 path : ./benchmark_results/
157174 retention-days : 30
158175
159176 summary :
160- needs : [get-daily-commits, benchmark-commits]
177+ needs : benchmark-builds
161178 if : always()
162179 runs-on : ubuntu-latest
163180
164181 steps :
165182 - name : Print summary
166183 run : |
167184 echo "Daily benchmark run completed"
168- echo "Total commits processed: ${{ needs.get-daily-commits.outputs.commit-count }}"
169-
170- if [ "${{ needs.get-daily-commits.outputs.commit-count }}" = "0" ]; then
171- echo "No commits found for the target date"
172- else
173- echo "Benchmark jobs completed with status: ${{ needs.benchmark-commits.result }}"
174- fi
185+ echo "Benchmark jobs completed with status: ${{ needs.benchmark-builds.result }}"
186+ echo "Binary types benchmarked: default, debug, jit, lto-pgo, nogil"
0 commit comments