-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Comments
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. |
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 |
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.
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.
Stripping debuginfo gives nice size reduction, for example rustc ui tests rust-lang/rust#98140 |
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 runningDone in Switch some tests fromcargo build
and instead use lighter-weight commands likecargo check
orcargo 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.build
tocheck
#11725Clean 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).
The text was updated successfully, but these errors were encountered: