perf(dev): cache cargo build by fork-tree fingerprint (bd openlock-b5k)#45
Merged
Conversation
In dev mode (openshell-fork/.git present), every startGateway re-entered 'cargo build --release' for openshell-server / openshell-sandbox. Even with incremental builds, release relinks after an upstream rebase or build-script mtime churn burn 10-30s+. Since the gateway stops when no sandbox sessions remain, this hit every new session. Wrap buildFromSource with a fingerprint-keyed cache: - fingerprint = sha256(git rev-parse HEAD + git diff HEAD + untracked names) - cache layout: ~/.cache/openlock/dev-bin/<fp>/<binName>[-target] - OPENLOCK_REBUILD=1 forces a rebuild (escape hatch) - prod (ensureFromRelease) path is unchanged Smoke-tested: cold build 190s, subsequent calls 74ms.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
openshell-fork/.gitpresent),getGatewayBinary/getSupervisorBinarywere callingcargo build -p ... --releaseon everystartGateway— and since the gateway stops when no sandboxes remain, that hit every new session. Release relinks after an upstream rebase or build-script mtime churn burned 10-30s+.buildFromSourcewithbuildFromSourceCached: fingerprint the fork tree (git rev-parse HEAD+git diff HEAD+ untracked names → sha256), key a per-fingerprint cache under~/.cache/openlock/dev-bin/<fp>/<binName>[-target], copy the release artifact in on first build, return the cached path on subsequent calls.OPENLOCK_REBUILD=1forces a rebuild. The prod (ensureFromRelease) path is untouched.Verification
Using cached openshell-gateway (5bcd603cc8f7912c))bun run typecheck,bun run lint,bun run knip: clean.bun test: same baseline asmain(1 pre-existing unrelated failure from a vendored z3 test underopenshell-fork/target/).Test plan
openlocksession; observeBuilding openshell-server...once, thenUsing cached openshell-gateway (...)on subsequent gateway starts.OPENLOCK_REBUILD=1 openlock ...rebuilds even on cache hit.openshell-sandboxdirectly (no zigbuild); Mac dev path still uses zigbuild + linux target.Closes openlock-b5k.