Skip to content

chore(rs): run tests under nextest, and stop wasting CPU on RSA keygen - #2558

Merged
kixelated merged 2 commits into
mainfrom
claude/nextest-default
Jul 29, 2026
Merged

chore(rs): run tests under nextest, and stop wasting CPU on RSA keygen#2558
kixelated merged 2 commits into
mainfrom
claude/nextest-default

Conversation

@kixelated

Copy link
Copy Markdown
Collaborator

Summary

Two related annoyances, both about tests eating CPU for no benefit.

Plain cargo test has no timeout. A test that parks with nothing to wake it never returns, so the harness never exits: it holds the target lock and burns a core until someone kills it by hand. That is not hypothetical in this repo, since a lost kio wakeup is a hang rather than a failure, and it cost two such runs while reviewing #2556. .config/nextest.toml adds a slow-timeout with terminate-after, so the same test is reported TIMEOUT and killed in bounded time: SLOW at 30s, killed at 60s, doubled on CI. just rs test now runs nextest, matching what just rs ci already did; doctests get their own recipe rather than being silently dropped, since nextest does not run them.

A timeout is only meaningful if the honest tests are fast, and the moq-token RSA tests were not: six 2048-bit keygens across two tests, ~16s, because rsa and its bignum backend are orders of magnitude slower unoptimized. Rather than shrinking the key size (which weakens the test and diverges from production), give those three dependencies an opt-level override in the dev profile, which test builds inherit.

before after
slowest single test 35s 8.8s
the 5 RSA tests 16.3s 0.8s
full workspace suite 87s 35s
tests flagged SLOW 2 0

With nothing legitimately near the limit any more, the threshold is real signal: a test flagged SLOW is now a bug to fix, not a number to raise, and rs/CLAUDE.md says so along with the opt-level escape hatch for a slow dependency.

Public API changes

None. Build profile, test runner config, just recipes, and a guide.

Test plan

  • cargo nextest run --workspace --all-targets --all-features: 2441 passed, 0 slow.
  • Timeout verified end to end, not just configured: parking a test on std::future::pending() is killed at exactly 120s under the old setting and reported TIMEOUT instead of hanging the run.
  • RSA timings above measured before and after on the same machine.
  • cargo fmt --check, taplo format --check (which covers the new .config/nextest.toml), cargo sort --check, and clippy -D warnings all clean.

Split out of #2556, which is where the hangs turned up.

(Written by Opus 5)

Plain `cargo test` has no timeout. A test that parks with nothing to wake
it never returns, so the harness never exits: it holds the target lock and
burns a core until someone kills it by hand. That is not hypothetical here,
since a lost `kio` wakeup is a hang rather than a failure, and it cost two
such runs while reviewing #2556.

Add `.config/nextest.toml` with a `slow-timeout` that terminates, turning a
hang into a TIMEOUT failure in bounded time (SLOW at 30s, killed at 60s;
double that on CI). Point `just rs test` at nextest to match what
`just rs ci` already ran, and give doctests their own recipe rather than
dropping them silently, since nextest does not run them.

For that timeout to mean anything the honest tests have to be fast, and the
moq-token RSA tests were not: six 2048-bit keygens across two tests, ~16s,
because `rsa` and its bignum backend are orders of magnitude slower
unoptimized. Give those three dependencies an `opt-level` override in the
dev profile, which test builds inherit. The tests still generate
production-size keys and now take 0.8s; the full workspace suite drops from
87s to 35s, and the slowest single test from 35s to under 9s.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry @kixelated, you have reached your weekly rate limit of 500000 diff characters.

Please try again later or upgrade to continue using Sourcery

@coderabbitai

coderabbitai Bot commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 0a146cb1-9e14-4a8a-a9fa-98f585e1e464

📥 Commits

Reviewing files that changed from the base of the PR and between bb12a03 and bf32b4b.

📒 Files selected for processing (1)
  • rs/justfile

Walkthrough

Updated Rust test infrastructure to use cargo nextest for standard test runs while retaining cargo test for doctests. Added shared default and CI nextest profiles with bounded timeouts, disabled retries, and CI failure output settings. Expanded testing guidance to document the new commands and timeout expectations. Added development profile optimization overrides for RSA and bignum-related dependencies.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main changes: switching tests to nextest and speeding RSA keygen-related test work.
Description check ✅ Passed The description matches the changeset and explains the nextest timeout, doctest, and RSA optimization updates.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
✨ Simplify code
  • Create PR with simplified code
  • Commit simplified code in branch claude/nextest-default

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In @.config/nextest.toml:
- Around line 24-28: Update the Rust CI test command in the justfile’s nextest
invocation to explicitly select the existing ci profile, using --profile ci or
the equivalent NEXTEST_PROFILE=ci configuration. Preserve the current workspace,
target, and feature arguments so the profile’s timeout and failure-output
settings apply in CI.

In `@Cargo.toml`:
- Around line 126-132: Remove the stale before/after timing claims from the
optimization comment in Cargo.toml lines 126-132, while retaining the bignum
dependency optimization rationale and production key-size guarantee. Also update
rs/CLAUDE.md lines 153-160 to retain the SLOW-test policy and opt-level
guidance, removing the workspace and RSA timing claims; both sites require
direct documentation-only edits.

In `@rs/CLAUDE.md`:
- Around line 142-143: Update the command guidance near the just and cargo
examples in the project documentation to state that these commands should run
inside the Nix development shell to match CI tooling. Retain direct cargo or bun
invocation as the fallback when Nix is unavailable.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: d9f31879-a576-4a05-935a-60fe478cd477

📥 Commits

Reviewing files that changed from the base of the PR and between d49fdfb and bb12a03.

📒 Files selected for processing (4)
  • .config/nextest.toml
  • Cargo.toml
  • rs/CLAUDE.md
  • rs/justfile

Comment thread .config/nextest.toml
Comment thread Cargo.toml
Comment on lines +126 to +132
# Optimize the bignum crates even in dev/test builds. RSA keygen is bignum
# arithmetic in a loop, and unoptimized it is orders of magnitude slower: the
# moq-token key tests spend ~16s generating 2048-bit keys, versus well under a
# second here. These are dependencies we never step through in a debugger, so
# optimizing them costs nothing an unoptimized build was buying us, and the
# tests keep exercising production key sizes rather than being weakened to
# stay fast. `profile.test` inherits these overrides.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

Remove stale before/after timings from both comments.

Both comments should explain the current optimization policy without embedding migration measurements that will become inaccurate.

  • Cargo.toml#L126-L132: retain the dependency optimization rationale and production key-size guarantee; remove the fixed timing comparison.
  • rs/CLAUDE.md#L153-L160: retain the SLOW-test policy and opt-level guidance; remove the workspace and RSA timing claims.

As per coding guidelines, comments and documentation must describe the current behavior, not historical migration context or obsolete behavior.

📍 Affects 2 files
  • Cargo.toml#L126-L132 (this comment)
  • rs/CLAUDE.md#L153-L160
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@Cargo.toml` around lines 126 - 132, Remove the stale before/after timing
claims from the optimization comment in Cargo.toml lines 126-132, while
retaining the bignum dependency optimization rationale and production key-size
guarantee. Also update rs/CLAUDE.md lines 153-160 to retain the SLOW-test policy
and opt-level guidance, removing the workspace and RSA timing claims; both sites
require direct documentation-only edits.

Source: Coding guidelines

Comment thread rs/CLAUDE.md
Comment on lines +142 to +143
- `just check` runs all tests + lint; `just fix` auto-fixes formatting/lint. `just rs test -p <crate>` (or `cargo nextest run -p <crate>`) for one crate.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

Document the Nix-shell requirement for these commands.

The repository guideline requires project commands to run in the Nix development shell so local tooling matches CI. Add a short scope note around the new just and cargo commands, retaining direct Cargo as the fallback when Nix is unavailable.

As per coding guidelines, use the Nix development shell for project commands so local runs match CI tooling; if unavailable, use cargo or bun directly.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@rs/CLAUDE.md` around lines 142 - 143, Update the command guidance near the
just and cargo examples in the project documentation to state that these
commands should run inside the Nix development shell to match CI tooling. Retain
direct cargo or bun invocation as the fallback when Nix is unavailable.

Source: Coding guidelines

The [profile.ci] block added alongside the nextest switch was dead config:
nothing set NEXTEST_PROFILE and `just rs ci` ran a bare `cargo nextest
run`, so CI silently used profile.default and the longer timeout the
comment described never applied. Pass --profile ci so it does.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@kixelated
kixelated enabled auto-merge (squash) July 29, 2026 20:54
@kixelated
kixelated merged commit 9edd2b2 into main Jul 29, 2026
4 checks passed
@kixelated
kixelated deleted the claude/nextest-default branch July 29, 2026 21:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant