Repository navigation
perf(build): reuse kernel builds across worktrees; add a quick test-only kernel build - #533
Conversation
…nly kernel profile
…p the cache for custom flags; test build-kernel with a fake cargo
|
@coderabbitai full review |
There was a problem hiding this comment.
bompus has reached the 50-credit limit for trial accounts. To continue receiving code reviews, upgrade your plan.
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 22 minutes. View limit details
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
|
Review bots skipped on 8320a70: CodeRabbit review rate limited (review limit reached), cubic out of quota, Greptile out of trial credits. A local review before opening this PR found one blocking defect (a kernel compiled while its sources were being edited could be cached under the clean commit's key) and several smaller gaps; all are fixed in the second commit, with tests that fail on the first version. |
|
The Windows lifecycle failures here are pre-existing timing flakes, not this change. Two runs on this PR timed out in two different runtime-control.test.ts startup tests (MCP readiness at 10 s). Control PR #534, which is the unchanged base with only a comment added to trigger the workflow, failed on Windows the same way in a third test (mcp-writer-lock.test.ts, a hook timed out at 10 s). Linux and macOS passed in all runs. This PR touches only the kernel build scripts and their tests. |
A new worktree gets its native kernel in under a second instead of about two minutes when its kernel sources match a recent build, and a kernel edit can be tested after a 4 s rebuild instead of 90 s.
npm run build:kernelin a new worktree, kernel sources unchangedtarget/target/ensure-kernelbeforenpm test, prebuild missingbuild:kernel:quick)One run each; these are single measurements, not a benchmark claim. The gaps are far outside run-to-run variation.
What changes
scripts/kernel-cache.mjs(new): a per-user cache of release kernel builds, keyed by the kernel source stamp thatensure-kernelalready uses.RUSTFLAGSorCARGO_PROFILE_*overrides is not cached.CODEGRAPH_KERNEL_CACHE, else$XDG_CACHE_HOME/codegraph/kernel(%LOCALAPPDATA%on Windows);=offdisables it.scripts/build-kernel.mjs:--no-cachecompiles anyway.--quickbuilds a newquickCargo profile (no LTO, 16 codegen units, incremental). Its stamp is markedquick, and it is never cached.CARGO_TARGET_DIRis honored. Before, the output path was hard-coded totarget/.scripts/ensure-kernel.mjsrestores from the cache before compiling. It accepts a quick build of the current sources, with a reminder that a quick build is not for measuring.npm run build:kernel:quick.--minWorkers=1 --maxWorkers=8form;--maxWorkersalone errors in vitest 2.--target) and release-workflow builds are unchanged: restore, save and--quickare host-only.Verification (head 8320a70)
__tests__/ensure-kernel-stamp.test.ts, 23 tests. New ones use a fakecargoto coverbuild-kernel.mjs:--no-cache;CARGO_TARGET_DIR;ensure-kernelwithout a toolchain;The mid-build and custom-flag tests fail against the first version of this change and pass now.
Real builds: a release build saved to the cache; a second fresh worktree at the same commit restored it in 0.8 s, and the golden-dump tests passed on the restored kernel.
Full suite: 754 files passed, 40 tests skipped (
vitest run --minWorkers=1 --maxWorkers=8).ensure-kernelrestored a stale prebuild from the cache during one run and rebuilt-and-saved during the other.Windows: the cache unit test is not gated by platform, but the fake-cargo tests are POSIX-only (shell-script cargo). Not run on Windows.
README rows checked: none apply (developer build tooling; no user-visible feature, command or quoted number).
Summary by cubic
Caches plain release kernel builds per user so a new worktree with unchanged kernel sources restores the prebuild in under a second instead of recompiling for ~two minutes, and adds an unoptimized
quickbuild (npm run build:kernel:quick) that rebuilds after a one-line edit in ~4 s instead of ~90 s.Details:
CODEGRAPH_KERNEL_CACHE(or the platform cache dir;=offdisables it).RUSTFLAGS/CARGO_PROFILE_*builds bypass it, andbuild:kernel --no-cachecompiles without it.ensure-kernel.mjsand host release builds restore from the cache before compiling.CARGO_TARGET_DIRnow write there instead of hard-codedtarget/.ensure-kernelaccepts a quick build of the current sources and warns not to measure performance with it.Written for commit 8320a70. Summary will update on new commits.