Fast Iteration & Build-Speed Guardrails
Practical workflows for fast Rust toolchain iteration, fast
.tn application development, and the guardrails that
keep builds and the gate fast.
For test authoring rules and focused test commands, see docs/testing.md.
Fast Rust toolchain iteration
Use the smallest command that answers your question:
cargo check --workspace # fast syntax/type check without linking
cargo test --bin tenon <filter> # run one Rust unit-test module/test
make dev-fast # cargo build --profile dev-fast --bin tenon -> target/dev-fast/tenon
make check-fast # TENON_CHECK_FAST=1 scripts/check.sh (workspace tests + fmt-check)
scripts/gate.sh --fast --quiet # inner-loop gate tier (never cached as a full pass)
scripts/gate.sh --quiet # cached full gate (reuses clean tree + toolchain pass)
Profiles and workspace layout
crates/tenon-assets: leaf crate owning static embedded data (MEMBERS_2026bundled plugins, vendoredsqlite3.c/sqlite3.h, and the 28RUNTIME_HEADERS). RootCargo.tomlsetsopt-level = 0fortenon-assetsunder both[profile.test]and[profile.dev-fast]so LLVM never spends time optimizing static byte arrays.crates/tenon-frontend: pure frontend library (lexer, parser, AST, compact~1codec, diagnostics, formatter) shared bytenon-compiler,tenon, andtenon-codecso frontend modules are compiled once instead of duplicated across binaries.crates/tenon-compiler: core compiler, interpreter, region/ownership analysis, C codegen, driver, build caches, editions, and package/registry engine. Kept separate from the CLI binary so CLI/tooling edits only recompile the thintenoncrate.crates/tenon: thin CLI/tooling binary crate (tenon,tenon-codec,app_launcher,app_test,plugin_kit,doc_card,edit,fix,doctor,release, etc.) depending ontenon-compiler,tenon-frontend, andtenon-assets.[profile.dev]and[profile.test]: usedebug = "line-tables-only"(preserving exactfile:linepanic backtraces while cuttingtarget/size and link time).[profile.test]setsopt-level = 0for the thintenonCLI crate andtenon-assets, while overridingtenon-compilerandtenon-frontendtoopt-level = 1so compiler-heavy tests stay fast without slowing down CLI incremental rebuilds.[profile.dev-fast]: inheritsdevwithopt-level = 2,debug = 0, andincremental = true. Build it viamake dev-fastwhenever you need a fast localtenonbinary (e.g. runningtenon interpor repeated.tnbuilds) without waiting on a full--releasebuild.- Dev build provenance gating
(
crates/tenon/build.rs): debug and test builds emitTENON_BUILD_COMMIT=devandTENON_BUILD_DATE=devand intentionally do not emitcargo:rerun-if-changedon.git/HEADor branch refs. Ordinary commits never trigger a rebuild ofcrates/tenon. Release builds (--release) or an explicitTENON_RELEASE_COMMIT(and optionalSOURCE_DATE_EPOCH) enable full git provenance stamping.
Multi-worktree and parallel agent lanes
- Cargo holds an exclusive lock on
CARGO_TARGET_DIR. Pointing multiple concurrent worktrees at the sameCARGO_TARGET_DIRserializes builds and stalls parallel lanes. - Prefer each worktree's own
target/directory for concurrent lanes. If you want shared artifact reuse across worktrees without target-dir lock contention, configureRUSTC_WRAPPER=sccacheinstead of sharingCARGO_TARGET_DIRacross simultaneous builds.
Fast .tn
application iteration
Work in a tight inner loop before compiling a release binary:
- Check first (
~25–45ms):tenon check <file.tn>runs the frontend only (parse + typecheck, no C compiler). - Interpret for quick logic checks:
tenon interp <file.tn>. For heavy interpreter workloads or scripts, run a release binary ortarget/dev-fast/tenon(make dev-fast) rather than an unoptimized debug binary. - Compile & run with
--dev:tenon build --devandtenon run --devcompile inBuildMode::Dev(-O0/ TinyCC when installed; pass--dev --releaseto override back to-O2) and benefit from four build-time accelerators:- Deduplicated compiler probes:
cc --version/tcc --version,pkg-configprobes (fail-closed on env/search-dir/.pcchanges), and tool lookup results are cached (crates/tenon-compiler/src/build_cache.rs,crates/tenon-compiler/src/driver.rs). - Native build cache (
Cache): identical compiled programs hit~/.cache/tenonand skip invoking the C compiler entirely. - FFI object & library cache
(
FfiCache): caches FFI builds on both Linux and macOS (including vendored SQLite object compilation and cross-platform link-library discovery). On macOS (ffi-cache-macos-v2), pre-stage cache hits verify inputs before creating aTempDir, extracting vendored SQLite, or running system-header probes, keeping repeat SQLite and TUI FFI hits fast. - Cached C runtime acceleration
(
crates/tenon-compiler/src/driver/runtime_pch.rs): for uncached native GCC/Clang builds, compiles coreruntime/headers once into a cachedtenon_rt.oand precompiled header (.pchon Clang,.gchon GCC).tenon emit-cstays 100% self-contained C and never depends on PCH. TinyCC remains the fast default for non-FFI dev builds when installed.
- Deduplicated compiler probes:
- Batch formatting: use
tenon fmt [--check] <path...>ortenon fmt --check --stdin0(NUL-delimited paths, as used byscripts/fmt-check.tn) to check or format many files in a single process.
Useful environment knobs
| Variable | Effect |
|---|---|
TENON_NO_CACHE=1 |
Bypass executable, FFI, and runtime PCH caches (forces direct uncached C compilation) |
TENON_CACHE_DIR=<path> |
Override the cache root (default:
$XDG_CACHE_HOME/tenon or
~/.cache/tenon) |
TENON_CACHE_MAX_MB=<N> |
Set the build-cache LRU size limit in MiB (default:
2048) |
TENON_FAST_CC=0 |
Opt out of the TinyCC dev default (an explicit
CC=gcc or CC=clang also wins) |
TENON_SQLITE=system |
Link system -lsqlite3 instead of compiling the
vendored SQLite amalgamation |
TENON_RELEASE_COMMIT=<sha> |
Stamp explicit release commit provenance in
crates/tenon/build.rs (pairs with
SOURCE_DATE_EPOCH) |
TENON_QUIET=1 |
Same as scripts/check.sh --quiet (prints
check: OK + log path, or failing step summary) |
TENON_TEST_BUDGET_SECONDS=<N> |
Override scripts/check.sh unit-test runtime
budget (default: 120) |
Anti-regression guardrails
Do not undo these speedups when adding features, tests, or scripts:
- No
.gitwatching or large static assets incrates/tenon: Never add.gitrerun-if-changedlines or multi-MBinclude_bytes!/include_str!payloads tocrates/tenon. Keep static assets incrates/tenon-assets(withopt-level = 0in test/dev-fast profiles) and keep git provenance stamping gated behind release builds orTENON_RELEASE_COMMIT. - Keep the 4-crate split (
tenon-assets,tenon-frontend,tenon-compiler,tenon) anddebug = "line-tables-only"intact: Do not duplicate modules across binaries (tenon-codecmust reusetenon-frontend), do not pull CLI/main handlers intotenon-compilerorplugin_kit, keep[profile.dev]/[profile.test]atdebug = "line-tables-only", and keep[profile.test]atopt-level = 0withtenon-compiler/tenon-frontendatopt-level = 1. - Batch CLI invocations; never spawn
tenonper file in shell loops: Usetenon fmt --check --stdin0or multi-path CLI arguments (tenon fmt --check path1 path2 ...) instead of per-file subprocess loops. - Keep
scripts/check.shfree of redundant builds, consolidated, and parallel-safe: Never re-add a fullcargo buildstep toscripts/check.sh(cargo test --workspace --no-runalready builds a fresh$target_dir/debug/tenonviaCARGO_BIN_EXE_tenon, andcargo clippy --workspace --all-targetsalready checkstenon-codec). KeepTENON_CHECK_FAST=1(make check-fast/scripts/gate.sh --fast) scoped to workspace tests +fmt-check.tnwith its fast-tier banner and never cached as a full pass. Keep Rust integration tests consolidated incrates/tenon/tests/integration.rs(one compiled/linked test binary with parallel-safe temp dirs) instead of adding separatecrates/tenon/tests/*.rscrates, and preservescripts/check.sh's Bash 3.2-compatible pipeline overlap. Keep everyscripts/test_*.tnsuite parallel-safe (isolated temp dirs, ephemeral127.0.0.1:0ports, no shared global paths) soscripts/run_script_tests.tnstays deterministic. - Keep build caches fail-closed and probe-free:
Keep
build_cache(Cache, Linux/macOS/vendored-SQLiteFfiCache) anddriver/runtime_pchfail-closed (any unsupported mode or corrupt cache entry must evict/fall back cleanly to direct compilation) and free of redundant subprocess probes (cc --version,tcc --version). Never maketenon emit-cdepend on PCH or cached objects. - Keep
lower/regionslinear on branch-heavy functions: Never reintroduceO(locals * branches)cloning/joining orO(locals * stmts)scans over all scalar locals incrates/tenon-compiler/src/lower*.rsorregions*.rs. Preserve dense container-local slot indexing, scalar-only function/block skipping, and theregions_place_scales_linearly_on_branch_heavy_functionsregression test. - Keep Rust unit tests millisecond-fast and
parallel-friendly: Keep unit tests unit-level (in-memory
inputs, no child processes, C compiler, network, or sleeps) so
cargo test --workspacestays far below the 120s budget. Split multi-app or multi-scenario compiler tests into independent#[test]functions solibtestruns them across cores, useBuildMode::Dev(-O0) unless-O2is specifically under test, reuse precompiled objects where safe, and record before/after timings whenever touching build scripts, caches, or gate steps.