Repository navigation
perf(ci): one test binary per crate for the three that carry most of them - #345
Merged
Merged
Conversation
…them sccache reports `Non-cacheable reasons: crate-type 147` — it cannot cache a final link, so the workspace's ~147 test binaries were compiled and linked uncached on every run of every CI job, each one statically linking bundled DuckDB. That is a floor no amount of cache work gets under, and it is the largest single cost in both long jobs. `autotests = false` plus one explicit `[[test]]` target per crate makes every file in `tests/` a module of `tests/main.rs` instead of a target of its own, for the three crates holding 76 of the 117 integration files: er-server 49, dedupe-core 20, er-match 7. **Files do not move.** That is the point of doing it with `autotests` rather than by relocating sources into a subdirectory: all 40 `include_str!` paths and the `CARGO_MANIFEST_DIR`-relative fixture helpers keep resolving, and git history stays attached to each file. ## Measured, same machine, back to back | | before | after | | |---|---|---|---| | test binaries linked (`cargo test --workspace`) | 147 | **75** | −49% | | er-server: compile lib + link its test targets | 52.6s | **13.4s** | 3.9× | | er-server suite wall | 259.5s | **30.6s** | 8.5× | | `check-e2e` test time | 346s | 210s | −39% | | `check-e2e` test time at CI's 4 threads | 346s | 256s | −26% | The suite win is the same overlap `cargo nextest` was meant to buy: cargo runs one test BINARY at a time, so these files ran strictly in series, and as modules of one binary they are threads in one process. Unlike nextest there is no process-per-test tax — nextest was measured 96s *slower* on the `test` job for exactly that reason (#344) — and unlike nextest this also removes 72 uncacheable links. One change, both costs. This is only safe because each Postgres test owns its own database (#344); before that, 49 concurrent threads on one shared schema is precisely the race `pg_serial.rs` exists to prevent. dedupe-core and er-match needed no equivalent work: their fixtures are read-only committed files, verified by grepping for writers. ## Consequences worth knowing `--test <file>` no longer resolves for these three crates; the target is `main` and the old file name is a name filter. Updated at all three call sites — rust.yml's extension-loading step and the 50k scale job, plus the ducklake-lakehouse skill. `er-cli --test lake_e2e` is untouched because er-cli is not consolidated. `pg_serial.rs` keeps doing its job unchanged: it scans `tests/` for `pg_*.rs` files, which are still there. Counts are identical to main: `make check` 586 passed, `check-e2e` 232 passed, zero skips. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Extends the same `autotests = false` pattern to the twelve other crates with more than one integration-test file: dedupe-cli, er-cli, er-compile, er-entity-gen, er-entity-lint, er-hash, er-ingest, er-reconcile, er-schema, er-standardize, er-std. Test binaries across the workspace go **147 -> 56**. ## One crate is deliberately left out, and it took a failure to find `er-entity-diff` is NOT consolidated. Its `pg_diff.rs` and `pg_reconcile.rs` both connect to the single database named by `ER_TEST_PG_DSN`, so as modules of one binary they ran concurrently against shared tables and Postgres returned `E40P01 deadlock detected` — one test waiting on AccessShareLock on the schema while the other held AccessExclusiveLock on a relation it was retyping. I had scanned every candidate crate for concurrency hazards before starting, but only for temp-file and working-directory collisions — not for a shared Postgres, because the database-per-test isolation (#344) lives in er-server's test support and I did not think to ask which *other* crate talks to that database. It is two links; the reason it stays separate, and what would have to happen first, is recorded in its Cargo.toml rather than left to be rediscovered. ## Measured | | main | after | |---|---|---| | test binaries linked | 147 | **56** | | `check-e2e` test time | 346s | **194s** (−44%) | CI on the previous commit (the big three only) already showed the effect on job wall-clock, against two independent controls with `fmt + clippy + docs` as the control variable: `test` 9.0m/10.2m -> 8.2m, `DuckLake e2e` 15.5m/17.4m -> 13.6m. Roughly −10% to −20% on both long jobs. Modest rather than dramatic, because what remains in both is dependency-tree compile, which only the cache can touch. `make check` 586 passed and `check-e2e` 232 passed, both unchanged from main, zero skips. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
athvin
added a commit
that referenced
this pull request
Oct 28, 2026
…t applied) (#346) * perf(ci): one test binary per crate for the three that carry most of them sccache reports `Non-cacheable reasons: crate-type 147` — it cannot cache a final link, so the workspace's ~147 test binaries were compiled and linked uncached on every run of every CI job, each one statically linking bundled DuckDB. That is a floor no amount of cache work gets under, and it is the largest single cost in both long jobs. `autotests = false` plus one explicit `[[test]]` target per crate makes every file in `tests/` a module of `tests/main.rs` instead of a target of its own, for the three crates holding 76 of the 117 integration files: er-server 49, dedupe-core 20, er-match 7. **Files do not move.** That is the point of doing it with `autotests` rather than by relocating sources into a subdirectory: all 40 `include_str!` paths and the `CARGO_MANIFEST_DIR`-relative fixture helpers keep resolving, and git history stays attached to each file. ## Measured, same machine, back to back | | before | after | | |---|---|---|---| | test binaries linked (`cargo test --workspace`) | 147 | **75** | −49% | | er-server: compile lib + link its test targets | 52.6s | **13.4s** | 3.9× | | er-server suite wall | 259.5s | **30.6s** | 8.5× | | `check-e2e` test time | 346s | 210s | −39% | | `check-e2e` test time at CI's 4 threads | 346s | 256s | −26% | The suite win is the same overlap `cargo nextest` was meant to buy: cargo runs one test BINARY at a time, so these files ran strictly in series, and as modules of one binary they are threads in one process. Unlike nextest there is no process-per-test tax — nextest was measured 96s *slower* on the `test` job for exactly that reason (#344) — and unlike nextest this also removes 72 uncacheable links. One change, both costs. This is only safe because each Postgres test owns its own database (#344); before that, 49 concurrent threads on one shared schema is precisely the race `pg_serial.rs` exists to prevent. dedupe-core and er-match needed no equivalent work: their fixtures are read-only committed files, verified by grepping for writers. ## Consequences worth knowing `--test <file>` no longer resolves for these three crates; the target is `main` and the old file name is a name filter. Updated at all three call sites — rust.yml's extension-loading step and the 50k scale job, plus the ducklake-lakehouse skill. `er-cli --test lake_e2e` is untouched because er-cli is not consolidated. `pg_serial.rs` keeps doing its job unchanged: it scans `tests/` for `pg_*.rs` files, which are still there. Counts are identical to main: `make check` 586 passed, `check-e2e` 232 passed, zero skips. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> * perf(ci): consolidate the remaining multi-file test crates Extends the same `autotests = false` pattern to the twelve other crates with more than one integration-test file: dedupe-cli, er-cli, er-compile, er-entity-gen, er-entity-lint, er-hash, er-ingest, er-reconcile, er-schema, er-standardize, er-std. Test binaries across the workspace go **147 -> 56**. ## One crate is deliberately left out, and it took a failure to find `er-entity-diff` is NOT consolidated. Its `pg_diff.rs` and `pg_reconcile.rs` both connect to the single database named by `ER_TEST_PG_DSN`, so as modules of one binary they ran concurrently against shared tables and Postgres returned `E40P01 deadlock detected` — one test waiting on AccessShareLock on the schema while the other held AccessExclusiveLock on a relation it was retyping. I had scanned every candidate crate for concurrency hazards before starting, but only for temp-file and working-directory collisions — not for a shared Postgres, because the database-per-test isolation (#344) lives in er-server's test support and I did not think to ask which *other* crate talks to that database. It is two links; the reason it stays separate, and what would have to happen first, is recorded in its Cargo.toml rather than left to be rediscovered. ## Measured | | main | after | |---|---|---| | test binaries linked | 147 | **56** | | `check-e2e` test time | 346s | **194s** (−44%) | CI on the previous commit (the big three only) already showed the effect on job wall-clock, against two independent controls with `fmt + clippy + docs` as the control variable: `test` 9.0m/10.2m -> 8.2m, `DuckLake e2e` 15.5m/17.4m -> 13.6m. Roughly −10% to −20% on both long jobs. Modest rather than dramatic, because what remains in both is dependency-tree compile, which only the cache can touch. `make check` 586 passed and `check-e2e` 232 passed, both unchanged from main, zero skips. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> * feat(infra): terraform the sccache S3 bucket and its two CI roles NOT APPLIED, and rust.yml is deliberately untouched. Pointing the workflow at the bucket before `terraform apply` runs would make every compile job fail to assume a role that does not exist, so the sequence is: merge this, apply, then switch the workflow in its own change. ## Why sccache currently uses the GitHub Actions cache backend, which shares one 10 GB per-repository budget, LRU-evicted past it. That is why rust.yml carries a nightly `cache-prune` job — a cap on the thing doing most of the work. When the repository sat at the ceiling GitHub evicted its largest LRU victim, the rust-cache entry every compile job restores from, producing cold runs with no dependency change to explain them. Cold is roughly 3x: on DuckDB 2.0 the `DuckLake e2e` job measured 25m cold against 8m warm, `test` 15m against 6m. This is now the dominant remaining CI lever. After collapsing 147 test binaries to 56 (#345), what is left in both long jobs is dependency-tree compile, which only a cache can touch — consolidation got `test` to 8.2m and `DuckLake e2e` to 13.6m, and more test-structure work would be diminishing returns. ## The security decision in this change Two roles, not one, because **this repository is public**. A role that let any PR-triggered job write to the cache would be a path for a contributor-supplied branch to place compiled object code that a later `main` build consumes — cache poisoning straight into the build. So `er-ci-sccache-write` trusts only `ref:refs/heads/main`, exactly as the existing `er-ci-ecr-push` role restricts image pushes and as rust.yml's rust-cache config already restricts its single writer ("`lint` is the SINGLE WRITER of `shared-key: rust`, and only from `main`"). `er-ci-sccache-read` trusts any ref of this repository, so PRs read the cache `main` populated — which is where nearly all the value is, the dependency tree rather than the PR's own crates. Neither policy carries `s3:DeleteObject`; expiry is the lifecycle rule's job. Fork PRs get neither role: GitHub issues no `id-token` to a fork's `pull_request` run, so those have no cache. That is the safe failure and not a regression, since the Actions backend was equally unavailable to them. **One thing is unverified and the comment says so.** sccache is *expected* to treat a denied `PutObject` as a non-fatal cache-write miss and keep compiling. If it instead fails the build, the read-only role is unusable and the choice becomes one read+write role (accepting the poisoning surface) or no cache on PRs. Probe that on a single PR before deleting `cache-prune`. ## Notes The bucket is private, SSE-AES256, unversioned (every object is a content-addressed compilation result, so a second version is the same bytes), with a 14-day expiry that replaces the nightly prune and a 1-day abort-incomplete-multipart rule so a killed runner cannot leave billable uploads behind. The `github-oidc` module gains an `oidc_provider_arn` output: an account may hold only one OIDC provider per issuer URL and that module owns it, so these roles federate against the existing ARN rather than declaring a second provider (which would fail with EntityAlreadyExists). `terraform fmt -check -recursive` passes. I could not run `terraform validate` locally — my provider setup validates credentials at init and fails identically on unmodified `main`, so it is environmental — and infra.yml's credential-free `validate each env` job is the authority. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> * feat(infra): measure the read-only-cache assumption instead of asserting it The two-role split only works if sccache treats a denied cache write as a non-fatal miss. That was the one unverified precondition in this change, so I measured it rather than leaving it as a caveat: sccache 0.19.0 against a read-only cache directory, compiling a source change the cache could not satisfy, exits 0 and reports `Cache write errors 1`, `Cache errors 0`, `Compilation failures 0`. Kept one caveat honestly: the probe used the local-disk backend, not S3. The failure is handled at the same backend-agnostic `storage.put()` boundary, so this is strong evidence rather than proof that an S3 403 behaves the same way — hence the note to watch `Cache write errors` on the first PR run after the switch. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> * chore(infra): regenerate the account footprint for the sccache resources `.claude/skills/aws-account-operations/references/footprint.md` is GENERATED from `infra/terraform/` — it counts resource types — so adding sccache.tf made it stale and both the `agent skills (lint + drift)` and `fmt + clippy + docs` jobs failed on it. My miss: on this branch I ran `terraform fmt` and leaned on infra.yml's validate, and never ran the repo-wide `make skills-check`. The terraform was fine; the generated doc derived from it was not. The inventory now reads aws_iam_role 9 -> 11, aws_iam_role_policy 6 -> 8, aws_s3_bucket 5 -> 6, plus the bucket's access-block/encryption/lifecycle entries. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> --------- Co-authored-by: bmoore813 <[email protected]> Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
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.
sccache reports
Non-cacheable reasons: crate-type 147— it cannot cache afinal link, so the workspace's ~147 test binaries were compiled and linked
uncached on every run of every CI job, each statically linking bundled DuckDB.
That is a floor no amount of cache work gets under, and it was the largest
single cost in both long jobs.
autotests = falseplus one explicit[[test]]target per crate makes everyfile in
tests/a module oftests/main.rsinstead of a target of its own.Test binaries across the workspace: 147 -> 56.
Files do not move. That is the point of using
autotestsrather thanrelocating sources into a subdirectory: all 40
include_str!paths and theCARGO_MANIFEST_DIR-relative fixture helpers keep resolving, and git historystays attached to each file.
Measured, same machine, back to back
check-e2etest timeAnd on CI, against two independent controls with
fmt + clippy + docsas thecontrol variable (1.1m / 1.2m / 1.0m across the three runs, so cache state is
comparable):
testDuckLake + extensions e2eRoughly −10% to −20% on both long jobs — real and consistent across controls,
but modest rather than dramatic, because what remains in both is
dependency-tree compile. Only the cache can touch that, which is why
sccache-on-S3 is the next lever and not more of this.
Why this and not
cargo nextestThe suite win is the same overlap nextest was meant to buy: cargo runs one test
BINARY at a time, so these files ran strictly in series, and as modules of one
binary they are threads in one process. Unlike nextest there is no
process-per-test tax — nextest measured 96s slower on the
testjob forexactly that reason (#344) — and unlike nextest this also removes 91
uncacheable links. One change, both costs.
This is only safe for er-server because each of its Postgres tests owns its own
database (#344); before that, 49 concurrent threads on one shared schema is
precisely the race
pg_serial.rsexists to prevent.pg_serial.rskeepsworking unchanged — it scans
tests/forpg_*.rs, which are still there.One crate is deliberately excluded, and it took a failure to find
er-entity-diffis not consolidated. Itspg_diff.rsandpg_reconcile.rsboth connect to the single database named by
ER_TEST_PG_DSN, so as modules ofone binary they ran concurrently against shared tables and Postgres returned
E40P01 deadlock detected.I had scanned every candidate crate for concurrency hazards first — but only for
temp-file and working-directory collisions, not for a shared Postgres, because
the database-per-test isolation lives in er-server's test support and I did not
think to ask which other crate talks to that database. It is two links; the
reason it stays separate, and what would have to happen first, is recorded in
its Cargo.toml rather than left to be rediscovered.
Consequence worth knowing
--test <file>no longer resolves for the consolidated crates; the target ismainand the old file name becomes a name filter(
cargo test -p dedupe-core --test main extensions). Updated at all three callsites — rust.yml's extension-loading step and the 50k scale job, plus the
ducklake-lakehouse skill.
Counts identical to main:
make check586 passed,check-e2e232passed, zero skips.
🤖 Generated with Claude Code