@@ -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 : ' 18'
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 : ' nogil'
49+ configure_flags : ' --disable-gil'
50+ description : ' Free-threaded build'
51+ install_deps : ' standard'
52+ fail-fast : false
3653
3754 steps :
38- - name : Clone CPython repository
55+ - name : Checkout memory tracker
56+ uses : actions/checkout@v4
57+
58+ - name : Set up Python
59+ uses : actions/setup-python@v4
60+ with :
61+ python-version : ' 3.11'
62+
63+ - name : Clone CPython repository and get commits
3964 run : |
4065 git clone ${{ github.event.inputs.cpython_repo || 'https://github.com/python/cpython.git' }} cpython
4166 cd cpython
4267 git fetch --all
4368
44- - name : Get commits from target date
45- id : get-commits
46- run : |
47- cd cpython
48-
4969 # Determine target date
5070 if [ -n "${{ github.event.inputs.target_date }}" ]; then
5171 TARGET_DATE="${{ github.event.inputs.target_date }}"
@@ -60,45 +80,30 @@ jobs:
6080
6181 if [ -z "$COMMITS" ]; then
6282 echo "No commits found for date $TARGET_DATE"
63- echo "commits=" >> $GITHUB_OUTPUT
64- echo "commit-count=0" >> $GITHUB_OUTPUT
83+ exit 1
6584 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))')
6885 COMMIT_COUNT=$(echo "$COMMITS" | wc -l)
86+ FIRST_COMMIT=$(echo "$COMMITS" | head -1)
87+ LAST_COMMIT=$(echo "$COMMITS" | tail -1)
6988
7089 echo "Found $COMMIT_COUNT commits for date $TARGET_DATE"
71- echo "commits=$COMMITS_JSON " >> $GITHUB_OUTPUT
72- echo "commit-count =$COMMIT_COUNT" >> $GITHUB_OUTPUT
90+ echo "COMMIT_RANGE=${FIRST_COMMIT}..${LAST_COMMIT} " >> $GITHUB_ENV
91+ echo "COMMIT_COUNT =$COMMIT_COUNT" >> $GITHUB_ENV
7392
7493 echo "Commits to benchmark:"
7594 echo "$COMMITS"
7695 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'
9696
97- - name : Clone CPython repository
97+ - name : Print environment variables
9898 run : |
99- git clone ${{ github.event.inputs.cpython_repo || 'https://github.com/python/cpython.git' }} cpython
100- cd cpython
101- git fetch --depth=200
99+ echo "=== Environment Variables ==="
100+ echo "COMMIT_RANGE: $COMMIT_RANGE"
101+ echo "COMMIT_COUNT: $COMMIT_COUNT"
102+ echo "Binary ID: ${{ matrix.build_config.binary_id }}"
103+ echo "Description: ${{ matrix.build_config.description }}"
104+ echo "Configure flags: ${{ matrix.build_config.configure_flags }}"
105+ echo "Install deps: ${{ matrix.build_config.install_deps }}"
106+ echo "=========================="
102107
103108 - name : Install memory tracker worker
104109 run : |
@@ -110,6 +115,11 @@ jobs:
110115 # Install CPython dependencies using their script
111116 cd cpython
112117 sudo .github/workflows/posix-deps-apt.sh
118+
119+ # Install JIT dependencies if needed
120+ if [ "${{ matrix.build_config.install_deps }}" = "jit" ]; then
121+ sudo bash -c "$(wget -O - https://apt.llvm.org/llvm.sh)" ./llvm.sh ${{ github.event.inputs.llvm || '18' }}
122+ fi
113123
114124 # Install Memray dependencies
115125 sudo apt-get install -y \
@@ -118,31 +128,34 @@ jobs:
118128 libunwind-dev \
119129 liblz4-dev
120130
121- - name : Run memory benchmark for commit
131+ - name : Run memory benchmark for commit range - ${{ matrix.build_config.description }}
122132 env :
123133 MEMORY_TRACKER_TOKEN : ${{ secrets.MEMORY_TRACKER_TOKEN }}
124134 run : |
125- COMMIT="${{ matrix.commit }}"
135+ if [ "${{ matrix.build_config.install_deps }}" = "jit" ]; then
136+ export PATH="$(llvm-config-${{ github.event.inputs.llvm || '18' }} --bindir):$PATH"
137+ fi
126138
127- # Build command for single commit
128- CMD="memory-tracker benchmark '$COMMIT '"
139+ # Build command for commit range
140+ CMD="memory-tracker benchmark '$COMMIT_RANGE '"
129141 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 ' }}'"
142+ CMD="$CMD --binary-id '${{ matrix.build_config. binary_id }}'"
143+ CMD="$CMD --environment-id '${{ github.event.inputs.environment_id || 'gh_actions ' }}'"
132144 CMD="$CMD --api-base '${{ github.event.inputs.server_url || 'https://memory.python.org' }}'"
133145 CMD="$CMD --output-dir ./benchmark_results"
146+ CMD="$CMD --configure-flags='${{ matrix.build_config.configure_flags }}'"
134147 CMD="$CMD --force"
135148 CMD="$CMD -vv"
136149
137- echo "Running benchmark for commit: $COMMIT "
150+ echo "Running ${{ matrix.build_config.description }} benchmark for commit range with $COMMIT_COUNT commits "
138151 echo "Command: $CMD"
139152 eval $CMD
140153
141154 - name : Upload benchmark results (if failed)
142155 if : failure()
143156 uses : actions/upload-artifact@v4
144157 with :
145- name : benchmark-logs-${{ matrix.commit }}
158+ name : benchmark-logs-${{ matrix.build_config.binary_id }}
146159 path : |
147160 *.log
148161 ./benchmark_results/
@@ -152,23 +165,18 @@ jobs:
152165 if : success()
153166 uses : actions/upload-artifact@v4
154167 with :
155- name : benchmark-results-${{ matrix.commit }}
168+ name : benchmark-results-${{ matrix.build_config.binary_id }}
156169 path : ./benchmark_results/
157170 retention-days : 30
158171
159172 summary :
160- needs : [get-daily-commits, benchmark-commits]
173+ needs : benchmark-builds
161174 if : always()
162175 runs-on : ubuntu-latest
163176
164177 steps :
165178 - name : Print summary
166179 run : |
167180 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
181+ echo "Benchmark jobs completed with status: ${{ needs.benchmark-builds.result }}"
182+ echo "Binary types benchmarked: default, debug, jit, nogil"
0 commit comments