From 9262900372cc8567cf97ef363aa379f1fb4900df Mon Sep 17 00:00:00 2001 From: Jonathan Peris Date: Thu, 3 Dec 2026 14:39:58 -0300 Subject: [PATCH] Compile at most one heavy JSON sample at a time in a test shard CI runs three samples at once on 16 GB runners. The reflection-based JSON samples need 3 to 4 GiB each to compile for wasm32 at -O2 (325_json_types 4.0 GiB, 317_json_deserialize 3.1 GiB, both unfinished after 500 s on a loaded host), so three of them meeting in one shard can run the runner out of memory: wasm32 shard 0 lost its runner on two pull requests whose new sample had put them together (a rerun of each passed). Other samples still run beside a heavy one. --- docs/05-testing.md | 3 ++- tests/heavy-samples.txt | 20 ++++++++++++++++++++ tests/run.sh | 13 +++++++++++-- 3 files changed, 33 insertions(+), 3 deletions(-) create mode 100644 tests/heavy-samples.txt diff --git a/docs/05-testing.md b/docs/05-testing.md index b819dfce..3552e466 100644 --- a/docs/05-testing.md +++ b/docs/05-testing.md @@ -49,7 +49,8 @@ exit code; every sample gets scratch files of its own. The first sample of each so the shared runtime/corelib cache in `~/.cache/csharpc` is filled once, and the samples listed in `tests/serial-samples.txt` run alone too: those that observe their neighbours (connecting to a port that was just closed on purpose, wall-clock windows of a few tens of milliseconds, inotify). Add a sample -there if it flakes only when run next to others. `--repeat` and `--via-il` always run one sample at a +there if it flakes only when run next to others. At most one sample of `tests/heavy-samples.txt` compiles at a time (reflection-based +JSON: 3-4 GiB each for wasm32, and three at once cost CI its runner, #590); others run beside it. `--repeat` and `--via-il` always run one sample at a time. CI uses 3 on every platform (`jobs_for_platform` in `tools/ci-plan.sh`). `--via-il` runs the same samples against the same recordings through csc first, as the dotnet pipeline diff --git a/tests/heavy-samples.txt b/tests/heavy-samples.txt new file mode 100644 index 00000000..ba0792fb --- /dev/null +++ b/tests/heavy-samples.txt @@ -0,0 +1,20 @@ +# Samples whose compilation needs gigabytes (reflection-based System.Text.Json): tests/run.sh runs at most one of them at once when +# CSHARPC_JOBS > 1, next to ordinary samples. Measured on linux-x64 for wasm32-wasip1 at -O2 (#590): 325_json_types 4.0 GiB and +# 317_json_deserialize 3.1 GiB, both still growing at 500 s; three at once exhausted a 16 GB CI runner. One name per line, '#' starts a comment. +1160_json_private_nested_types +1250_json_culture_real +1251_json_culture_synthetic +1295_json_reflection_bcl_member_types +1296_json_reflection_dateonly_timeonly +1301_json_reflection_roots +1313_json_reflection_disabled +315_json_node +316_json_serialize +317_json_deserialize +318_json_options +319_json_converters +320_json_polymorphism +321_json_references +323_json_anonymous_and_file_local +325_json_types +740_json_internal_types diff --git a/tests/run.sh b/tests/run.sh index 5327b1ba..3b721621 100755 --- a/tests/run.sh +++ b/tests/run.sh @@ -279,19 +279,24 @@ JOBS="${CSHARPC_JOBS:-1}" [[ "$JOBS" =~ ^[1-9][0-9]*$ ]] || { echo "bad CSHARPC_JOBS '$JOBS'" >&2; exit 2; } # --repeat is for flake hunts, where concurrent neighbours would change what is measured; --via-il has its own build pool. (( REPEAT > 1 || VIA_IL == 1 )) && JOBS=1 -SERIAL=" " +SERIAL=" " HEAVY=" " if (( JOBS > 1 )); then while IFS= read -r line || [[ -n "$line" ]]; do line="${line%%#*}"; line="${line//[[:space:]]/}" [[ -n "$line" ]] && SERIAL+="$line " done < "$ROOT/tests/serial-samples.txt" + # At most one of these compiles at a time: three at once run a 16 GB runner out of memory (#590). + while IFS= read -r line || [[ -n "$line" ]]; do + line="${line%%#*}"; line="${line//[[:space:]]/}" + [[ -n "$line" ]] && HEAVY+="$line " + done < "$ROOT/tests/heavy-samples.txt" # The oracle hook (macOS and Windows) is built into a shared directory on first use: build it # before several samples need it at once. platform_oracle_hook || exit 1 fi run_pass() { # opt rep - local opt="$1" rep="$2" name i n=${#selected[@]} next=0 running=0 res + local opt="$1" rep="$2" name i n=${#selected[@]} next=0 running=0 res heavy= if (( JOBS <= 1 )); then for name in "${selected[@]}"; do run_sample "$name" "$opt" "$rep" "$OUT" @@ -316,6 +321,10 @@ run_pass() { # opt rep while (( running > 0 )); do reap; done else while (( running >= JOBS )); do reap; done + if [[ "$HEAVY" == *" $name "* ]]; then + while [[ -n "$heavy" && ! -f "$res/$heavy.rc" && -d "$res/w$heavy" ]] && (( running > 0 )); do reap; done + heavy=$i + fi fi mkdir -p "$res/w$i" (