Skip to content

Cut polling/auth round trips; stop E2E timing out in CI - #29

Merged
ellmkay merged 2 commits into
fix/map-tile-cold-render-performancefrom
perf/polling-and-auth-round-trips
Sep 24, 2026
Merged

ellmkay merged 2 commits into
fix/map-tile-cold-render-performancefrom
perf/polling-and-auth-round-trips

Conversation

@ellmkay

@ellmkay ellmkay commented Sep 24, 2026

Copy link
Copy Markdown
Contributor

Stacked on #28 (base branch); GitHub retargets to main when that merges.

Summary

Commit 1 — performance sweep (docs/perf-polling-and-auth-round-trips.md). Follow-up to the Cloud Run log review: the recurring slow endpoints were all polls or per-request plumbing.

  • competition.counterState (every 5 s/tab): 9 sequential queries → 1 statement with scalar subselects.
  • competition.dbStatus (every 3 s/tab, public): 3 queries → 1; pg_database_size() memoised 60 s (ttl-memo.ts).
  • assertRestAccess now returns the resolved EventRef so handlers stop looking the slug up twice; countFinishedRunners only runs when it can change the capability set (finishedCountMatters — date already past or grants already cover the completion caps ⇒ skip). Semantics unchanged.
  • /api/maps/:nameId/window.png rasterises under the shared renderGate() with the same 503/Retry-After behaviour as tiles, so layout previews can't stack on top of MAP_RENDER_CONCURRENCY tile renders.
  • course.controlCompletionStatus (every 15 s) loads only the requested course's runners and the cards they carry; one regex per control.
  • Also widened one async wait in online-input-config.spec.ts that was flaking under load.

Commit 2 — CI E2E failures. Every main run since #26 has failed the E2E job (blocking publish). All failures were timeouts: four full stacks on a 4 vCPU runner ran each shard at half speed (6–10 min vs 3–5 locally).

  • scripts/e2e-sharded.mjs: default shard count is now min(4, floor(cores/2)) — 4 on a dev box, 2 on a GitHub runner. E2E_SHARDS still overrides.
  • phase2.spec.ts create/edit/delete: names and card number derive from testInfo.retry, so a slow first attempt no longer leaves a runner that makes every retry hit the duplicate-card dialog (the one deterministic failure in all three runs); list waits raised to 15 s.
  • The two course-editor tests that hit the 30 s test timeout on every CI run are marked test.slow().
  • docs/e2e-sharding.md and AGENTS.md updated.

Test plan

  • pnpm build, pnpm test (612 api / 867 web / 292 shared)
  • Integration: 339 passed (new: finishedCountMatters table, ttl-memo, counterState keys + oClub semantics, control-completion suite — which also passes against the previous implementation)
  • Full E2E, default shards: 274 passed
  • Full E2E, CI=1 E2E_SHARDS=2 (runner-shaped): 275 passed, 0 flaky
  • Docker oxygen-api / oxygen-web rebuilt and started
  • Watch this PR's E2E job: expect "across 2 shards" in the log and a green run

Made with Cursor

marcus-kempe and others added 2 commits September 24, 2026 22:13
counterState and dbStatus each become one statement (the database size
is memoised for a minute), the REST guard hands back the event it
resolved instead of handlers looking it up again, the finished-runner
count only runs when it can change the capability set, the course-map
window preview shares the tile render gate, and controlCompletionStatus
loads only the requested course's runners and their cards.

Co-authored-by: Cursor <cursoragent@cursor.com>
Four full stacks on a 4 vCPU runner ran every shard at half speed and
pushed 5 s expect budgets over; the shard count now follows the core
count. The runner create/edit/delete test derives its name and card
from the retry index so a slow first attempt cannot turn into a
duplicate-card dialog on retry, and the two long course-editor tests
declare themselves slow instead of racing the 30 s test timeout.

Co-authored-by: Cursor <cursoragent@cursor.com>
@ellmkay
ellmkay merged commit 5c3a910 into fix/map-tile-cold-render-performance Sep 24, 2026
4 checks passed
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.

2 participants