Skip to content
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

Reduce cargo's testsuite overhead #11341

Open
ehuss opened this issue Nov 5, 2022 · 3 comments
Open

Reduce cargo's testsuite overhead #11341

ehuss opened this issue Nov 5, 2022 · 3 comments
Labels
A-testing-cargo-itself Area: cargo's tests S-triage Status: This issue is waiting on initial triage.

Comments

@ehuss
Copy link
Contributor

ehuss commented Nov 5, 2022

Cargo's testsuite has fairly significant overhead, particularly in disk space usage. For x86_64-pc-windows-gnu it is generating nearly 9.5GB of data. This will eventually run the risk of running out of space on CI and leads to slower tests.

This issue is for tracking ideas and work to try to reduce that overhead. Some ideas:

  • Switch tests to default with debuginfo off. Most tests don't care about debuginfo, and it generates a significantly large amount of data on some platforms. Other profile options may also be considered (for example, enable_mac_dsym sets split-debuginfo to "packed". Something like that could be considered for other targets or settings.)

  • Switch tests to avoid running cargo build and instead use lighter-weight commands like cargo check or cargo tree. Lots of tests were written before these other commands existed, and the tests themselves aren't particularly interested in the compiled artifacts. This may be difficult and tedious, and may not have significant wins. It also has a moderate risk of inadvertently changing the intent of the test, or otherwise degrading our test coverage. Done in Switch some tests from build to check #11725

  • Clean tests after they run. Unfortunately this is quite difficult (or maybe impossible). Particularly on Windows, there can be locking issues (see cargo_test: remove test roots after success #9701, windows: testsuite is unreasonably slow #9585, Revert test directory cleaning change. #7042 and others for more details). There could be workarounds, such as ignoring errors while deleting. Another issue is that for development, it is very useful (to me at least) to keep the directories around. This allows manually entering the directory to test and debug issues. This could also be alleviated with something like an environment variable to toggle the behavior, but that would make running tests more complicated and cumbersome.

  • Somehow reduce excess registry overhead. I've noticed that many cargo-add and similar tests are generating very large registries (1.5MB to 2MB each). Ideally those should only be generating the minimal amount of data needed (I would expect about 10x less).

@ehuss ehuss added the A-testing-cargo-itself Area: cargo's tests label Nov 5, 2022
@ChrisDenton
Copy link
Member

Clean tests after they run

Idea: A test directory could simply be renamed when it's no longer required. This would allow a cleanup thread or process to somehow be signalled to attempt deletes at its own pace without holding up other work. If there is a setting to keep the test directory then maybe the cleanup thread/process wouldn't be run or would just be a no-op.

Admittedly this adds some complexity.

@weihanglo
Copy link
Member

weihanglo commented Nov 10, 2022

Terribly bad idea: What about a layer of in-memory file system, so we no more suffer from insufficient disk space? It drops after a test finishes. Presumably for registry index and target-dir we could do that. Then we need a larger RAM 😆.

bors added a commit that referenced this issue Feb 17, 2023
Switch some tests from `build` to `check`

#11341 brought up issues with cargo's `testsute` size and speed. One of the suggested fixes was switching most tests to `check` instead of `build`. This PR did that.

Before size on `nightly`: 4.4GB

After size on `nightly`: 4.2GB

Regex to find `build` in `tests/testsuite`: `cargo\(".*build.*\)`
Before: 1607
After: 626

Note I did not remove all `build` I only did the easy ones that required minimal changes. I also tried not to touch systems I was unsure about. There could be other uses of `build` I missed as well.

I still need to play around with `opt-level`, `debug=0`, and a few other tweaks, but there should be more time/memory to drop.

Each test file changed is in a commit of its own, so you should look commit by commit.
bors added a commit that referenced this issue Feb 21, 2023
Switch some tests from `build` to `check`

#11341 brought up issues with cargo's `testsute` size and speed. One of the suggested fixes was switching most tests to `check` instead of `build`. This PR did that.

Before size on `nightly`: 4.4GB

After size on `nightly`: 4.2GB

Regex to find `build` in `tests/testsuite`: `cargo\(".*build.*\)`
Before: 1607
After: 626

Note I did not remove all `build` I only did the easy ones that required minimal changes. I also tried not to touch systems I was unsure about. There could be other uses of `build` I missed as well.

I still need to play around with `opt-level`, `debug=0`, and a few other tweaks, but there should be more time/memory to drop.

Each test file changed is in a commit of its own, so you should look commit by commit.
@klensy
Copy link
Contributor

klensy commented Feb 22, 2023

Switch tests to default with debuginfo off. Most tests don't care about debuginfo, and it generates a significantly large amount of data on some platforms. Other profile options may also be considered (for example, enable_mac_dsym sets split-debuginfo to "packed". Something like that could be considered for other targets or settings.)

Stripping debuginfo gives nice size reduction, for example rustc ui tests rust-lang/rust#98140

@epage epage added the S-triage Status: This issue is waiting on initial triage. label Nov 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-testing-cargo-itself Area: cargo's tests S-triage Status: This issue is waiting on initial triage.
Projects
None yet
Development

No branches or pull requests

5 participants