perf(e2e): template workspace and scope setup instead of spawning bit - #10672
Conversation
bit init, bit init --bare and bit remote add write a handful of small files but pay the full bit bootstrap to do it, ~3,300 times per suite run. Run the real command once per mocha process into a template dir, then copy it and rewrite the few values init derives from the target path. Output is byte-identical. BIT_E2E_NO_SETUP_TEMPLATE=1 restores the real commands.
PR Summary by QodoSpeed up E2E setup with lazy workspace and scope templates
AI Description
Diagram
High-Level Assessment
Files changed (2)
|
Code Review by Qodo
1. Format SCOPE_JSON_CANDIDATES declaration
|
|
Code review by qodo was updated up to the latest commit 81298bb |
…d (revert before merge)" This reverts commit 81298bb.
|
Code review by qodo was updated up to the latest commit 608da5c |
bit init,bit init --bareandbit remote addeach write only a handful of small files, but every call pays the full bit bootstrap to do it. Across the suite that is ~3,340 calls per run (1,243 workspace inits, 814 bare inits, 1,286 remote-adds) — the largest block of process spin-up that isn't testing anything.Instead of hardcoding a fixture that would rot the moment
bit initchanges, the first setup call in each mocha process runs the real command into a template dir; every later call copies that dir and rewrites the only valuesbit initderives from the target path — the workspace name in workspace.jsonc, and the local scope name<basename>-local-<random>. The bytes always come from thebit initof the version under test.bit remote addhas no dir to copy, but it only setsremotes[<remote scope name>] = <url>in scope.json, which is written directly.Measured on CI (controlled A/B)
Same branch, same test set, same 40-node packing — the control arm was produced by a temporary commit setting
BIT_E2E_NO_SETUP_TEMPLATE=1in the e2e_test job, since comparing across branches has burned us before. Sum of the "Run e2e tests" step across all 40 nodes:~29 machine-min / 7.9% per run, median node -7.1%.
Locally, per file: deprecate.e2e.ts 140s -> 128s with bit spawns 162 -> 124, and tag-harmony.e2e.ts 342s -> 305s.
Fidelity
Verified the templated output is byte-identical to the real commands: 12 entries for a workspace, 4 for a bare scope, and scope.json identical after
remote add.These paths keep running the real command:
initGit(a real.gitmoves the scope to.git/bitand suppresses AGENTS.md),interactive/generatePackageJson(different branches in create-consumer),--globalremotes, and any case where scope.json isn't where expected — most importantly before bit has auto-created a scope, whichgit-worktree.e2e.tsexercises deliberately by usingaddRemoteScopeas the first bit command in a worktree.BIT_E2E_NO_SETUP_TEMPLATE=1restores the real commands everywhere, for A/B measurement or to rule the templates out when a test misbehaves.