Commit Graph
4 Commits
Author SHA1 Message Date
Oleg Isonen 9a86222afd perf: Cut Builder E2E shard startup and repeated work (#6705)
The five-worker A/B run (`3d464ec2`, run 43985693015) passed all 61 E2E
cases and every Main check. Full shard jobs took **197, 201, 218, 226,
and 233 seconds** with a warm Builder build cache. Browser phases were
**154, 147, 169, 184, and 186 seconds**, totaling about 18 seconds more
than the four-worker warm run (`6f87754c`, run 43983946199). Five
workers raised CPU scheduling pressure from 72–74% to 77–84%. Four
workers are restored; all five jobs still need to finish under 180
seconds.

The merged-main run (`dfa0fc97`, run 43981570428) passed all **61 E2E
tests** and every Main workflow check. Its cold build cache made each
shard wait about 35–41 seconds for the shared Builder artifact. Full job
times were **285, 246, 227, 202, and 228 seconds**; browser phases were
**196, 154, 138, 116, and 140 seconds**. CPU scheduling pressure was
68–71%, with no memory pressure. A same-SHA rerun hit the Builder build
cache on shard 1: the full job fell to 215 seconds and browser work took
155.9 seconds. Warm setup is cheaper, but shard 1 still misses 180
seconds. The other four jobs have not been rerun warm.

The warm-cache full run on commit `3c0a936d` passed all 60 browser cases
across five fixed shards with three workers. Full jobs took 184, 191,
124, 161, and 190 seconds. Shards 1, 2, and 5 remain 4–11 seconds over
the 180-second target.

Browser phases took 137.5, 140.3, 77.0, 117.4, and 134.0 seconds. Setup
and cleanup added 44–56 seconds. All caches hit, and source checkout
took about 1–2 seconds.

The latest warm-cache run on `8a8f04b4` passed all 60 cases, but browser
phases were 85.9, 129.8, 193.2, 169.9, and 138.4 seconds. Shard 3's
Email binding test alone took 96.8 seconds in this run, versus 50.5 and
59.2 seconds in two earlier runs. This shows the current fixed
assignment is still too uneven and timings vary by run. The third
assignment moved Data variables from shard 1 to 3, Style panel from
shard 2 to 4, and Animation runtime from shard 2 to 5. All 60 cases
passed, but browser phases were 93.7, 150.2, 156.7, 110.6, and 167.2
seconds. Shards 2, 3, and 5 remain above the target once setup is
included. Test times varied sharply from prior runs. Read-only
inspection found no safe material reduction in the 93-second redirect
test or 56-second Asset folder clone test; both use serial state changes
and persistence checks. A separate select-asset-folders test now uses a
direct page reload for its final persistence check, removing an
unnecessary canvas wait. Its focused full-run time changed from 19.9 to
18.8 seconds, but this small result is not a speedup for the slow Asset
folder clone test. The six-move assignment passed all 60 cases on run
43969666884, but browser phases were 166.8, 106.5, 151.5, 183.3, and
123.1 seconds. Only shards 2 and 5 finished under 180 seconds including
setup. The total measured test work was about 1,805 seconds across 15
workers, a 120-second ideal average before scheduling overhead. The
latest run on `b71669bf` passed all 60 cases, with browser phases of
88.4, 123.5, 138.8, 151.4, and 157.1 seconds. Setup added 43–65 seconds.
Only shard 1 finished under 180 seconds for the complete job. The
four-file rebalance reduced the worst complete-job time from about 238
to 209 seconds. Run `66163599` passed all 60 cases; full jobs took about
155, 212, 152, 168, and 173 seconds. Run `1853aef1` also passed all 60,
but jobs were about 180, 157, 203, 166, and 156 seconds; browser phases
were 129, 90, 136, 106, and 103 seconds. Setup and cleanup added 51, 67,
67, 60, and 53 seconds. Shards 1 and 3 missed the 180-second target. CPU
scheduling pressure was 48–62%, with no memory pressure.

Recent changes reduce repeated work and keep the same assertions:
- The variable test uses one saved pre-edit Preview snapshot while
Builder edits and reloads the project on a separate page.
- The two-generation Email test starts from a blank project because it
creates the routes and forms it checks. Both saved production
generations are still built and checked.
- Email delivery forms are authored inside the existing Preview process,
removing a separate Node process start.
- Two shard-3 form tests share one project and production Preview. Their
success/failure results, redirects, browser feedback, scroll behavior,
retry behavior, and saved project redirect checks remain.
- Marketplace settings save both fields in one cycle and keep checks for
each value before and after reload.
- Content-mode rich-text tests save both link edits together while
keeping stored href and link-removal checks.
- MCP form delivery uses a smaller fixture with the same email plan and
Builder permissions; it removes five unused inserts. Warm local timings
were nearly the same.
- The two longest shard-5 cases and the 64-second shard-3 Pages bridge
file moved to lower-load fixed shards. All 60 cases remain assigned
once.
- The shard-3 form-delivery file now sorts earlier so its Preview work
overlaps earlier cases. A local three-worker comparison reduced shard-3
Playwright time from 71.2 to 64.7 seconds.
- The shard-5 callbacks test uses a blank project with its existing
page. It keeps its production Preview and all assertions, removes eight
unrelated database operations, and measured 13.8% faster in focused
local comparisons.
- The shard action starts PostgreSQL and PostgREST image pulls while
pnpm installs dependencies. Both operations still occur; setup and
cleanup still add about 45 seconds.

The latest run (`43990503162`) passed all 61 browser cases, but GitHub
reported full shard jobs of **228/200/176/152/218 seconds**; shards 1,
2, and 5 missed the 180-second target. Hook-aware logs show per-file
work sums of **587/458/358/349/551 seconds**. These are work totals, not
CI wall times, and the two parallel suites on shard 1 made a simple
work-sum rebalance misleading. The current setup change starts and
readies the snapshot database/PostgREST while dependencies install, with
Prisma and Chromium work remaining after installation; its CI saving is
not measured yet.

Run `44008044890` passed all 61 browser cases and five setup tests on
the same fixed assignments after backend setup began overlapping
dependency installation. Browser phases were
**202.5/176.4/81.2/106.7/110.8 seconds**; the full jobs still missed the
180-second goal on the slower shards. Image pulls finished in
4/6/21/8/23 seconds, and only shards 3 and 5 waited after installation
(9 and 14 seconds). The nine-file tag assignment passed all 61 browser
cases and five setup tests in run `44008945736`. Complete shard jobs
took **174.4/125/223.7/161.6/166.2 seconds**; only shard 3 missed 180
seconds. Three more measured file retags move slow serial work from
shard 3 to shards 2 and 4. All twelve tag changes are exact file
renames, so test cases and assertions remain. The final full run on
commit `b9bc8b4` (run `44050045632`) passed all 61 browser tests and
five setup tests. Complete shard jobs, including setup and cleanup, took
**151/132/136/162/144 seconds**; all five finished under three minutes.
The Node/pnpm, Playwright browser, and Builder build caches hit, so no
E2E build artifact polling or download was needed. Each shard still
installs workspace dependencies, starts and readies its local database
services, prepares E2E, runs its assigned tests, and tears services
down. CPU scheduling pressure was 60–68%; memory pressure was 0%. All
workflow checks passed.

### Checklist

- [x] Keep five fixed shards and preserve every test while measuring
worker counts.
- [x] Add timings for generated Preview phases and preserve the logs in
CI.
- [x] Reduce repeated form, variable, and Preview setup without dropping
assertions.
- [x] Compare worker counts and restore three workers after the
two-worker trial increased total test time.
- [x] Manually rebalance fixed shard tags from measured test durations;
discovery confirms all 60 cases run once.
- [x] Review Builder documentation impact; the E2E README describes
fixed, manually measured shard tags.
- [x] Run all five shards on the latest assignment; all 60 browser cases
and all workflow checks passed.
- [x] Check whether slow source checkouts recur; this run's five fetches
took 1–2 seconds, and source caching remains unjustified.
- [x] Optimize shard-5 setup without removing its Preview or assertions.
- [x] Rebalance heavy tests onto lower-load fixed shards, based on
measured durations.
- [x] Overlap image pulls with the dependency install shared by the five
shards.
- [x] Run the full suite on these combined changes; all 60 cases and
workflow checks passed.
- [x] Re-run shard 5 with the Builder build cache warm; it passed in 173
seconds.
- [x] Rebalance measured files across the five shards and verify all 60
cases run once.
- [x] Run all five shards with the Builder build cache warm; four
finished under 180 seconds.
- [x] Move the 61-second data-variable Preview case from shard 1 to
shard 5; all 60 cases remain assigned once.
- [x] Run all five shards on the latest assignments; all 60 cases
passed, but shards 3 (183s) and 5 (212s) remain over 180 seconds.
- [x] Share one generated Preview between shard-5 callback and
legacy-route scenarios; local full-shard A/B improved by 6 seconds with
all assertions preserved.
- [x] Move the data-variable and Form inspector tests from shard 5 to
shard 4, Preview links from shard 5 to shard 1, and content-mode pages
from shard 3 to shard 1.
- [x] Run all five shards on the new assignments; all 60 cases passed,
but shard 4 took 235 seconds.
- [x] Move the 61-second data-variable and 46-second redirect tests from
shard 4 to shard 1, the 79-second Email binding test to shard 5, and the
21-second Slot keyboard test from shard 5 to shard 2.
- [x] Rebalance the four longest test files from the latest CI
measurements while keeping five fixed shards and all 60 cases.
- [x] Run all five shards on that assignment; all 60 browser cases and
workflow checks passed, but full jobs were approximately 144, 188, 247,
212, and 180 seconds. Shards 2–5 remained at or above the 180-second
goal.
- [x] Rebalance measured test files again and verify all 60 cases run
once; full workflow run 43965687329 passed all cases, but several shards
remained over 180 seconds.
- [x] Use four-run medians to rebalance Data variables, Style panel, and
Animation runtime while keeping five shards and three workers.
- [x] Run all five shards on the latest assignment; all 60 cases passed,
but browser phases were 93.7, 150.2, 156.7, 110.6, and 167.2 seconds.
- [x] Replace the unnecessary Builder canvas readiness wait with a
direct reload in the select-and-drag asset folder persistence test;
preserve the post-reload folder assertions. Focused full runs were 19.9s
and 18.8s, including setup; independent review found no coverage or
readiness issue.
- [x] Inspect the slow redirect and Asset folder clone tests; keep their
serial writes and persistence checks because no safe material reduction
was found.
- [x] Rebalance six files against recent and median timings; all 60
browser cases passed on run 43969666884, with full jobs approximately
212, 156, 208, 238, and 176 seconds. Shards 1, 3, and 4 remained over
180 seconds.
- [x] Rebalance Data variables, Content mode assets, Navigator, and Form
redirect files using the latest run. All 60 cases passed on run
43971617077; complete jobs were approximately 149, 191, 191, 209, and
202 seconds.
- [x] Move Navigator (shard 4→1), Form redirect matrix (5→1), and Editor
fragment (2→4). The 66163599 run passed all 60 cases; four full jobs
took 149–171 seconds and shard 2 took 208 seconds.
- [x] Move Share links from shard 2→3 and Author props from shard 2→1.
All 60 cases passed in run `1853aef1`, but shards 1 and 3 remained over
180 seconds.
- [x] Move Email binding from shard 1→2, Browser form preview from shard
3→1, and Share links from shard 3→5. All 60 cases passed, but the latest
run’s browser phases were 184, 145, 129, 89, and 182 seconds. Only shard
4’s full job was under 180 seconds.
- [x] Start DB/PostgREST image pulls before Node/pnpm cache restoration
and installation, preserving timeouts, error propagation, and cleanup.
The next run reported 5–17 seconds total pull time and zero wait after
install on all five shards; setup still varied and the 3-minute goal was
not met.
- [x] Compare three and four Playwright workers on the same five fixed
shards and assignments. Four workers lowered total browser-phase time by
about 13% and lowered the worst full job from 252s to 234s; all tests
passed. Keep four workers for the next balanced run.
- [x] Trial five Playwright workers on the same five fixed shards and 61
cases. Run 43985693015 passed every check with warm-cache full jobs of
197/201/218/226/233s; browser phases were 154/147/169/184/186s. Against
the four-worker run 43983946199 (198/180/224/230/246s full;
147/135/168/182/190s browser), aggregate browser work rose about 18s and
CPU pressure rose to 77–84%. Restore four workers; neither setting met
the 180s target.
- [x] Use run 43986730815's 61 case timings to rebalance whole test
files across the same five fixed shards with four workers. Discovery
found all 61 unique cases once; run 43988555497 passed all five shards
with full jobs of 158/162/224/220/177s. Shards 3 and 4 still miss 180s.
- [x] Overlap snapshot DB/PostgREST preparation with dependency
installation; preserve readiness, errors, and cleanup. Run 44008044890
passed all five shards; only two image pulls required waiting after
installation.
- [x] Add hook-aware timings and rebalance fixed shard tags using runs
43990503162 and 44008044890. All nine file changes are exact renames;
the 180-second whole-job target remains unverified on the new tags.
- [x] Rebalance the five fixed shards from all 61 current case timings
without weakening assertions; run `44050045632` passed all 61 browser
cases and five setup tests, with full jobs at 151/132/136/162/144
seconds and all checks green.
- [x] Validate seeded E2E pages, instances, props, and breakpoints with
existing schemas; preserve the historical Form identity marker and cover
its JSON round-trip. Builder typecheck, focused Vitest, lint,
formatting, and diff checks passed. Reviewed Builder docs; no
documentation changes are needed.
- [ ] Rebalance any shard still above three minutes using the latest
full-run timings while keeping five fixed shards and all tests.
2026-11-17 11:03:04 +01:00
Oleg Isonen baeaab904f perf: Measure and trim Builder E2E setup (#6699)
Builder E2E still misses the three-minute target. The latest warm
ten-shard run passed, but shard 6 took 4:29 from runner start to
completion. This PR remains a draft.

The ten shard jobs took 2:21–4:29. Their test phases took 1:20–3:31 and
their test durations summed to about 4,018 seconds across 136 tests. At
three Playwright workers per shard, that is a 2:14 average lower bound
before roughly 45–60 seconds of runner setup; some shards have much more
work than average. The latest managed Form consolidation passed on shard
7, but that shard still took 4:06. Shard 5 ranged from 4:40 to 3:20
across two warm runs with no shard 5 code change, so a single run is not
evidence of a stable speedup.

This branch caches the compiled Builder for E2E-only changes and commits
the schema snapshot so shards do not repeat migrations. The separate
Supabase migration job still applies all migrations. Each shard now
restores the compiled Builder cache directly. A warm run confirmed the
artifact wait and download were skipped; a miss run confirmed the
fallback. New runners still restore pnpm, Playwright, and Builder
caches, and start a database.

Related Form redirect, Email, feedback, resource, and managed delivery
outcomes now use fewer generated production Previews while retaining
named steps and assertions. Three generated resource tests now share one
project and Preview; the combined test passed in 52 seconds on CI versus
three prior tests of about 76–79 seconds each. The newest managed Form
test combines navigation, two Action delivery, and multipart upload in
one Preview and passed both locally and in CI.

Four workers per shard were tested and reverted: full E2E rose from 4:46
to 5:32, with 57–64% CPU scheduling pressure on several shards and zero
memory pressure. In the latest shard 7 run, seven generated Preview
startups summed to 200 seconds across parallel tests. Repeated Builder
canvas startup and saves dominate other shards. Caching and small test
consolidations are insufficient for the target; the remaining work needs
a test architecture that keeps production Preview and real Builder
coverage while avoiding full compilation or reload for every behavior
case.

### Status

- [x] Measure per-test, key phase, and runner CPU/memory times.
- [x] Cache compiled Builder inputs and commit a schema snapshot while
retaining the full migration check.
- [x] Keep dashboard UI creation coverage while using faster setup in
unrelated tests.
- [x] Fix the MCP Preview redirect observation race with a regression
test.
- [x] Consolidate related redirect, Email, feedback, resource, and
managed Form outcomes while retaining assertions.
- [x] Verify formatting, Builder typecheck, focused local tests, and the
latest warm ten-shard CI run.
- [ ] Diagnose and eliminate intermittent Chromium startup failures
beyond the concurrent Email binding case.
- [ ] Run managed Form callback protocol and browser checks against one
production Preview.
- [ ] Cut repeated Builder and production Preview work enough for every
shard to finish within three minutes.
- [ ] Verify cold and warm ten-shard CI runs under three minutes.

No user-facing documentation or fixture bundle changes are needed.
2026-11-15 20:38:14 +01:00
Oleg Isonen 23c81d64c9 perf: Speed up Builder E2E tests (#6689)
Builder E2E still takes too long. The goal is all 145 cases under 3
minutes end to end, with exactly ten shards and the same UI, MCP, and
generated Preview checks. This PR has not met that goal.

### Measured results
- Initial green CI run: 9m43s from build start to the last shard;
slowest test step 439s.
- Best green run after replacing repeated UI project setup: about 5m35s;
slowest test step 250s.
- Best green run (393e51c): about 4m59s; slowest test step 201s. The
two-file rebalance reduced the prior green run by about 50s. The
3-minute goal remains unmet.
- Latest green run (de2f4ed): about 5m56s; slowest test step 257s. All
ten shards and required workflows passed. The preceding green run took
about 6m09s, showing substantial run-to-run variation.
- The 119 content-mode project setup calls fell from 599s to 23.5s of
aggregate worker time by using the app's dev login and project creation
API. The sum of shard test steps fell from 2,178s to 1,721s in the first
run with this change. Per-shard wall time still varies substantially
between runs.
- The shared build takes about 85s, including roughly 30s of setup and
51s of Builder compilation. During tests, the four-CPU shard runners
showed 27–52% CPU scheduling pressure and 0% memory pressure; peak
memory was unavailable.

### Changes
- Cache the test schema and share one Builder build artifact across ten
shards. Shard setup overlaps the build; each shard still starts an
isolated database.
- Keep real MCP and browser sessions alive for repeated Preview
submissions, and reuse generated Previews where checks can share one.
- Give independent cases separate projects and run them within the
existing shard workers. Keep exactly ten shards.
- Create content-mode fixture projects through the app's normal login
and project API, using its CSRF token. Dedicated UI project creation
remains in the Builder project fixture.
- Capture managed Form responses before fast redirects discard their
bodies. Fix drag targeting and unique drag fixture IDs.
- Report CPU and memory pressure for every shard. Allow the MCP browser
startup enough time under CI load. An earlier shard rebalance worsened
the run and was reverted; a measured two-file rebalance improved the
slowest shard without changing test logic.

### Verification and remaining work
Focused local runs passed for a single project, three projects sharing
one session, a paid-plan MCP project, and the MCP Preview form case.
Builder and Vision typechecks, lint, formatting, the ten-shard matrix
check, and Vision regression tests passed. All required workflows passed
on de2f4ed. The latest review fix also passed all 63 Vision tests,
Vision typecheck, lint, and formatting locally.

- [x] Profile the full suite and measure complete ten-shard CI runs.
- [x] Remove repeated UI project setup from the shared fixture.
- [x] Measure CPU and memory pressure in CI.
- [ ] Reduce Builder interactions, generated Preview work, and build
time enough to finish under 3 minutes.
- [x] Resolve five review threads and verify the affected paths.
- [x] Check authoritative Builder documentation; these test harness and
capture fixes do not change user-facing behavior or documentation.

CI still checks out and installs dependencies, builds Builder, uploads
and downloads its artifact, starts a database for each shard, and runs
real browsers and generated production Previews. Warm caches remove
downloads and schema generation, but do not remove setup, compilation,
browser work, or cache transfers. No product behavior or authoritative
documentation changed.
2026-11-15 17:10:10 +01:00
Oleg Isonen 4273b7001f refactor: Organize Builder development and test tooling (#6285)
## Outcome

Builder development, backend, E2E, and CI tooling now share one
ownership model: Builder defines named commands and backend modes, while
CI only schedules those commands.

## Technical choices

- Group shared Compose files, PostgreSQL initialization, and backend
helpers under `apps/builder/backend`.
- Resolve `compose.<mode>.yaml` by convention instead of maintaining
Compose filename lists in scripts and workflows.
- Keep persistent development and disposable test Compose projects
separate by default, while allowing the standard `COMPOSE_PROJECT_NAME`
override.
- Make schema snapshots invalidate from discovered migration sources and
backend files.
- Move E2E behavior recipes into named Builder commands; retain concise
root proxies for developer entry points.
- Let Vitest allocate available browser ports instead of maintaining a
cross-package port registry.
- Keep test-suite scheduling explicit in `main.yml`, but move executable
test commands to root package scripts.
- Move fixture-size enforcement from inline GitHub JavaScript into a
locally runnable repository script.

## Todo

- [x] Consolidate Builder backend and Compose ownership.
- [x] Add named development, E2E, schema-cache, Supabase, and CI-shard
commands.
- [x] Remove Compose topology and behavior flags from CI.
- [x] Remove the static Vitest browser-port registry.
- [x] Extract fixture-size checking from the workflow.
- [x] Verify migration bootstrap, snapshot-backed E2E, tests, builds,
types, formatting, lint, generated contracts, and workflow syntax.
- [x] Review documentation impact: updated the E2E developer guide; no
user-facing `docs/` content is affected.

## Verification

- Full package, CLI, Builder core, and Builder app test suites
- Full workspace typecheck
- Builder production build
- Schema-cache generation through the complete migration history
- Supabase migration compatibility
- Snapshot-backed Playwright animation workflow
- Backend regression tests, including demonstrated fail/pass coverage
- All four Compose mode configurations
- `oxfmt`, `oxlint`, package boundaries, generated API, and generated
docs checks
- `actionlint` and Bash syntax checks

The fixture-size checker preserves the existing Linux `du` thresholds.
Its three inputs build locally; macOS allocation sizes are not directly
comparable to the Linux CI thresholds, so CI remains the authoritative
size result.
2026-08-31 21:09:54 +02:00