[{"data":1,"prerenderedAt":479},["ShallowReactive",2],{"blog-slat-22-en":3},{"number":4,"title":5,"summary":6,"parts":7,"toc":11,"minutes":478},22,"Build and test time","The largest saving in SLAT comes from section 5: only app knows Tauri, so the tests of every other crate never compile Tauri and the web view behind it. The…",[8],{"kind":9,"html":10},"html","\u003Cp>\u003Cem>New in version 1.2.\u003C\u002Fem>\u003C\u002Fp>\n\u003Cp>The largest saving in SLAT comes from section 5: only \u003Ccode>app\u003C\u002Fcode> knows Tauri, so the tests of every other crate never compile Tauri and the web view behind it. The second largest comes from 5.3: a heavy native library lives in a driver crate that \u003Ccode>core\u003C\u002Fcode> does not depend on, so the tests of \u003Ccode>core\u003C\u002Fcode> never compile it either. The rest of the time goes to a few settings and habits, each a line or two of configuration. This section lists them in the order of what they usually save, and ends with the things that make a build start over when it should not.\u003C\u002Fp>\n\u003Cp>Measure first. \u003Ccode>cargo build --timings\u003C\u002Fcode> writes an HTML report of every crate's compile time and of how many ran in parallel. Keep the report from before a change and compare.\u003C\u002Fp>\n\u003Ch3 id=\"s22-1\">22.1. Where the time goes\u003C\u002Fh3>\n\u003Cul>\n\u003Cli>\u003Cstrong>A library crate is compiled, not linked.\u003C\u002Fstrong> What gets linked is every binary, and in a test run every test binary.\u003C\u002Fli>\n\u003Cli>\u003Cstrong>Each crate can have three kinds of test binaries:\u003C\u002Fstrong> its unit tests, each file directly in \u003Ccode>tests\u002F\u003C\u002Fcode> (section 14.1 reduces that to one, \u003Ccode>tests\u002Fit\u003C\u002Fcode>), and its documentation examples. Since edition 2024, the documentation examples of a crate are built as one binary. A crate with no documentation examples sets \u003Ccode>doctest = false\u003C\u002Fcode> under \u003Ccode>[lib]\u003C\u002Fcode>.\u003C\u002Fli>\n\u003Cli>\u003Cstrong>A test run below \u003Ccode>app\u003C\u002Fcode> never needs Tauri.\u003C\u002Fstrong> The everyday command is \u003Ccode>cargo t\u003C\u002Fcode> (22.3), which runs every crate except \u003Ccode>quayside\u003C\u002Fcode>. Only the end-to-end tests of section 14 build the \u003Ccode>app\u003C\u002Fcode> crate.\u003C\u002Fli>\n\u003Cli>\u003Cstrong>A heavy native library costs more than Tauri.\u003C\u002Fstrong> C and C++ sources compiled by build scripts, and machine-learning crates, take most of a clean build and most of the link of every binary that includes them. Section 5.3 keeps them out of the tests of \u003Ccode>core\u003C\u002Fcode>.\u003C\u002Fli>\n\u003Cli>\u003Cstrong>Debug information is a large share of the link time.\u003C\u002Fstrong> Most of it is never read.\u003C\u002Fli>\n\u003C\u002Ful>\n\u003Ch3 id=\"s22-2\">22.2. Build settings\u003C\u002Fh3>\n\u003Cp>In the workspace root \u003Ccode>Cargo.toml\u003C\u002Fcode>:\u003C\u002Fp>\n\u003Cpre class=\"shiki shiki-themes github-light github-dark\" style=\"--shiki-light:#24292e;--shiki-dark:#e1e4e8;--shiki-light-bg:#fff;--shiki-dark-bg:#24292e\" tabindex=\"0\">\u003Ccode>\u003Cspan class=\"line\">\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">[\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#6F42C1;--shiki-dark:#B392F0\">profile\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">.\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#6F42C1;--shiki-dark:#B392F0\">dev\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">]\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">debug = \u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#032F62;--shiki-dark:#9ECBFF\">\"line-tables-only\"\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">split-debuginfo = \u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#032F62;--shiki-dark:#9ECBFF\">\"unpacked\"\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">[\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#6F42C1;--shiki-dark:#B392F0\">profile\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">.\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#6F42C1;--shiki-dark:#B392F0\">dev\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">.\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#6F42C1;--shiki-dark:#B392F0\">package\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">.\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#6F42C1;--shiki-dark:#B392F0\">\"*\"\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">]\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">debug = \u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#005CC5;--shiki-dark:#79B8FF\">false\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">strip = \u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#005CC5;--shiki-dark:#79B8FF\">false\u003C\u002Fspan>\u003C\u002Fspan>\u003C\u002Fcode>\u003C\u002Fpre>\n\n\u003Cp>Your own crates keep file and line numbers in backtraces; dependencies get no debug information. Raise it back to \u003Ccode>debug = true\u003C\u002Fcode> for one session when you need a debugger.\u003C\u002Fp>\n\u003Cp>\u003Ccode>strip = false\u003C\u002Fcode> is not optional on macOS. With \u003Ccode>debug = false\u003C\u002Fcode>, Cargo also strips those units by default, and on macOS 27 the system \u003Ccode>strip\u003C\u002Fcode> damages the dynamic libraries of procedural macros: \u003Ccode>serde_derive\u003C\u002Fcode> can no longer be loaded and a clean build fails. \u003Ccode>split-debuginfo = &quot;unpacked&quot;\u003C\u002Fcode> is written out so that whether \u003Ccode>dsymutil\u003C\u002Fcode> runs after every link on macOS does not depend on the default of a given Cargo version.\u003C\u002Fp>\n\u003Cp>The linker matters most for test binaries. On Linux for x86-64, Rust has used \u003Ccode>rust-lld\u003C\u002Fcode> by default since version 1.90. Other Linux targets can use \u003Ccode>mold\u003C\u002Fcode>. On macOS, the linker that comes with Xcode 15 and later is already fast, so leave it alone. On Windows, \u003Ccode>rust-lld\u003C\u002Fcode> is usually much faster than the default linker. In \u003Ccode>.cargo\u002Fconfig.toml\u003C\u002Fcode>:\u003C\u002Fp>\n\u003Cpre class=\"shiki shiki-themes github-light github-dark\" style=\"--shiki-light:#24292e;--shiki-dark:#e1e4e8;--shiki-light-bg:#fff;--shiki-dark-bg:#24292e\" tabindex=\"0\">\u003Ccode>\u003Cspan class=\"line\">\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">[\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#6F42C1;--shiki-dark:#B392F0\">target\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">.\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#6F42C1;--shiki-dark:#B392F0\">aarch64-unknown-linux-gnu\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">]\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">linker = \u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#032F62;--shiki-dark:#9ECBFF\">\"clang\"\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">rustflags = [\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#032F62;--shiki-dark:#9ECBFF\">\"-C\"\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">, \u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#032F62;--shiki-dark:#9ECBFF\">\"link-arg=-fuse-ld=mold\"\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">]\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">[\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#6F42C1;--shiki-dark:#B392F0\">target\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">.\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#6F42C1;--shiki-dark:#B392F0\">x86_64-pc-windows-msvc\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">]\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">linker = \u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#032F62;--shiki-dark:#9ECBFF\">\"rust-lld.exe\"\u003C\u002Fspan>\u003C\u002Fspan>\u003C\u002Fcode>\u003C\u002Fpre>\n\n\u003Cp>\u003Cstrong>Optimize the dependencies your tests spend their time in.\u003C\u002Fstrong> A dev build compiles every dependency without optimization, including an encrypted database built from C sources, a cipher or a hash function that the tests call millions of times. Optimizing only those packages makes the tests faster and leaves the release build unchanged. In one of our workspaces this took a test run from 170 to 102 seconds:\u003C\u002Fp>\n\u003Cpre class=\"shiki shiki-themes github-light github-dark\" style=\"--shiki-light:#24292e;--shiki-dark:#e1e4e8;--shiki-light-bg:#fff;--shiki-dark-bg:#24292e\" tabindex=\"0\">\u003Ccode>\u003Cspan class=\"line\">\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">[\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#6F42C1;--shiki-dark:#B392F0\">profile\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">.\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#6F42C1;--shiki-dark:#B392F0\">dev\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">.\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#6F42C1;--shiki-dark:#B392F0\">package\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">.\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#6F42C1;--shiki-dark:#B392F0\">libsqlite3-sys\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">]\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">opt-level = \u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#005CC5;--shiki-dark:#79B8FF\">3\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">[\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#6F42C1;--shiki-dark:#B392F0\">profile\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">.\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#6F42C1;--shiki-dark:#B392F0\">dev\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">.\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#6F42C1;--shiki-dark:#B392F0\">package\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">.\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#6F42C1;--shiki-dark:#B392F0\">sha2\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">]\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">opt-level = \u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#005CC5;--shiki-dark:#79B8FF\">3\u003C\u002Fspan>\u003C\u002Fspan>\u003C\u002Fcode>\u003C\u002Fpre>\n\n\u003Cp>Each line costs one rebuild of that package. Measure the test run before and after, and keep only the packages that moved it.\u003C\u002Fp>\n\u003Cp>Remove dependencies nobody uses: \u003Ccode>cargo machete\u003C\u002Fcode> lists them, and each one is compile time for nothing.\u003C\u002Fp>\n\u003Ch3 id=\"s22-3\">22.3. One set of features\u003C\u002Fh3>\n\u003Cp>Cargo builds a dependency once for every distinct set of features it is asked for. Two things in a SLAT workspace ask for different sets:\u003C\u002Fp>\n\u003Col>\n\u003Cli>\u003Cstrong>Different commands.\u003C\u002Fstrong> \u003Ccode>cargo test --workspace\u003C\u002Fcode> unifies the features of all members, \u003Ccode>cargo test -p quayside-core\u003C\u002Fcode> only those that \u003Ccode>core\u003C\u002Fcode> needs. Running both compiles \u003Ccode>tokio\u003C\u002Fcode>, \u003Ccode>serde\u003C\u002Fcode> and the rest twice. \u003Ccode>cargo-hakari\u003C\u002Fcode> fixes this: it keeps a generated \u003Ccode>workspace-hack\u003C\u002Fcode> crate that every member depends on, with the union of all features, so every command builds the dependencies the same way. \u003Ccode>cargo hakari generate\u003C\u002Fcode> updates it, and \u003Ccode>cargo hakari verify\u003C\u002Fcode> in CI fails when someone forgot.\u003C\u002Fli>\n\u003Cli>\u003Cstrong>Test features of your own crates.\u003C\u002Fstrong> The \u003Ccode>fake\u003C\u002Fcode> feature of 14.2 and \u003Ccode>test-hooks\u003C\u002Fcode> of section 10 change \u003Ccode>drivers\u003C\u002Fcode> and \u003Ccode>core\u003C\u002Fcode>, so every crate above them is compiled again when the feature switches. Prefer a data seam (14.2), which needs no feature. Where a feature is necessary, every test command switches it on the same way. Put that command in one place, in \u003Ccode>.cargo\u002Fconfig.toml\u003C\u002Fcode>:\u003C\u002Fli>\n\u003C\u002Fol>\n\u003Cpre class=\"shiki shiki-themes github-light github-dark\" style=\"--shiki-light:#24292e;--shiki-dark:#e1e4e8;--shiki-light-bg:#fff;--shiki-dark-bg:#24292e\" tabindex=\"0\">\u003Ccode>\u003Cspan class=\"line\">\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">[\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#6F42C1;--shiki-dark:#B392F0\">alias\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">]\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">t = \u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#032F62;--shiki-dark:#9ECBFF\">\"nextest run --workspace --exclude quayside --features quayside-drivers\u002Ffake --no-tests=fail\"\u003C\u002Fspan>\u003C\u002Fspan>\u003C\u002Fcode>\u003C\u002Fpre>\n\n\u003Cp>Everyone, including agents and CI, runs \u003Ccode>cargo t\u003C\u002Fcode> for the whole suite, and every narrower test command is \u003Ccode>cargo t\u003C\u002Fcode> with a filter added (22.4). A test command with a different list of packages or features is a second build. A workspace that uses only data seams (14.2) drops \u003Ccode>--features quayside-drivers\u002Ffake\u003C\u002Fcode> here and in the script of 22.4: an alias that names a feature nobody defines fails.\u003C\u002Fp>\n\u003Ch3 id=\"s22-4\">22.4. Run what a change can affect\u003C\u002Fh3>\n\u003Cp>The fixed layout says which slice a file belongs to, and the slice graph from the cycle check (16.4) says which slices depend on it. Together they give each kind of change its own set of tests:\u003C\u002Fp>\n\u003Cdiv class=\"table-wrap\">\u003Ctable>\n\u003Cthead>\n\u003Ctr>\n\u003Cth>What changed\u003C\u002Fth>\n\u003Cth>What runs\u003C\u002Fth>\n\u003C\u002Ftr>\n\u003C\u002Fthead>\n\u003Ctbody>\n\u003Ctr>\n\u003Ctd>\u003Ccode>logic.rs\u003C\u002Fcode>, \u003Ccode>model.rs\u003C\u002Fcode>, \u003Ccode>store.rs\u003C\u002Fcode>, \u003Ccode>service.rs\u003C\u002Fcode> or \u003Ccode>actor\u002F\u003C\u002Fcode> inside one slice, its \u003Ccode>mod.rs\u003C\u002Fcode> unchanged\u003C\u002Ftd>\n\u003Ctd>the tests of that slice, and \u003Ccode>cargo mutants --in-diff\u003C\u002Fcode> (14.3)\u003C\u002Ftd>\n\u003C\u002Ftr>\n\u003Ctr>\n\u003Ctd>a slice's \u003Ccode>mod.rs\u003C\u002Fcode>, its public API\u003C\u002Ftd>\n\u003Ctd>that slice and every slice that imports it\u003C\u002Ftd>\n\u003C\u002Ftr>\n\u003Ctr>\n\u003Ctd>a module of \u003Ccode>tests\u002Fit\u003C\u002Fcode>\u003C\u002Ftd>\n\u003Ctd>that module\u003C\u002Ftd>\n\u003C\u002Ftr>\n\u003Ctr>\n\u003Ctd>\u003Ccode>kit\u003C\u002Fcode>, \u003Ccode>store\u003C\u002Fcode> or \u003Ccode>drivers\u003C\u002Fcode>\u003C\u002Ftd>\n\u003Ctd>every crate that depends on it: \u003Ccode>cargo t -E 'rdeps(quayside-store)'\u003C\u002Fcode>\u003C\u002Ftd>\n\u003C\u002Ftr>\n\u003Ctr>\n\u003Ctd>\u003Ccode>drivers\u002Fsrc\u002Fplatform\u002F\u003C\u002Fcode>\u003C\u002Ftd>\n\u003Ctd>also the contract test (12.5); in CI, the platform job (16.3)\u003C\u002Ftd>\n\u003C\u002Ftr>\n\u003Ctr>\n\u003Ctd>only \u003Ccode>app\u003C\u002Fcode>\u003C\u002Ftd>\n\u003Ctd>the end-to-end tests through the entry; nothing in \u003Ccode>core\u003C\u002Fcode> changed\u003C\u002Ftd>\n\u003C\u002Ftr>\n\u003Ctr>\n\u003Ctd>\u003Ccode>Cargo.toml\u003C\u002Fcode>, \u003Ccode>Cargo.lock\u003C\u002Fcode>, \u003Ccode>.cargo\u002F\u003C\u002Fcode>, the toolchain file\u003C\u002Ftd>\n\u003Ctd>everything\u003C\u002Ftd>\n\u003C\u002Ftr>\n\u003C\u002Ftbody>\n\u003C\u002Ftable>\u003C\u002Fdiv>\n\u003Cp>A filter chooses which tests \u003Cstrong>run\u003C\u002Fstrong>, not what is \u003Cstrong>compiled\u003C\u002Fstrong>: nextest first builds every package that the Cargo options name, then applies \u003Ccode>-E\u003C\u002Fcode>. That is why every row keeps the packages and features of \u003Ccode>cargo t\u003C\u002Fcode> and narrows only with \u003Ccode>-E\u003C\u002Fcode>. The build stays the one that is already in \u003Ccode>target\u002F\u003C\u002Fcode>, and only the run gets shorter. Narrowing the build with \u003Ccode>-p\u003C\u002Fcode> saves compile time only when \u003Ccode>cargo-hakari\u003C\u002Fcode> (22.3) keeps the features the same; without it, \u003Ccode>-p\u003C\u002Fcode> is a second build of the dependencies.\u003C\u002Fp>\n\u003Cp>The tests of a slice are easy to select because their names start with the slice: unit tests live in \u003Ccode>core\u002Fsrc\u002F&lt;slice&gt;\u002F\u003C\u002Fcode>, so their names begin with \u003Ccode>&lt;slice&gt;::\u003C\u002Fcode>, and the modules of \u003Ccode>tests\u002Fit\u003C\u002Fcode> begin with the slice too (\u003Ccode>recording_stops_on_time_limit\u003C\u002Fcode>). A first version of the selection fits in a short script. It compares the working copy with the point where the branch left \u003Ccode>main\u003C\u002Fcode>, so changes that are not committed yet count too, which is what an agent's loop needs:\u003C\u002Fp>\n\u003Cpre class=\"shiki shiki-themes github-light github-dark\" style=\"--shiki-light:#24292e;--shiki-dark:#e1e4e8;--shiki-light-bg:#fff;--shiki-dark-bg:#24292e\" tabindex=\"0\">\u003Ccode>\u003Cspan class=\"line\">\u003Cspan style=\"--shiki-light:#6A737D;--shiki-dark:#6A737D\">#!\u002Fusr\u002Fbin\u002Fenv bash\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"--shiki-light:#005CC5;--shiki-dark:#79B8FF\">set\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#005CC5;--shiki-dark:#79B8FF\"> -euo\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#032F62;--shiki-dark:#9ECBFF\"> pipefail\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">base\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#D73A49;--shiki-dark:#F97583\">=\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#032F62;--shiki-dark:#9ECBFF\">\"$(\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#6F42C1;--shiki-dark:#B392F0\">git\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#032F62;--shiki-dark:#9ECBFF\"> merge-base origin\u002Fmain HEAD)\"\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">changed\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#D73A49;--shiki-dark:#F97583\">=\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#032F62;--shiki-dark:#9ECBFF\">\"$({ git diff --name-only \"$base\"; git ls-files --others --exclude-standard; } | sort -u)\"\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">crate\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#D73A49;--shiki-dark:#F97583\">=\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#032F62;--shiki-dark:#9ECBFF\">\"crates\u002Fquayside-core\"\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">tests\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#D73A49;--shiki-dark:#F97583\">=\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#032F62;--shiki-dark:#9ECBFF\">(cargo nextest run --workspace --exclude quayside --features quayside-drivers\u002Ffake \u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#6F42C1;--shiki-dark:#B392F0\">--no-tests\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#D73A49;--shiki-dark:#F97583\">=\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#032F62;--shiki-dark:#9ECBFF\">fail)\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"--shiki-light:#D73A49;--shiki-dark:#F97583\">if\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#6F42C1;--shiki-dark:#B392F0\"> grep\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#005CC5;--shiki-dark:#79B8FF\"> -qE\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#032F62;--shiki-dark:#9ECBFF\"> '(^|\u002F)Cargo\\.(toml|lock)$|^\\.cargo\u002F|^rust-toolchain|^crates\u002Fquayside-(kit|store|drivers)\u002F' \u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#D73A49;--shiki-dark:#F97583\">&#x3C;&#x3C;&#x3C;\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#032F62;--shiki-dark:#9ECBFF\"> \"\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">$changed\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#032F62;--shiki-dark:#9ECBFF\">\"; \u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#D73A49;--shiki-dark:#F97583\">then\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"--shiki-light:#005CC5;--shiki-dark:#79B8FF\">  exec\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#032F62;--shiki-dark:#9ECBFF\"> \"${\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">tests\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#032F62;--shiki-dark:#9ECBFF\">[\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#D73A49;--shiki-dark:#F97583\">@\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#032F62;--shiki-dark:#9ECBFF\">]}\"\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"--shiki-light:#D73A49;--shiki-dark:#F97583\">fi\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"--shiki-light:#D73A49;--shiki-dark:#F97583\">if\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#6F42C1;--shiki-dark:#B392F0\"> grep\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#005CC5;--shiki-dark:#79B8FF\"> -qE\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#032F62;--shiki-dark:#9ECBFF\"> \"^\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">$crate\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#032F62;--shiki-dark:#9ECBFF\">\u002F(src\u002F[^\u002F]+\\.rs|src\u002F.*mod\\.rs|tests\u002Fit\u002Fmain\\.rs|tests\u002Fit\u002Fsupport\u002F)\" \u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#D73A49;--shiki-dark:#F97583\">&#x3C;&#x3C;&#x3C;\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#032F62;--shiki-dark:#9ECBFF\"> \"\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">$changed\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#032F62;--shiki-dark:#9ECBFF\">\"; \u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#D73A49;--shiki-dark:#F97583\">then\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"--shiki-light:#005CC5;--shiki-dark:#79B8FF\">  exec\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#032F62;--shiki-dark:#9ECBFF\"> \"${\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">tests\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#032F62;--shiki-dark:#9ECBFF\">[\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#D73A49;--shiki-dark:#F97583\">@\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#032F62;--shiki-dark:#9ECBFF\">]}\" \u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#005CC5;--shiki-dark:#79B8FF\">-E\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#032F62;--shiki-dark:#9ECBFF\"> 'package(quayside-core)'\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"--shiki-light:#D73A49;--shiki-dark:#F97583\">fi\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">names\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#D73A49;--shiki-dark:#F97583\">=\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#032F62;--shiki-dark:#9ECBFF\">\"$({\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"--shiki-light:#6F42C1;--shiki-dark:#B392F0\">  sed\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#005CC5;--shiki-dark:#79B8FF\"> -nE\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#032F62;--shiki-dark:#9ECBFF\"> \"s#^\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">$crate\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#032F62;--shiki-dark:#9ECBFF\">\u002Fsrc\u002F([a-z_]+)\u002F.*#\\1#p\" \u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#D73A49;--shiki-dark:#F97583\">&#x3C;&#x3C;&#x3C;\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#032F62;--shiki-dark:#9ECBFF\"> \"\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">$changed\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#032F62;--shiki-dark:#9ECBFF\">\"\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"--shiki-light:#6F42C1;--shiki-dark:#B392F0\">  sed\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#005CC5;--shiki-dark:#79B8FF\"> -nE\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#032F62;--shiki-dark:#9ECBFF\"> \"s#^\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">$crate\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#032F62;--shiki-dark:#9ECBFF\">\u002Ftests\u002Fit\u002F([a-z_]+)\\.rs\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#005CC5;--shiki-dark:#79B8FF\">\\$\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#032F62;--shiki-dark:#9ECBFF\">#\\1#p\" \u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#D73A49;--shiki-dark:#F97583\">&#x3C;&#x3C;&#x3C;\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#032F62;--shiki-dark:#9ECBFF\"> \"\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">$changed\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#032F62;--shiki-dark:#9ECBFF\">\"\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"--shiki-light:#032F62;--shiki-dark:#9ECBFF\">} | sort -u | paste -sd'|' -)\"\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"--shiki-light:#D73A49;--shiki-dark:#F97583\">if\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#032F62;--shiki-dark:#9ECBFF\"> [ \u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#D73A49;--shiki-dark:#F97583\">-z\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#032F62;--shiki-dark:#9ECBFF\"> \"\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">$names\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#032F62;--shiki-dark:#9ECBFF\">\" ]; \u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#D73A49;--shiki-dark:#F97583\">then\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"--shiki-light:#005CC5;--shiki-dark:#79B8FF\">  echo\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#032F62;--shiki-dark:#9ECBFF\"> \"nothing below app changed; run the end-to-end tests of the entry\"\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"--shiki-light:#005CC5;--shiki-dark:#79B8FF\">  exit\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#005CC5;--shiki-dark:#79B8FF\"> 0\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"--shiki-light:#D73A49;--shiki-dark:#F97583\">fi\u003C\u002Fspan>\u003C\u002Fspan>\n\u003Cspan class=\"line\">\u003Cspan style=\"--shiki-light:#005CC5;--shiki-dark:#79B8FF\">exec\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#032F62;--shiki-dark:#9ECBFF\"> \"${\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">tests\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#032F62;--shiki-dark:#9ECBFF\">[\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#D73A49;--shiki-dark:#F97583\">@\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#032F62;--shiki-dark:#9ECBFF\">]}\" \u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#005CC5;--shiki-dark:#79B8FF\">-E\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#032F62;--shiki-dark:#9ECBFF\"> \"package(quayside-core) &#x26; test(\u002F^(\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#24292E;--shiki-dark:#E1E4E8\">$names\u003C\u002Fspan>\u003Cspan style=\"--shiki-light:#032F62;--shiki-dark:#9ECBFF\">)(::|_)\u002F)\"\u003C\u002Fspan>\u003C\u002Fspan>\u003C\u002Fcode>\u003C\u002Fpre>\n\n\u003Cp>It is deliberately cautious: a change to any \u003Ccode>mod.rs\u003C\u002Fcode>, to a file at the top of \u003Ccode>core\u002Fsrc\u002F\u003C\u002Fcode> or to the shared test helpers runs all of \u003Ccode>core\u003C\u002Fcode> instead of following the slice graph. Replace that step with the graph when the suite of \u003Ccode>core\u003C\u002Fcode> gets slow.\u003C\u002Fp>\n\u003Cp>Selection is for speed, not for proof. Use three levels:\u003C\u002Fp>\n\u003Cdiv class=\"table-wrap\">\u003Ctable>\n\u003Cthead>\n\u003Ctr>\n\u003Cth>Where\u003C\u002Fth>\n\u003Cth>What runs\u003C\u002Fth>\n\u003C\u002Ftr>\n\u003C\u002Fthead>\n\u003Ctbody>\n\u003Ctr>\n\u003Ctd>on your machine and in an agent's loop\u003C\u002Ftd>\n\u003Ctd>the selection above\u003C\u002Ftd>\n\u003C\u002Ftr>\n\u003Ctr>\n\u003Ctd>in CI on a pull request\u003C\u002Ftd>\n\u003Ctd>every crate that depends on a changed crate (\u003Ccode>rdeps\u003C\u002Fcode>)\u003C\u002Ftd>\n\u003C\u002Ftr>\n\u003Ctr>\n\u003Ctd>on \u003Ccode>main\u003C\u002Fcode>, or in the merge queue\u003C\u002Ftd>\n\u003Ctd>the whole suite\u003C\u002Ftd>\n\u003C\u002Ftr>\n\u003C\u002Ftbody>\n\u003C\u002Ftable>\u003C\u002Fdiv>\n\u003Cp>\u003Ccode>--no-tests=fail\u003C\u002Fcode> (14.1) stays on at every level, so a selection that matches nothing is red, not quietly green.\u003C\u002Fp>\n\u003Ch3 id=\"s22-5\">22.5. Many working copies\u003C\u002Fh3>\n\u003Cp>Coding agents often work in parallel, each in its own working copy. Without care, four agents compile the same dependencies four times at the same moment.\u003C\u002Fp>\n\u003Cp>\u003Cstrong>Every working copy has its own \u003Ccode>target\u002F\u003C\u002Fcode>.\u003C\u002Fstrong> Do not point several copies at one folder, with a symbolic link or with \u003Ccode>CARGO_TARGET_DIR\u003C\u002Fcode>. It looks like a shared cache, but it is a correctness bug. Two copies of the same workspace produce the same artifact names and the same fingerprint entries, so after \u003Ccode>build A; build B; build A\u003C\u002Fcode> Cargo can report copy A as \u003Ccode>Fresh\u003C\u002Fcode> while the library on disk was built from the sources of B. A check then judges someone else's code and reports green. On top of that, branches that differ rebuild each other's crates at every switch.\u003C\u002Fp>\n\u003Cp>\u003Cstrong>Start a new copy warm by cloning, not by sharing.\u003C\u002Fstrong> When the working copy is created, copy the \u003Ccode>target\u002F\u003C\u002Fcode> of the main copy with a copy-on-write clone: \u003Ccode>cp -c -R\u003C\u002Fcode> on macOS (APFS), \u003Ccode>cp --reflink=auto -R\u003C\u002Fcode> on Btrfs or XFS. It takes seconds and no disk space until a file changes. Dependencies stay fresh, and Cargo rebuilds only your own crates, because their sources are newer than what the clone recorded. Measure the first build in a new copy once; it should be close to an incremental build, not a clean one.\u003C\u002Fp>\n\u003Cp>\u003Cstrong>\u003Ccode>sccache\u003C\u002Fcode> is a complement, not the answer.\u003C\u002Fstrong> Set it as the compiler wrapper, in the user's \u003Ccode>~\u002F.cargo\u002Fconfig.toml\u003C\u002Fcode> or in the environment (\u003Ccode>RUSTC_WRAPPER=sccache\u003C\u002Fcode>), and its local cache is shared by every working copy on the machine. It caches the compilation of ordinary library dependencies. It does not cache procedural macros, binaries, \u003Ccode>cdylib\u003C\u002Fcode> crates or your own crates, which Cargo compiles incrementally, and it does not cache linking. Linking the test binaries is what each working copy pays most for, and only 14.1, 22.2 and the clone above reduce it.\u003C\u002Fp>\n\u003Cp>Limit how much of the machine one build may take with \u003Ccode>CARGO_BUILD_JOBS\u003C\u002Fcode>, for example half of the cores, so that a second build slows down instead of freezing the machine. The rule of section 19.2 still holds: one heavy build at a time.\u003C\u002Fp>\n\u003Ch3 id=\"s22-6\">22.6. CI\u003C\u002Fh3>\n\u003Cul>\n\u003Cli>\u003Cstrong>A cache in every Rust job\u003C\u002Fstrong>, including the platform job of 16.3. \u003Ccode>Swatinem\u002Frust-cache\u003C\u002Fcode> keeps dependencies and the target folder between runs, keyed by \u003Ccode>Cargo.lock\u003C\u002Fcode> and the toolchain.\u003C\u002Fli>\n\u003Cli>\u003Cstrong>Write the cache only from \u003Ccode>main\u003C\u002Fcode>, read it everywhere.\u003C\u002Fstrong> A pull-request run can read the cache of its own ref and of the default branch, nothing else, so a cache written by one pull request helps only that pull request, while the default branch, where every other pull request looks, stays empty. Set \u003Ccode>save-if: ${{ github.ref == 'refs\u002Fheads\u002Fmain' }}\u003C\u002Fcode> and run the workflow on \u003Ccode>push\u003C\u002Fcode> to \u003Ccode>main\u003C\u002Fcode> as well, so that every merge refreshes the cache and the first run of each pull request starts warm. In one of our repositories that took the first run from 942 to 478 seconds.\u003C\u002Fli>\n\u003Cli>\u003Cstrong>\u003Ccode>CARGO_INCREMENTAL=0\u003C\u002Fcode>\u003C\u002Fstrong> in CI. Incremental data is large and useless in a fresh run. \u003Ccode>Swatinem\u002Frust-cache\u003C\u002Fcode> sets it for you; with any other cache, set it yourself.\u003C\u002Fli>\n\u003Cli>\u003Cstrong>The tests below \u003Ccode>app\u003C\u002Fcode> on Linux.\u003C\u002Fstrong> When the only macOS code is in \u003Ccode>drivers\u002Fsrc\u002Fplatform\u002F\u003C\u002Fcode> and in the native driver crates of 5.3, the tests of \u003Ccode>kit\u003C\u002Fcode>, \u003Ccode>store\u003C\u002Fcode> and \u003Ccode>core\u003C\u002Fcode> need no macOS. Run them on a Linux runner, which starts faster and costs less, and keep the macOS runner for \u003Ccode>drivers\u003C\u002Fcode>, \u003Ccode>app\u003C\u002Fcode> and the contract test.\u003C\u002Fli>\n\u003Cli>\u003Cstrong>Build once, test in parallel\u003C\u002Fstrong>, when the suite takes longer than a few minutes: \u003Ccode>cargo nextest archive\u003C\u002Fcode> builds the test binaries in one job, and several jobs run their part of them with \u003Ccode>--partition hash:1\u002F3\u003C\u002Fcode>, \u003Ccode>2\u002F3\u003C\u002Fcode>, \u003Ccode>3\u002F3\u003C\u002Fcode>.\u003C\u002Fli>\n\u003Cli>\u003Cstrong>A timings report on \u003Ccode>main\u003C\u002Fcode>.\u003C\u002Fstrong> \u003Ccode>cargo build --timings\u003C\u002Fcode> as an artifact of every build of \u003Ccode>main\u003C\u002Fcode>. When the bar of \u003Ccode>core\u003C\u002Fcode> keeps getting longer after a change to a single slice, that is the measurement section 5.3 asks for before a split.\u003C\u002Fli>\n\u003Cli>\u003Cstrong>\u003Ccode>cargo hakari verify\u003C\u002Fcode>\u003C\u002Fstrong> and \u003Cstrong>\u003Ccode>cargo deny check\u003C\u002Fcode>\u003C\u002Fstrong> next to the checks of section 16. Both take seconds.\u003C\u002Fli>\n\u003C\u002Ful>\n\u003Ch3 id=\"s22-7\">22.7. What makes a build start over\u003C\u002Fh3>\n\u003Cp>A build that starts over for no visible reason almost always has one of these causes:\u003C\u002Fp>\n\u003Cul>\n\u003Cli>\u003Cstrong>A build script without \u003Ccode>rerun-if-changed\u003C\u002Fcode>.\u003C\u002Fstrong> A \u003Ccode>build.rs\u003C\u002Fcode> that prints no \u003Ccode>cargo:rerun-if-changed\u003C\u002Fcode> runs again after a change to any file of its package, and everything that uses its output is compiled again. Print one line per input. A script that compiles helper programs (Swift, C) lists their sources. Never list a path that does not exist: Cargo treats it as changed on every build.\u003C\u002Fli>\n\u003Cli>\u003Cstrong>\u003Ccode>tauri dev\u003C\u002Fcode> watching its own output.\u003C\u002Fstrong> The development server rebuilds the app when a file in \u003Ccode>src-tauri\u002F\u003C\u002Fcode> changes. A database, a log or a generated file that the app writes there restarts the build in a loop. Runtime data belongs under \u003Ccode>kit::paths\u003C\u002Fcode> (12.4); generated files go into \u003Ccode>.taurignore\u003C\u002Fcode>.\u003C\u002Fli>\n\u003Cli>\u003Cstrong>The editor and the terminal in one folder.\u003C\u002Fstrong> rust-analyzer runs \u003Ccode>cargo check\u003C\u002Fcode> with its own settings. In the same \u003Ccode>target\u002F\u003C\u002Fcode>, the editor and the terminal or an agent wait for each other's lock and can invalidate each other's work. Give the editor its own folder: \u003Ccode>&quot;rust-analyzer.cargo.targetDir&quot;: true\u003C\u002Fcode>.\u003C\u002Fli>\n\u003Cli>\u003Cstrong>Different environments.\u003C\u002Fstrong> \u003Ccode>RUSTFLAGS\u003C\u002Fcode>, and the variables that build scripts read (\u003Ccode>MACOSX_DEPLOYMENT_TARGET\u003C\u002Fcode>, \u003Ccode>CC\u003C\u002Fcode>, \u003Ccode>CFLAGS\u003C\u002Fcode>), are part of what Cargo compares. If the terminal, the editor and an agent's shell set them differently, every switch between them rebuilds. Put them in \u003Ccode>.cargo\u002Fconfig.toml\u003C\u002Fcode> (\u003Ccode>[env]\u003C\u002Fcode>, \u003Ccode>[build] rustflags\u003C\u002Fcode>), not in shell profiles.\u003C\u002Fli>\n\u003Cli>\u003Cstrong>A moving toolchain.\u003C\u002Fstrong> A new compiler rebuilds everything. Pin the full version in \u003Ccode>rust-toolchain.toml\u003C\u002Fcode>, three parts (\u003Ccode>1.98.1\u003C\u002Fcode>): a two-part channel picks up every new patch release without a change in the repository.\u003C\u002Fli>\n\u003C\u002Ful>\n\u003Ch3 id=\"s22-8\">22.8. Clean \u003Ccode>target\u002F\u003C\u002Fcode>\u003C\u002Fh3>\n\u003Cp>Cargo never deletes old artifacts. Every branch, feature set and dependency version leaves files behind, and with hundreds of thousands of files in \u003Ccode>target\u002F\u003C\u002Fcode> every Cargo command gets slower. In one of our workspaces \u003Ccode>cargo clean\u003C\u002Fcode> removed about 960,000 files (119 GiB). A full build of the library and its tests went from 7–8 minutes to 36 seconds, and \u003Ccode>cargo clippy --all-targets\u003C\u002Fcode> from several minutes to 8 seconds.\u003C\u002Fp>\n\u003Cp>Make it a rule, not a rescue: when \u003Ccode>target\u002Fdebug\u002Fdeps\u003C\u002Fcode> passes a few tens of thousands of files, or \u003Ccode>target\u002F\u003C\u002Fcode> passes a few tens of gigabytes, run \u003Ccode>cargo clean\u003C\u002Fcode> and accept one cold build. \u003Ccode>cargo sweep --time 30\u003C\u002Fcode> is the gentler option: it removes only the artifacts not used for 30 days. A working copy that is removed takes its \u003Ccode>target\u002F\u003C\u002Fcode> with it.\u003C\u002Fp>\n",[12,30,34,38,42,62,86,102,122,146,150,158,190,194,218,222,246,282,286,306,326,342,378,426,474],{"id":13,"text":14,"depth":15,"children":16},"s1","1. Why SLAT exists",2,[17,22,26],{"id":18,"text":19,"depth":20,"children":21},"s1-1","1.1. Goals",3,[],{"id":23,"text":24,"depth":20,"children":25},"s1-2","1.2. Non-goals",[],{"id":27,"text":28,"depth":20,"children":29},"s1-3","1.3. Who should use it",[],{"id":31,"text":32,"depth":15,"children":33},"s2","2. SLAT on one page",[],{"id":35,"text":36,"depth":15,"children":37},"s3","3. Vocabulary",[],{"id":39,"text":40,"depth":15,"children":41},"s4","4. Where SLAT comes from",[],{"id":43,"text":44,"depth":15,"children":45},"s5","5. Tiers",[46,50,54,58],{"id":47,"text":48,"depth":20,"children":49},"s5-1","5.1. The compiler is the guard",[],{"id":51,"text":52,"depth":20,"children":53},"s5-2","5.2. How many crates to start with",[],{"id":55,"text":56,"depth":20,"children":57},"s5-3","5.3. When to split a tier",[],{"id":59,"text":60,"depth":20,"children":61},"s5-4","5.4. Compatibility exception",[],{"id":63,"text":64,"depth":15,"children":65},"s6","6. Slices",[66,70,74,78,82],{"id":67,"text":68,"depth":20,"children":69},"s6-1","6.1. A slice in core",[],{"id":71,"text":72,"depth":20,"children":73},"s6-2","6.2. A slice in app",[],{"id":75,"text":76,"depth":20,"children":77},"s6-3","6.3. A command, the reference shape",[],{"id":79,"text":80,"depth":20,"children":81},"s6-4","6.4. Registering commands",[],{"id":83,"text":84,"depth":20,"children":85},"s6-5","6.5. Naming slices",[],{"id":87,"text":88,"depth":15,"children":89},"s7","7. Who may import whom",[90,94,98],{"id":91,"text":92,"depth":20,"children":93},"s7-1","7.1. Inside a slice",[],{"id":95,"text":96,"depth":20,"children":97},"s7-2","7.2. Between slices",[],{"id":99,"text":100,"depth":20,"children":101},"s7-3","7.3. Why these particular lines",[],{"id":103,"text":104,"depth":15,"children":105},"s8","8. Data flows",[106,110,114,118],{"id":107,"text":108,"depth":20,"children":109},"s8-1","8.1. Query (a read)",[],{"id":111,"text":112,"depth":20,"children":113},"s8-2","8.2. Command (a change)",[],{"id":115,"text":116,"depth":20,"children":117},"s8-3","8.3. Event (backend → window)",[],{"id":119,"text":120,"depth":20,"children":121},"s8-4","8.4. High-volume streams",[],{"id":123,"text":124,"depth":15,"children":125},"s9","9. Actors: slices with state",[126,130,134,138,142],{"id":127,"text":128,"depth":20,"children":129},"s9-1","9.1. When to use an actor",[],{"id":131,"text":132,"depth":20,"children":133},"s9-2","9.2. Files",[],{"id":135,"text":136,"depth":20,"children":137},"s9-3","9.3. The contract",[],{"id":139,"text":140,"depth":20,"children":141},"s9-4","9.4. A complete small actor",[],{"id":143,"text":144,"depth":20,"children":145},"s9-5","9.5. Testing an actor",[],{"id":147,"text":148,"depth":15,"children":149},"s10","10. The variant explosion",[],{"id":151,"text":152,"depth":15,"children":153},"s11","11. AppState, the composition root",[154],{"id":155,"text":156,"depth":20,"children":157},"s11-1","11.1. kit::Jobs: one-shot background work",[],{"id":159,"text":160,"depth":15,"children":161},"s12","12. Platforms",[162,166,170,174,178,182,186],{"id":163,"text":164,"depth":20,"children":165},"s12-1","12.1. Layout",[],{"id":167,"text":168,"depth":20,"children":169},"s12-2","12.2. Contracts",[],{"id":171,"text":172,"depth":20,"children":173},"s12-3","12.3. What is forbidden outside platform\u002F",[],{"id":175,"text":176,"depth":20,"children":177},"s12-4","12.4. Paths, files and text",[],{"id":179,"text":180,"depth":20,"children":181},"s12-5","12.5. Platform tests",[],{"id":183,"text":184,"depth":20,"children":185},"s12-6","12.6. Enforcement",[],{"id":187,"text":188,"depth":20,"children":189},"s12-7","12.7. Porting to a new operating system",[],{"id":191,"text":192,"depth":15,"children":193},"s13","13. Errors",[],{"id":195,"text":196,"depth":15,"children":197},"s14","14. Testing by layer",[198,202,206,210,214],{"id":199,"text":200,"depth":20,"children":201},"s14-1","14.1. One integration binary",[],{"id":203,"text":204,"depth":20,"children":205},"s14-2","14.2. A fake driver without a trait",[],{"id":207,"text":208,"depth":20,"children":209},"s14-3","14.3. Mutants in the diff",[],{"id":211,"text":212,"depth":20,"children":213},"s14-4","14.4. Property tests for update",[],{"id":215,"text":216,"depth":20,"children":217},"s14-5","14.5. A test through the entry",[],{"id":219,"text":220,"depth":15,"children":221},"s15","15. Size limits",[],{"id":223,"text":224,"depth":15,"children":225},"s16","16. Enforcement",[226,230,234,238,242],{"id":227,"text":228,"depth":20,"children":229},"s16-1","16.1. A check with a baseline",[],{"id":231,"text":232,"depth":20,"children":233},"s16-2","16.2. A check must be able to fail",[],{"id":235,"text":236,"depth":20,"children":237},"s16-3","16.3. The platform job in CI",[],{"id":239,"text":240,"depth":20,"children":241},"s16-4","16.4. Checks for the whole set",[],{"id":243,"text":244,"depth":20,"children":245},"s16-5","16.5. Lints and bans before scripts",[],{"id":247,"text":248,"depth":15,"children":249},"s17","17. Recipes",[250,254,258,262,266,270,274,278],{"id":251,"text":252,"depth":20,"children":253},"s17-1","17.1. A new read (Query)",[],{"id":255,"text":256,"depth":20,"children":257},"s17-2","17.2. A new change without background state (Command)",[],{"id":259,"text":260,"depth":20,"children":261},"s17-3","17.3. A new slice",[],{"id":263,"text":264,"depth":20,"children":265},"s17-4","17.4. A new flow with state (actor)",[],{"id":267,"text":268,"depth":20,"children":269},"s17-5","17.5. A new driver (the outside world)",[],{"id":271,"text":272,"depth":20,"children":273},"s17-6","17.6. A new event for the window",[],{"id":275,"text":276,"depth":20,"children":277},"s17-7","17.7. A new platform",[],{"id":279,"text":280,"depth":20,"children":281},"s17-8","17.8. Where does this go? (decision tree)",[],{"id":283,"text":284,"depth":15,"children":285},"s18","18. Working with coding agents",[],{"id":287,"text":288,"depth":15,"children":289},"s19","19. Migrating an existing codebase",[290,294,298,302],{"id":291,"text":292,"depth":20,"children":293},"s19-1","19.1. The order",[],{"id":295,"text":296,"depth":20,"children":297},"s19-2","19.2. Rules of migration",[],{"id":299,"text":300,"depth":20,"children":301},"s19-3","19.3. Layout first, a faster start",[],{"id":303,"text":304,"depth":20,"children":305},"s19-4","19.4. What usually goes wrong",[],{"id":307,"text":308,"depth":15,"children":309},"s20","20. Case study: Quayside",[310,314,318,322],{"id":311,"text":312,"depth":20,"children":313},"s20-1","20.1. Before",[],{"id":315,"text":316,"depth":20,"children":317},"s20-2","20.2. Symptoms in the code",[],{"id":319,"text":320,"depth":20,"children":321},"s20-3","20.3. The migration, step by step",[],{"id":323,"text":324,"depth":20,"children":325},"s20-4","20.4. After",[],{"id":327,"text":328,"depth":15,"children":329},"s21","21. Adoption checklist and FAQ",[330,334,338],{"id":331,"text":332,"depth":20,"children":333},"s21-1","21.1. Checklist for a new project",[],{"id":335,"text":336,"depth":20,"children":337},"s21-2","21.2. Checklist for an existing project",[],{"id":339,"text":340,"depth":20,"children":341},"s21-3","21.3. Questions",[],{"id":343,"text":344,"depth":15,"children":345},"s22","22. Build and test time",[346,350,354,358,362,366,370,374],{"id":347,"text":348,"depth":20,"children":349},"s22-1","22.1. Where the time goes",[],{"id":351,"text":352,"depth":20,"children":353},"s22-2","22.2. Build settings",[],{"id":355,"text":356,"depth":20,"children":357},"s22-3","22.3. One set of features",[],{"id":359,"text":360,"depth":20,"children":361},"s22-4","22.4. Run what a change can affect",[],{"id":363,"text":364,"depth":20,"children":365},"s22-5","22.5. Many working copies",[],{"id":367,"text":368,"depth":20,"children":369},"s22-6","22.6. CI",[],{"id":371,"text":372,"depth":20,"children":373},"s22-7","22.7. What makes a build start over",[],{"id":375,"text":376,"depth":20,"children":377},"s22-8","22.8. Clean target\u002F",[],{"id":379,"text":380,"depth":15,"children":381},"s23","23. Plugins",[382,386,390,394,398,402,406,410,414,418,422],{"id":383,"text":384,"depth":20,"children":385},"s23-1","23.1. When a feature is a plugin",[],{"id":387,"text":388,"depth":20,"children":389},"s23-2","23.2. Layout",[],{"id":391,"text":392,"depth":20,"children":393},"s23-3","23.3. Direction",[],{"id":395,"text":396,"depth":20,"children":397},"s23-4","23.4. Extension points",[],{"id":399,"text":400,"depth":20,"children":401},"s23-5","23.5. On and off",[],{"id":403,"text":404,"depth":20,"children":405},"s23-6","23.6. Front-end",[],{"id":407,"text":408,"depth":20,"children":409},"s23-7","23.7. A plugin in its own crate",[],{"id":411,"text":412,"depth":20,"children":413},"s23-8","23.8. Testing",[],{"id":415,"text":416,"depth":20,"children":417},"s23-9","23.9. Turning an existing slice into a plugin",[],{"id":419,"text":420,"depth":20,"children":421},"s23-10","23.10. Enforcement",[],{"id":423,"text":424,"depth":20,"children":425},"s23-11","23.11. Plugins from outside",[],{"id":427,"text":428,"depth":15,"children":429},"s24","24. Plugin packages",[430,434,438,442,446,450,454,458,462,466,470],{"id":431,"text":432,"depth":20,"children":433},"s24-1","24.1. Built-in plugin or package",[],{"id":435,"text":436,"depth":20,"children":437},"s24-2","24.2. The process rule",[],{"id":439,"text":440,"depth":20,"children":441},"s24-3","24.3. Layout",[],{"id":443,"text":444,"depth":20,"children":445},"s24-4","24.4. The manifest",[],{"id":447,"text":448,"depth":20,"children":449},"s24-5","24.5. The protocol",[],{"id":451,"text":452,"depth":20,"children":453},"s24-6","24.6. Extension points for packages",[],{"id":455,"text":456,"depth":20,"children":457},"s24-7","24.7. Signing and the store",[],{"id":459,"text":460,"depth":20,"children":461},"s24-8","24.8. Life cycle",[],{"id":463,"text":464,"depth":20,"children":465},"s24-9","24.9. Permissions",[],{"id":467,"text":468,"depth":20,"children":469},"s24-10","24.10. Testing",[],{"id":471,"text":472,"depth":20,"children":473},"s24-11","24.11. Enforcement",[],{"id":475,"text":476,"depth":15,"children":477},"s25","25. Version history",[],77,1795449738295]