Skip to content

unit-pure shards: two bun processes, fresh timings - #2423

Merged
neuromechanist merged 8 commits into
devfrom
fix/issue-2351-shard-hang
Nov 26, 2026
Merged

neuromechanist merged 8 commits into
devfrom
fix/issue-2351-shard-hang

Conversation

@neuromechanist

@neuromechanist neuromechanist commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #2351.

Root cause

The shard does not hang on a test: the runner runs out of memory. A bun --parallel worker keeps the memory of every file it has run (each file gets a fresh global under --isolate, and the old ones are not given back), so a worker's memory grows with the number of files it runs, fastest in the tail of short files that bun schedules last. The stale test/unit-pure-timings.json made shard 1 by far the largest: bun weighs a file the table does not name as almost nothing, and 262 of the 1012 pure files were missing from it, so they all landed in shard 1 (466 of 992 files, against 26 to 187 in the others).

Evidence:

  • The three cancelled jobs of 2026-11-26 (140030879314 in run 45854948481, 140071594514 in run 45866731179, 140186613129 in run 45901025822) all stop about 5.5 to 6 minutes into the test step, each in a different file (identifier-screen-flow, data-integrity-sweep-route, mail-screening), after 295 to 369 of their 466 files. No test fails and nothing is printed after the cut; the second ends ##[error]Process completed with exit code 143. and The runner has received a shutdown signal, 12 s after its last test line and 18 minutes before the time limit. A test waiting on a socket would leave the runner alive and reporting; this is the runner itself going away.
  • This PR's first commit added a memory sampler to the step. On run 45905930817 (rebalanced, still one bun process per shard), shard 2's two bun workers reached 13,461 MiB used of 15,983, and shard 1 climbed from 2,881 to 8,570 MiB in its last 30 s while about 250 short files ran (two bun workers at 4,305 and 3,293 MiB).
  • Locally, each of the heaviest files alone peaks at about 1.1 to 1.3 GB (manifest-source, compute-end-callers, data-route-manifest-stream, compute-runner-end-callers), and the 250 shortest files of shard 1 alone filled a 3.8 GB Linux container (bun 1.4.3, two workers). Forcing Bun.gc(true) after every file did not change that, so the memory is retained, not uncollected.

Fix

  1. test/unit-pure-timings.json is refreshed from two green runs (45885080028 and 45866731179, mean per file), covering all 1012 pure files. test/ci-tier-routing.unit.test.ts now fails when a pure file is missing from the table, when the table names a file that is not a pure test file, or when an entry is not a positive whole number of milliseconds; it also checks that both shard matrices pass the table to --timings. The refresh note above unit-pure-shard gives the averaging command.
  2. Each shard runs as two bun processes in sequence: parts 2k-1 and 2k of a 2N bun shard split, balanced on the same table. On bun 1.4.4 the 12 parts nest inside the old six slices; that is an observation, and the checks do not rely on it: they hold each part to its own header and summary, and the gate holds the union across shards to the classifier's list. Every guard (header, summary, pass count, assigned vs ran, discovered vs classifier, non-empty) is kept per part and on the sum, and both parts run even when one fails or leaves no summary. The timings of the two parts are merged into the artifact's timings.json as before; the junit reports are uploaded per part as junit-1.xml and junit-2.xml, not merged. The same change is made in deploy-backend.yml's test-gate-shard, which runs the same file sets.
  3. The step prints the runner's memory every 15 s ([memory] used ... largest: ...) to the log, where it survives a runner that dies, and keeps it in the shard artifact as memory.txt.

No test was changed, skipped or given a longer timeout.

Shard timings

shard before (run 45866731179, attempt 2) after (run 45907601198) peak memory used, after
1 466 files, 8 min job (25 min when cancelled) 142 + 183 files, 117 + 101 s, 4.5 min job 5,046 MiB
2 183 files, 4.3 min 144 + 134 files, 154 + 137 s, 5.9 min job 8,005 MiB
3 146 files, 5 min 139 + 50 files, 142 + 102 s, 5 min job 2,057 MiB
4 41 files, 2.8 min 9 + 77 files, 192 + 147 s, 6.5 min job 3,116 MiB
5 47 files, 3.5 min 12 + 14 files, 114 + 111 s, 4.5 min job 1,695 MiB
6 109 files, 7.3 min 60 + 48 files, 113 + 114 s, 4.6 min job 1,984 MiB

The summed per-file durations per shard are now 469 to 537 s (were 239 to 852 s). The worst shard now peaks at half the runner's memory where one had reached 84%.

Tests

  • bun test test/ci-tier-routing.unit.test.ts (119 pass; with the old table it fails on the 262 missing files, the stale entries and a zero entry)
  • bun test test/workflow-yaml.test.ts and the other workflow-reading suites (191 pass)
  • The extracted shard step run on a stub tree of the 1012 paths: six shards, every file exactly once, timings and junit merged; a failing file in part 1 still runs part 2 and exits 1
  • bun run typecheck, bun run lint, actionlint (no new findings)
  • CI on this branch: run 45907601198 green, all six shards, timings above (round-1 fixes: see below)

Found on the way, not changed here

  • backend/test/compute-pipeline-input.test.ts picks dataset ids at random (freshId, line 135), and two of them collided once locally (UNIQUE constraint failed: datasets.dataset_id in "a Zarr input digest is stored only when the record shows it covers every store").

Review round 1

  • Important 1, the memory sampler could die silently under the inherited set -euo pipefail and a SIGPIPE from ps into head: the subshell now starts with set +e +o pipefail and awk reads all of ps's output (35efdca).
  • Important 2, a part that left no header or summary exited before the next part ran: it is recorded, the step fails after the loop, and the summed counts are checked after the loop, in both workflows (72fb8a6).
  • Suggestion 3, junit reports are uploaded per part and not merged: the comment and this description say so (72fb8a6).
  • Suggestion 4, sampler cleanup now also ends the in-flight sleep with pkill -P (35efdca).
  • Suggestion 5, the scrub refresh note's wrong claim is replaced and points at the averaging recipe; test/scrub/timings.json, which missed three suites, is refreshed from runs 45907601198 and 45905930817 (slowest of five slices 721 to 585 s of summed time), and ci-tier-routing now checks its coverage (2b06629).
  • Suggestion 6, the suite size is the measured 1,012 files and about 28,500 tests (02dffa6); the redundant --timings match is dropped, and a new test fails when either matrix stops running two $part/$parts bun processes, mutation-checked by reverting test.yml to one process (2b06629).
  • Merged origin/dev (6aa188b); the PR diff touches only .github/workflows/test.yml, .github/workflows/deploy-backend.yml, test/ci-tier-routing.unit.test.ts, test/unit-pure-timings.json and test/scrub/timings.json.

test/unit-pure-timings.json was a month old and missed 262 of the 1012 pure files. bun weighs an unnamed file as almost nothing, so they all landed in shard 1 (466 of 992 files). The table is now the mean of two green runs (45885080028, 45866731179) and ci-tier-routing.unit.test.ts fails when a pure file is missing from it or it names a file that is gone. Tested: bun test test/ci-tier-routing.unit.test.ts (119 pass).
A shard whose runner runs out of memory goes silent until the time limit instead of failing (#2351). Print free memory and the largest processes every 15 s to the log and keep them in the shard artifact. Also corrects the refresh note for the timings table.
@github-actions

github-actions Bot commented Nov 26, 2026 •

Copy link
Copy Markdown

📦 Package Preview

Your package is ready to test!

bun install -g nemar-cli@PR2423

Version: 0.10.41-PR2423.02dffa6
Commit: 02dffa6


🤖 Updated on each push.

A bun worker keeps the memory of every file it ran. On the 16 GB runner shard 1's workers climbed from 2.9 to 8.6 GB over its last ~250 short files (run 45905930817), and the old 466-file shard 1 ran out of memory, which hangs the job until its limit (#2351). Each shard now runs bun's parts 2k-1 and 2k of a 2N split one after the other, keeps every guard per part, and runs both parts even when one fails. Same change in deploy-backend.yml's test-gate. Tested: the extracted step on a stub tree (all six shards, 1012 files once each; a failing part exits 1 after both run); ci-tier-routing and workflow-yaml tests pass.
@neuromechanist neuromechanist changed the title unit-pure shards: refresh timings, log memory unit-pure shards: two bun processes, fresh timings Nov 26, 2026
@neuromechanist
neuromechanist marked this pull request as ready for review November 26, 2026 23:01
Review round 1 of #2423: the sampler subshell inherited set -euo pipefail, so a failed command or a SIGPIPE from ps into head could end it silently. It now turns both off, awk reads all of ps's output, and cleanup also ends the sampler's in-flight sleep. Tested: the extracted sampler with stand-in free and ps prints every interval and leaves no process.
Review round 1 of #2423: a part whose bun run printed no header or summary exited the step before the next part ran. It is now recorded and the step fails after the loop, which also refuses an empty sum over the parts. Same in deploy-backend.yml's test-gate. The comments now say the junit reports are uploaded per part, not merged, and that the nesting of the 12 parts in the old slices is an observation the checks do not rely on. Tested: the extracted step of both workflows on a stub tree, green and with a part whose worker exits; both parts run and the step exits 1.
Review round 1 of #2423: test/scrub/timings.json missed three suites (identifier-dates, git/canonical-key, git/location-logs-at). It is refreshed as the mean of runs 45907601198 and 45905930817, which moves the slowest of five slices from 721 to 585 s of summed time, and the scrub refresh note no longer says an unnamed file is only balanced less well. ci-tier-routing now fails when a scrub suite is missing from that table or it names a file that is gone, and when either pure shard matrix stops running two bun parts of a 2N split (mutation-checked: reverting test.yml to one --shard per job, and dropping a scrub entry, each fail one test). The redundant --timings match is gone. Tested: bun test test/ci-tier-routing.unit.test.ts (123 pass).
Review round 1 of #2423: 1,012 files and about 28,500 tests (run 45907601198), not 650 and 17,000.
@neuromechanist
neuromechanist merged commit 9bf7f61 into dev Nov 26, 2026
31 checks passed
@neuromechanist
neuromechanist deleted the fix/issue-2351-shard-hang branch November 26, 2026 23:22
neuromechanist added a commit that referenced this pull request Nov 27, 2026
dev's ci-tier-routing check fails on 18 decide-lane files (#2397 merged after #2423). Values copied from #2425, which adds the same entries to dev, so the two merge cleanly.
neuromechanist added a commit that referenced this pull request Nov 27, 2026
Dates 0.10.42, adds the 18 pure test files #2397 added to the timings table, records #2423, and makes the upstream-ack audit assertion order-independent.
@neuromechanist neuromechanist mentioned this pull request Nov 27, 2026

This branch was previously deployed

1 inactive deployment
npm — 02dffa61 Deployed Nov 26, 2026 by neuromechanist via publish #5018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant