Repository navigation
test: the profiling crate, thrust-profiling, with the v1 router's heap profile (test-suites PR 4) - #267
Merged
Conversation
…its heap profile with dhat
PR 4 of the test-suites plan, the owner's choice of first workload.
crates/testing/profiling is one crate, thrust-profiling:
- src/lib.rs: the workload. `run` sends a mix of creates, lists,
searches and updates through a router with tower's oneshot, with no
server or network. A `ballast` of bytes to hold while it runs is there
for the control.
- tests/common/mod.rs: the world it runs against, the real v1 routes
over thrust-core and the memory adapters, deterministic (fixed clock,
counter ids and randomness, a cheap argon2id). It is in tests/, as
crates/api/v1/tests/common is, because it mints SystemScope: the
first draft had it in src/, and check-deps.sh's proof-minting guard
refused it. That also puts the fixture under mutants.toml's
**/tests/common/** exclusion, like every crate's harness.
- tests/heap.rs installs dhat-rs as that binary's global allocator.
prof_heap_router profiles the 320-request mix and writes
target/profiling/dhat-heap-router.json for dhat's viewer: 128.8 MB in
1.03 M blocks, peak 1.58 MB. prof_heap_counts_a_known_extra_allocation
is its control, on fresh worlds: two runs without ballast allocate the
same bytes, and 4 MiB of ballast adds exactly 4 MiB. With the ballast
taken out of the workload, the control fails ("added 0 bytes").
- tests/workload.rs: every request of a generated mix is answered with
a 2xx, in the default loop, so a profile is never one of error paths.
- .config/nextest.toml: a `prof` profile (one test at a time, output
shown on a pass, no kill: dhat records a backtrace per allocation, so
the profile takes about 26 s). The default loop leaves out only the
prof_ tests, which write outside a temp dir (AGENTS.md rule 6).
- release-plz.toml: the crate joins the version group and the changelog,
with the first-release tag pattern.
dhat 0.3.3 is MIT OR Apache-2.0; it is a dev-dependency, in no shipped
graph.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
AGENTS.md rule 4 gains the `prof_` prefix. crates/testing/README.md: a row for `profiling/`, and what the crate is (one crate, a group only if two workloads conflict). docs/src/testing/techniques/performance.md: the heap profile and its control. docs/src/contributing/crates.md: twenty-one crates. ARCHITECTURE §2a gains `profiling/`. The plan: PR 3 merged, PR 4's status, and what was measured. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Review the following changes in direct dependencies. Learn more about Socket for GitHub.
|
aRustyDev
enabled auto-merge (squash)
November 17, 2026 05:22
Merged
aRustyDev
added a commit
that referenced
this pull request
Nov 17, 2026
…pper script (test-suites PR 5) (#272) * test: the v1 router's CPU profile, under samply through a nextest wrapper script PR 5 of the test-suites plan, the last. - crates/testing/profiling/tests/cpu.rs: prof_cpu_router runs the profiled mix 20 times on fresh worlds (6,400 requests, about 2 s in the release build), with the system allocator. It refuses to run without THRUST_PROF_SAMPLY, which only the wrapper sets, so a prof_cpu_ test selected under another profile fails instead of passing with no profile. - scripts/samply-wrapper.sh: nextest runs it as <wrapper> <test binary> <arguments>. It runs `samply record --save-only --no-open --unstable-presymbolicate` and writes target/profiling/<test>.json.gz, with a symbols sidecar so `samply load` opens it without the build. samply 0.13.1 exits with the test's status, but with 0 when the test is killed by a signal (measured): under a plain wrapper an aborting test PASSED. So a 0 counts only with libtest's pass line for one test. - .config/nextest.toml: `experimental = ["wrapper-scripts"]`, [scripts.wrapper.samply] (relative to the workspace root), and [[profile.prof.scripts]] for `test(/^prof_cpu_/)`. If the feature is renamed or dropped, nextest refuses the config (exit 96 for an unknown feature, 95 for a wrapper script without it; measured on 0.9.140), so no test runs unprofiled. - .github/scripts/tests/test-samply-wrapper.sh, run by ci-scripts: the wrapper against a fake samply that behaves as measured and a fake test binary, over every ending (pass, fail, no test, killed), samply installed or not, a profile written or not, and three test names (149 checks). Eight broken copies of the wrapper each fail it. - plan-ci.py: a change to the wrapper runs ci-scripts, not everything. Controls, against the real samply: a failing prof_cpu_ test fails (exit 100); an aborting one fails through the guard, and passes with the guard removed; the test refuses without the wrapper; the profile's symbols name thrust_api_v1, thrust_core, thrust_adapters_memory and thrust_profiling, and an unrelated binary's name none of them. Co-Authored-By: Claude Opus 5.5 <[email protected]> * docs: the CPU profile, and the test-suites plan's status AGENTS.md's commands table gains the profiles' command. The crate's description and module doc, crates/testing/README.md and docs/src/testing/techniques/performance.md describe the CPU profile and the wrapper. The plan: PR 4 merged in #267, PR 5 in review, and what PR 5 found (samply's exit status on a signal, the refusal without the wrapper, how nextest reacts if the experimental feature changes). Co-Authored-By: Claude Opus 5.5 <[email protected]> --------- Co-authored-by: Claude Opus 5.5 <[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.
PR 4 of the test-suites plan (
.agents/plans/test-suites/): the first profiling workload, which the owner chose to be the in-process v1 router, and its heap profile.crates/testing/profilingis a new crate,thrust-profiling.What
src/lib.rs, the workload.runsends a mix of creates, lists, searches and updates through the v1 router with tower'soneshot. There is no server and no network, so the profiler sees the application's own work. Aballastof bytes held during the run exists for the control.tests/common/mod.rs, the world the workload runs against. It serves the real v1 routes overthrust-coreand the memory adapters, and is deterministic: a fixed clock, counter ids and randomness, a cheap argon2id, and background work dropped. It lives intests/and not in the library because it mintsSystemScope. In my first draft it was insrc/, andcheck-deps.sh's proof-minting guard refused it (feat(core): makeScopethe argument of every repository andTxmethod #35, feat(compat): the 48-route minimum slice with the auth-client JSON change #44). Its shape is the same ascrates/api/v1/tests/common.tests/heap.rsinstalls dhat-rs as that test binary's global allocator.prof_heap_routerprofiles the 320-request mix. It prints the totals and writestarget/profiling/dhat-heap-router.jsonfor dhat's viewer.prof_heap_counts_a_known_extra_allocationis its control (below).tests/workload.rschecks every request of a generated mix (prop_) and of the profiled mix. Each must be answered with a 2xx, so a profile is never one of error paths. These tests are hermetic and run in the default loop..config/nextest.tomlgains aprofprofile: one test at a time, output shown on a pass, and no kill. dhat records a backtrace per allocation, so the router's profile takes about 26 s. The default loop leaves out only this crate'sprof_tests, because they write outside a temp dir (AGENTS.md rule 6).release-plz.toml: the crate joins the version group and the changelog, with the first-release tag pattern.prof_.crates/testing/README.mdgets a row and a description forprofiling/.performance.mddescribes the profile and its control.crates.mdnow counts twenty-one crates.profiling/line.dhat 0.3.3 is
MIT OR Apache-2.0. It is a dev-dependency only, so it is in no shipped graph. Run the profile with:The profile
320 requests (200 creates, 50 lists, 20 searches, 50 updates) allocate 128.8 MB in 1.03 M blocks. The peak is 1.58 MB in 14,404 blocks, and 612 KB is still held at the end. No number gates yet (X19).
Evidence
Every check below has a control that makes it fail (AGENTS.md rule 8).
cargo nextest run -p thrust-profiling(default profile)prof_tests skippedcargo nextest run -p thrust-profiling --profile profprof_tests, both passed; the workload's 2 tests skipped; the dhat file is written (468 KB)scripts/check-deps.shSystemScope::mint()insrc/lib.rscargo mutants -p thrust-profilingsrc/, missed 21. All of them were in the world's fixtures: the clock, ids, rng, config fields and seed fields. Moving the world totests/common/forcheck-depstook them out of scope, as.cargo/mutants.tomlexcludes**/tests/common/**in every crate. They were not killed by tests. The workload itself was caught in full both timescargo nextest run --profile ci --workspace(before mergingmain)cargo clippy -p thrust-profiling --all-targets -D warnings,cargo fmt --check,cargo deny checkdepsandci-scriptsjobs, read fromci.yml, shell scripts under dash, after merging today'smaincheck-release-plz.pyrefuses a crate that is not declared, as it did for #262scripts/check-layout.shcargo metadata --lockedafter mergingmain(a crate-adding PR)profprofile, rerun after mergingmain(#263 refactored the router's error types)Cargo.tomland.config/changed, so CI runs everything. Theprofprofile is not in CI; the CI-split plan owns the workflows.🤖 Generated with Claude Code