Skip to content

Refresh realm-server shard weights from every push to main - #6004

Closed
backspace wants to merge 2 commits into
mainfrom
cs-12753-realm-server-shard-weights-have-no-automated-refresh
Closed

Refresh realm-server shard weights from every push to main#6004
backspace wants to merge 2 commits into
mainfrom
cs-12753-realm-server-shard-weights-have-no-automated-refresh

Conversation

@backspace

Copy link
Copy Markdown
Contributor

Linear: CS-12753

What

packages/realm-server/tests/test-module-timings.json drives duration-weighted sharding (#5966) but nothing regenerated it. This adds the automated refresh the matrix and host suites already have, and fixes what finding the stale files turned up.

Commit 1 — the refresh

  • New realm-server-shard-timings-update job in ci.yaml: push-to-main only, runs after the shards finish (success or failure), downloads the run's own realm-server-test-report-merged, regenerates behind a drift gate, and commits Update realm-server shard timings [skip ci] with the same staleness guard and reset-and-retry push as its siblings. A main push run is representative here: realm-server CI has no Percy and no index cache, so no run selection is needed (unlike CS-12582 for host).
  • generate-test-module-timings.mjs gains --min-drift-seconds / --shard-count. Unlike the matrix and host generators, the prediction packs with the real splitter (shard-test-modules.cjs now exports slowestShardSeconds) instead of a mirrored copy that has to be kept in step.
  • All three refresh jobs' staleness guards now ignore each other's automated commits. The host job only ignored its own.

Commit 2 — files the shards were packing that never ran
tests/index.ts loads a hand-maintained list; the splitter walks the disk. Three files were on disk but not in the list, so they were assigned to shards that never loaded them and passed CI by never running: load-links-batching-test.ts (May), server-endpoints/delegate-session-test.ts (June, still written for the qunit CLI: named qunit import and __filename), and shard-assignment-test.ts from #5966 itself. All three are now listed, the sharding test pins the list against the disk, and delegate-session-test is brought up to the native runner. Whether the two older files pass against the CI stack is what this PR's CI run will tell us; locally they fail only on reaching the stack.

Threshold, from real reports

Two merged reports from consecutive runs of the #5966 branch, packed six ways with the actual splitter:

packed with → costed with slowest shard improvement
committed weights → run A 810s → 717s 93s
committed weights → run B 829s → 705s 124s
run A → run B (jitter) 731s → 705s 26s
run B → run A (jitter) 758s → 717s 41s

60s separates a stale file from jitter, and matches the host and matrix jobs.

Found along the way, not fixed here

The TEST_MODULES filter in tests/index.ts builds ^(?:file)(?:\s>\s|:), so a module titled basename | qualifier never matches. cpu-profiler-affinity-gate-test.ts and prerender-artifact-sink-test.ts have only such modules and run zero tests in CI; second modules like node-realm-test.ts | file stat are skipped too. Both reports confirm it: no suite name contains |. One alternation fixes it but would start running tests that have not run for months, so it wants its own issue.

Verification

  • Generator against both real reports: 100% attribution; the gate rewrites at 93s, skips at 26s, and exits 1 without --shard-count, on --shard-count 0, on a non-numeric threshold, and with no report.
  • shard-assignment-test.ts locally: 9/9, including the two new tests.
  • eslint, prettier, ember-tsc --noEmit, and yamllint (.github/.yamllint.yml, strict) all clean; actionlint reports nothing in the new job.
  • The refresh job itself only runs on main, so its first real exercise is the merge.

🤖 Generated with Claude Code

backspace and others added 2 commits September 3, 2026 15:07
CS-12731 (#5966) packs realm-server test files by measured duration, but
nothing regenerated the weights it committed: a human had to download a
merged junit report and run the generator. A day later twelve of 195
files were unmeasured, five of them added since the weights were seeded.

A push-to-main job now downloads the run's own merged report and commits
the regenerated file, in the shape the matrix and host refreshes already
have: a staleness guard against newer commits on main, reset-and-retry
around the push, [skip ci] on the commit, and success-or-failure
triggering so a flaky week does not freeze the weights. Realm-server CI
has no Percy and no index cache, so a push run and a PR run are the same
shape and no run selection is needed.

The generator gains the --min-drift-seconds / --shard-count gate the
other two have, so run-to-run jitter does not become a commit per push.
Unlike those, its prediction packs with the real splitter —
shard-test-modules.cjs exports slowestShardSeconds — rather than a copy
that has to be kept in step. Measured on two consecutive runs of one
branch, jitter moved the predicted slowest shard by 26s and 41s; the
day-old committed weights cost 93s to 124s. The threshold is 60s.

All three refresh jobs now ignore each other's automated commits in
their staleness guards. The host job only ignored its own, so a matrix
timings commit landing mid-run would have made it skip.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
tests/index.ts loads a hand-maintained list while the splitter walks the
disk, and nothing compared the two. A file in the second and not the
first is assigned to a shard that never loads it, so it passes CI by
never running. Three were in that position: load-links-batching-test.ts
(added in May, never listed), server-endpoints/delegate-session-test.ts
(added the day after the suite moved to native Node, still written for
the qunit CLI), and shard-assignment-test.ts from #5966 — so the test
pinning the sharding invariants had never run in CI. The weights
generator listing them as unmeasured was the only signal.

List all three, pin the list against the disk from the sharding test,
and bring delegate-session-test.ts up to the native runner: a named
qunit import Node cannot read from the CJS package, and __filename,
which does not exist in ES module scope. Whether the two older files
pass against the CI stack is for CI to say; locally they fail only on
reaching it.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 3, 2026

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review Completed 2026-09-03T19:11:24.715875Z aeb43ef PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@backspace

Copy link
Copy Markdown
Contributor Author

Closing as a duplicate. #6002 (stacked on #5996, CS-12759) was already open for CS-12753 when this was started, and covers everything here. The two small things this had that #6002 lacked — printing the unmeasured-files list before the drift gate so gated runs still report it, and the shard-count cross-reference on the realm-server-test matrix — are being ported onto #6002.

@backspace backspace closed this Sep 3, 2026
@backspace
backspace deleted the cs-12753-realm-server-shard-weights-have-no-automated-refresh branch September 3, 2026 19:29
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