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

cargo_test: remove test roots after success #9701

Closed
wants to merge 1 commit into from

Conversation

cuviper
Copy link
Member

@cuviper cuviper commented Jul 16, 2021

The test directories under .../cit/ can take up a lot of space, and
they're not useful to keep around for successful tests. The test guard
now removes each "root" directory, using panicking as a proxy for
failure to instead leave it for inspection.

The test directories under `.../cit/` can take up a lot of space, and
they're not useful to keep around for successful tests. The test guard
now removes each "root" directory, using `panicking` as a proxy for
failure to instead leave it for inspection.
@rust-highfive
Copy link

r? @alexcrichton

(rust-highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jul 16, 2021
@cuviper
Copy link
Member Author

cuviper commented Jul 16, 2021

For context, I was looking around in our distro builds of Rust to see what takes up so much space, and Cargo's test /cit/ was over 12GB! That's using std compiled with full debuginfo, so it's probably not so bad normally, but it's also easy to clean up.

@ehuss
Copy link
Contributor

ehuss commented Jul 16, 2021

As you can see from the test failure, I don't think this can land as it doesn't work on Windows. There's more information at #9585 and #7042. It would be great to figure out how to deal with Windows, but I'm uncertain how.

FWIW, I very frequently run commands inside test directories as I am doing development, even after success. Perhaps this could be an option? Or maybe the distro scripts can just delete it after the tests run?

EDIT: Would also need to be careful if this increased CI time significantly.

@cuviper
Copy link
Member Author

cuviper commented Jul 16, 2021

Or maybe the distro scripts can just delete it after the tests run?

I'll see if I can manage that. It does mean there will still be that 12GB spike in disk usage throughout the build, but combined with other transient cleanup I'm adding, it may be good enough.

(Ideally, I'd just provision our builders to always have plenty of total space, and just let all cleanup happen afterward, but we don't always have that flexibility across all targets.)

@ehuss
Copy link
Contributor

ehuss commented Jul 16, 2021

12 seems a lot larger than I would expect. Now you've got me curious where all that space is being wasted. On my linux system, it is 7GB, and on macOS it is 2.2GB. That seems like a crazy difference.

Hmm. One test has a hard-link to cargo itself which is 200MB (!).

Test binaries are almost 6MB each, whereas on macos they are 1.5MB (with debuginfo)! Why are linux binaries so much heavier?

@alexcrichton
Copy link
Member

Oh I thought the macos/linux differences would be "unpacked" debuginfo? On Linux we duplicate libstd's debuginfo everywhere but on macOS it's never duplicated since it's left to all reside in libstd itself

@cuviper
Copy link
Member Author

cuviper commented Jul 20, 2021

Yeah, I think split debuginfo explains macOS, and then I suspect our respective Linux differences may be due to building std with debuginfo=1 (as distributed by rustup) or debuginfo=2` (as we currently do in the distro).

@alexcrichton alexcrichton removed their assignment Mar 8, 2022
@ehuss
Copy link
Contributor

ehuss commented Mar 23, 2022

Closing since this has become a bit stale, and this can't be accepted as-is due to the Windows issue. I suggest if possible to delete the tmp directory after running tests to reduce disk space usage. It would be nice to have some kind of solution here, but it is not clear what that would look like. It would also be great if the tests didn't use so much space to begin with, but that's also challenging.

@ehuss ehuss closed this Mar 23, 2022
@ehuss ehuss mentioned this pull request Jun 3, 2022
bors added a commit that referenced this pull request Jun 3, 2022
Clear disk space on CI.

Cargo's testsuite uses a considerable amount of disk space. On windows-gnu, the target directory can get over 12GB, and there is only 13GB free.  We're starting to run out of disk space, so this is a stop-gap that clears out the test data before running the smoke test which uses a fair bit of space itself.

We will probably need to think about addressing #9701 somehow, otherwise we will start running out of space as we add more tests. See the linked issues in #9701 (comment) for additional context.
bors added a commit that referenced this pull request Nov 4, 2022
Clean more aggressively in CI

The Windows x86_64 gnu CI job is running dangerously low on disk space. This PR adds another step to delete test output more aggressively. The test output with x86_64-pc-windows-gnu is nearly 9.5GB. The benchmark step is adding about 1GB of space (unfortunately it is rebuilding cargo, which may be hard to avoid without a workspace).

Eventually we should probably look at figuring out how to reduce the amount of disk space used by the testsuite. Perhaps something like #9701 (see comments there). Or, making aggressive changes to the tests themselves. Many tests can probably be changed to use `cargo check` instead of `cargo build` (or maybe even `cargo tree`). We can default to not generating debuginfo. Or perhaps there are other changes to put the tests on a diet.
ehuss pushed a commit to ehuss/cargo that referenced this pull request Nov 15, 2022
Clean more aggressively in CI

The Windows x86_64 gnu CI job is running dangerously low on disk space. This PR adds another step to delete test output more aggressively. The test output with x86_64-pc-windows-gnu is nearly 9.5GB. The benchmark step is adding about 1GB of space (unfortunately it is rebuilding cargo, which may be hard to avoid without a workspace).

Eventually we should probably look at figuring out how to reduce the amount of disk space used by the testsuite. Perhaps something like rust-lang#9701 (see comments there). Or, making aggressive changes to the tests themselves. Many tests can probably be changed to use `cargo check` instead of `cargo build` (or maybe even `cargo tree`). We can default to not generating debuginfo. Or perhaps there are other changes to put the tests on a diet.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-review Status: Awaiting review from the assignee but also interested parties.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants