Skip to content

Faster branch runs and no silent frontend rebuilds - #1956

Closed
joepio wants to merge 1 commit into
developfrom
joep/fast-branch-runner
Closed

joepio wants to merge 1 commit into
developfrom
joep/fast-branch-runner

Conversation

@joepio

@joepio joepio commented Oct 1, 2026

Copy link
Copy Markdown
Member

Requested by Joep

Before: Checking out a branch and getting it running took about 280s cold, and cargo run could sit at Building 1084/1087: atomic-server(build) for 15+ minutes at 0% CPU. A fresh checkout gave every file a new mtime, so build.rs rebuilt the frontend and WASM even when the sources were identical, and the work was silent. Phones and tablets on the LAN failed with "This browser could not open local storage".

After: scripts/run-branch.sh <branch> [--tunnel] builds and serves a branch in its own worktree and target dir, printing a line per phase, and --tunnel gives an https URL for other devices. build.rs decides on a content hash, so identical sources skip the frontend build, and it prints a line on the terminal before the silent step.

The hang was not a slow build: a global build-dir in ~/.cargo/config.toml is shared by every repo and has one lock, so a running cargo run blocked every other cargo, including the one inside wasm-pack. The script and build:wasm now use a private CARGO_BUILD_BUILD_DIR. AGENTS.md documents this, the secure-origin rule (the server derives its login origin from ATOMIC_DOMAIN, and tunnelto breaks the websocket), and the worktree approach.

How: changes are in scripts/run-branch.sh, server/build.rs, browser/data-browser/package.json, AGENTS.md, .gitignore.

Measured on this Mac: cold checkout to 200 was 280s before (pnpm 1s, frontend+WASM 90s, cargo 177s, start 12s) and 264s with run-branch.sh on the canvas branch. Re-running on the same branch is about 32s to a 200 (frontend skipped, cargo 17s). In build.rs, touching a source file without changing it is now skipped by the content hash.

Not included: PR preview deploys (needs a hosting and cost decision, see the thread), and CI target caching. Not tested: --tunnel end to end from a clean state beyond manual runs, and the build.rs notice on terminals without /dev/tty.

…ate cargo build-dir

scripts/run-branch.sh builds and serves any branch in its own worktree and
target dir (optionally behind a cloudflared https tunnel for phones and
tablets). build.rs now decides whether to rebuild the frontend from a content
hash instead of mtimes, so a fresh checkout or branch switch with identical
sources no longer pays minutes for a rebuild, and prints a line on the
terminal before the silent step. The wasm-pack cargo gets a private
CARGO_BUILD_BUILD_DIR: a global build-dir is shared by every cargo and one
running cargo run made every other build block silently at 0% CPU.
@joepio joepio self-assigned this Oct 1, 2026
@joepio

joepio commented Oct 1, 2026

Copy link
Copy Markdown
Member Author

Trekmeester review: one bug before this can be batched. The content-hash stamp lives at server/js-inputs.hash, outside dist. Repro: switch to branch B, run pnpm build by hand, switch back to A, run cargo run. The hash matches A's sources, so build.rs skips the build and embeds B's dist; the old mtime check would have rebuilt. Fix: write the stamp inside browser/data-browser/dist/, which vite's default emptyOutDir clears on any manual build, so it falls back to the mtime check. Or include dist's build time in the stamp. The rest (run-branch.sh, the CARGO_BUILD_BUILD_DIR in build:wasm, docs) looks fine.

joepio added a commit that referenced this pull request Oct 6, 2026
One tested commit for the open PRs of 5 October: link device to account (#1948), one profile form (#1953), faster branch runs (#1956), end-to-end encrypted conversations (#1971), passkey ceremony header (#1972), Flutter account package (#2035), cheap canvas undo (#2053), atomic.place tab title (#2056), table resource cell (#2057), small table fixes (#2058), storage map (#2061), Sync page cloud ladder (#2072), several served-domain suffixes (#2073), one sign-in (#2074), smaller chat messages (#2077), bring-along e2e fix (#2078), inline row data loss (#2079), Retry-After (#2080), #2070, #2071, #2066, #2067, #2068, #1969, #1887, #1897 and #1920.

Compressed stored values from #2077 stay readable, but a downgrade cannot read compressed rows.

Co-authored-by: Joep Meindertsma <joep@ontola.io>
@joepio joepio closed this Oct 6, 2026
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