Skip to content

difftest: nextest support and speedups #334

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 14 commits into
base: main
Choose a base branch
from
Draft

Conversation

Firestar99
Copy link
Member

@Firestar99 Firestar99 commented Jul 14, 2025

Some difftest refactors of things I just want to have:

  • switch to mimic-libtest from tester
  • add profile-based test filtering via nextest, as before:
    • cargo nextest run will ignore difftests
    • cargo difftest will only run difftests
  • output is now in tests/difftests/tests/target/difftest so you can easily inspect the output instead of having to search your tmp dir
  • moved runner to new runner crate, bin just wraps it as a "test without harness"
    • split was needed to have both tests within the runner and exposing it as a test runner
  • moved lib into tests/difftests/tests workspace
    • prevents "Updating crates.io index" on every single test, causing massive slowdowns
    • created types crate with shared mod config between lib and runner
    • we no longer compile rustc_codegen_spirv, wgpu, ash etc. in both workspaces, now only in difftest workspace

Speedups

  • master reference
  • rerunning difftest without changes:
    • Linux: 45s -> 6s
    • Windows: 195s -> 80s (whatever is going on there)
  • CI difftest times:
    • Linux: 12m -> 8m
    • Windows: 22m -> 16m
  • total CI time: 23m -> 17m

@Firestar99 Firestar99 force-pushed the difftest_refactor branch 2 times, most recently from 1215a7c to 5b43740 Compare July 15, 2025 11:03
@Firestar99
Copy link
Member Author

Even if you specify nextest filters that exclude a certain package, nextest will still build it, just not run it to discover any potential tests. I'll have to add back in the manual package excludes in CI to get back to previous CI speeds.

feature request: nextest-rs/nextest#154

@Firestar99 Firestar99 force-pushed the difftest_refactor branch 7 times, most recently from 0677196 to a861aa2 Compare July 15, 2025 19:59
@Firestar99 Firestar99 force-pushed the difftest_refactor branch 3 times, most recently from ec23891 to da0bb51 Compare July 15, 2025 21:36
@Firestar99
Copy link
Member Author

Firestar99 commented Jul 15, 2025

@LegNeato this one is ready to review, apart from the macOS difftest failing. Could you do me a favor and debug that one on your mac? It's only difftests::arch::workgroup_memory failing with I/O error: No such file or directory (os error 2) when running the ash variant.
(especially since github is taking forever to launch CI again...)

@Firestar99 Firestar99 changed the base branch from const_folding to main July 15, 2025 22:06
@LegNeato
Copy link
Collaborator

Pushed a fix. The problem was you were making the output directory and coming up with temp_output_path, but you weren't creating temp_output_path. Preivously the contract was the harness creates the file and passes the path to the test. The tests expected the file to be created by the harness so they could just blindly open and write and the output Differs expected the file to exist so they could just read.

- name: cargo fetch --locked
run: cargo fetch --locked --target $TARGET
- name: cargo fetch --locked difftests
run: cargo fetch --locked --manifest-path=tests/difftests/tests/Cargo.toml --target $TARGET
- name: test difftest
run: cargo test -p "difftest*" --release --no-default-features --features "use-installed-tools"
- name: test difftest-runner
Copy link
Collaborator

Choose a reason for hiding this comment

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

My main concern here is we are making CI smarter when best practice is to make it as dumb as possible.

Copy link
Member Author

Choose a reason for hiding this comment

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

I'm still a little unsure what to do about precompiling the tests, which is not just an CI issue but also when building from your own machine. Currently, it'll look like the tests are just stuck eating CPU for minutes, apart from the occasional slow warning from nextest, as all tests are blocked on the first test holding the target folder lock and compiling all dependencies. So at least for CI, instead of windows taking 7-8min of "nothing happening", we get cargo's compilation progress reporting.

We could move precompiling tests to the listing stage, but that would make nextest list take forever on first execution. Not even sure if we can even print compilation progress, as when listing tests we must only write a list of tests to stdout and nothing else, otherwise nextest will error out. Though I haven't tested if piping through stderr would work.

Maybe we could alias cargo difftest to be proceeded by a test compile before running nextest?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Isn't that basically what we had? It ran cargo build --release in the tests workspace regardless of what was running. The thinking was that most of the deps would be shared, but I guess I soon as I added ash vs wgpu that went out the window.

Copy link
Member Author

Choose a reason for hiding this comment

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

Crates in a workspace will compile all their dependencies into the target dir of their workspace, regardless of where they're from. So on master, the difftest lib crate would be compiled once in the difftest workspace's target and a second time in the root workspace's target. Now only types is shared like that, and a lot lighter since it's just plain types and no wgpu or ash.

@LegNeato LegNeato force-pushed the difftest_refactor branch from e74b17e to d3a1cab Compare July 16, 2025 11:53
@LegNeato
Copy link
Collaborator

nextest list compiles things like wgpu, is that expected?

@LegNeato
Copy link
Collaborator

LegNeato commented Jul 16, 2025

nextest list also doesn't show any compiletests or difftests and nextest test doesn't run them...I would expect it to run all of them by default so we can tell people "install nextest, run nextest test before putting up a PR". But I guess this PR is just replacing the impl for cargo difftest and that can wait.

BTW, running cargo test from the root now appears to run difftests...

@Firestar99
Copy link
Member Author

Firestar99 commented Jul 16, 2025

nextest has a -P profile option to select a profile from the folllowing ones I configured:

[profile.default]
default-filter = '!package(difftest*) & !package(compiletest*) & !package(example-runner-*)'
fail-fast = false
[profile.difftests]
default-filter = 'package(difftests)'
slow-timeout = "2m"
[profile.difftest-runner]
default-filter = 'package(difftest-runner) | package(difftest-types)'

And cargo difftest just points nextest to the difftest profile:

difftest = "nextest run --release -P difftests -p difftests"

The only problem is that nextest compiles all crates, regardless of the profile excluding the crate / package or not. So in CI and the difftest alias I use cargo's -p option to only select relevant packages, to compile fewer crates. See this nextest feature request.

nextest test doesn't run [difftests]

With nextest run -P difftest you can. Let me know if you'd rather have the default test everything (including compiletests as well? #318)

nextest list compiles things like wgpu, is that expected?

In that sense, yes it is expected, since nextest needs to call the test binary to figure out which tests are contained within. Although, nextest run matches previous behavior on master where example-runner-wgpu and the "old" difftest lib (now moved to the difftest workspace) would force you to compile wgpu anyway.

BTW, running cargo test from the root now appears to run difftests...

cargo test does not care for nextest profiles (obviously), not much I can do there.

@@ -44,15 +45,18 @@ unexpected_cfgs = { level = "allow", check-cfg = [
'cfg(target_arch, values("spirv"))'
] }

# Cargo Windows bug: workspace dependencies of crates.io dependencies are resolved
# incorrectly in the root workspace instead of this difftest workspace. So all
# workspace dependencies here must be mirrored into the root workspace as well.
Copy link
Member Author

@Firestar99 Firestar99 Jul 16, 2025

Choose a reason for hiding this comment

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

I still don't fully understand what's causing this, I tried creating a minimal repro repo but haven't been able to. How difftest calls cargo (--manifest-path or inherited env vars) seems to be important in the repro, as you can just cargo build in the tests/difftest/tests repo and it'll build just fine.

@Firestar99 Firestar99 changed the title difftest refactors difftest: nextest support and speedups Jul 17, 2025
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.

2 participants