|
85 | 85 | description: the number of tests the archive holds |
86 | 86 | value: ${{ jobs.archive.outputs.archived }} |
87 | 87 | shards: |
88 | | - description: the run stage's shards, from the measured work of main's last run |
| 88 | + description: the run stage's shards, from the shards of main's last run and the longest of them |
89 | 89 | value: ${{ jobs.archive.outputs.shards }} |
90 | 90 |
|
91 | 91 | env: |
@@ -198,27 +198,46 @@ jobs: |
198 | 198 | fi |
199 | 199 | python3 .github/tools/test_history.py take "$RUNNER_TEMP/unit/history" "$d" "$d"/*/ |
200 | 200 |
|
201 | | - # THE SHARDS FROM THE PLAN (design 2026-11-20 §5.17, CI4): the measured work of main's last |
202 | | - # run, its shards' programs' durations summed (the history holds that run's shards alone, |
203 | | - # test_history.py), over what one shard does in 30 minutes with its four workers; at least |
204 | | - # one, at most eight. With no history, four, as before. |
| 201 | + # THE SHARDS FROM THE PLAN (design 2026-11-20 §5.17, CI4): main's last run took N shards and |
| 202 | + # the longest of them W, so the run is N × W of shard time; this one takes as many shards as |
| 203 | + # that is in 30 minutes each, at least one, at most eight. N and W are read from the stores |
| 204 | + # the shard jobs kept (`mtest-unit-<name>-<shard>-a<attempt>`, each holding that shard's |
| 205 | + # runs, test_history.py): the store's import (test-report) keeps a run in the form of |
| 206 | + # mtest's records, which state no shard, and the subsystems' store beside them is another |
| 207 | + # job's. A shard's time is that of its longest programs and of those that |
| 208 | + # run beside one another, not its programs' durations over four workers: the openkal |
| 209 | + # programs build in parallel within the machine's one budget, and in fewer shards they run |
| 210 | + # beside one another and each takes longer. A run of three shards (1236, 834 and 1438 s) |
| 211 | + # gave two by its durations summed, and the two took 2544 and 2432 s, `trees` 1369 s in the |
| 212 | + # first run and past the 40 minutes it states in the second (CI, 2026-11-21). With no |
| 213 | + # history of shards, four. |
205 | 214 | - name: The run stage's shards |
206 | 215 | id: shards |
207 | 216 | shell: bash |
| 217 | + env: |
| 218 | + KEY: ${{ inputs.name }} |
208 | 219 | run: | |
209 | 220 | set -uo pipefail |
210 | | - work=$(find "$RUNNER_TEMP/unit/history" -name programs.ndjson -print0 2>/dev/null \ |
211 | | - | xargs -0 -r cat | jq -s 'map(.ms // 0) | add // 0') |
212 | | - if [ -z "$work" ] || [ "${work%.*}" = 0 ]; then |
213 | | - echo 'shards=[1,2,3,4]' >> "$GITHUB_OUTPUT"; echo "no measured work: four shards"; exit 0 |
| 221 | + # A re-run's store (`-a2`) holds the attempt before it and its `--failed` run: the |
| 222 | + # shards are counted by number, and the longest run is the whole shard's. |
| 223 | + was=0; longest=0 |
| 224 | + for s in "$RUNNER_TEMP"/unit-stores/mtest-unit-"$KEY"-*-a*/; do |
| 225 | + [[ "$(basename "$s")" =~ ^mtest-unit-"$KEY"-([0-9]+)-a[0-9]+$ ]] || continue |
| 226 | + [ -f "$s/index.ndjson" ] || continue |
| 227 | + [ "${BASH_REMATCH[1]}" -le "$was" ] || was=${BASH_REMATCH[1]} |
| 228 | + ms=$(jq -s 'map(.ms // 0) | max // 0 | floor' "$s/index.ndjson" 2>/dev/null || echo 0) |
| 229 | + [ "${ms:-0}" -le "$longest" ] || longest=$ms |
| 230 | + done |
| 231 | + if [ "$was" -le 0 ] || [ "$longest" -le 0 ]; then |
| 232 | + echo 'shards=[1,2,3,4]' >> "$GITHUB_OUTPUT"; echo "no measured shards: four shards"; exit 0 |
214 | 233 | fi |
215 | | - per=$((30 * 60 * 1000 * 4)) |
216 | | - n=$(( (${work%.*} + per - 1) / per )) |
| 234 | + per=$((30 * 60 * 1000)) |
| 235 | + n=$(( (was * longest + per - 1) / per )) |
217 | 236 | [ "$n" -ge 1 ] || n=1 |
218 | 237 | [ "$n" -le 8 ] || n=8 |
219 | 238 | list=$(seq -s, 1 "$n") |
220 | 239 | echo "shards=[$list]" >> "$GITHUB_OUTPUT" |
221 | | - echo "measured work ${work%.*} ms: $n shard(s)" |
| 240 | + echo "main's last run: $was shard(s), the longest $((longest / 1000)) s: $n shard(s)" |
222 | 241 |
|
223 | 242 | - name: Upload the tests and their history |
224 | 243 | if: steps.archive.outputs.archived != '0' |
|
0 commit comments