Skip to content

ci: increase free disk space on macos-26 jobs - #165148

Closed
ubiratansoares wants to merge 5 commits into
rust-lang:mainfrom
ubiratansoares:u/macos-free-disk-space
Closed

ubiratansoares wants to merge 5 commits into
rust-lang:mainfrom
ubiratansoares:u/macos-free-disk-space

Conversation

@ubiratansoares

@ubiratansoares ubiratansoares commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

View all comments

AI/LLM disclosure

I wrote changes introduced by this single commit by hand. I used an LLM to ideate about changes, and also to review the code before submitting. I used both gpt6/astra and claude 5.5/opus as assistants.

What

A potential fix for rust-lang/infra-team#307 and a follow-up for #165123.

Here we introduce a dedicated script to free disk space on macOS Github runners. We do minimal changes to invoke this script accordingly from the CI Workflow.

The new script works by deleting iOS simulator instance files and runtimes. I assumed these components are not needed and therefore, safe to delete.

I ran a few related experiments in this repo. For macos-26 this script reclaims ~ 120GB of space. That repo also tests most of free-disk-space-mac.sh behavior.

I added a waiting logic after xcrun simctl runtime delete all (which runs asyncly) because in general this command finishes fast (less than 30 seconds) and the script can correctly calculate how much disk space was freed afterwards.

I did not try to replicate the same funcionality available in the existing Linux couterpart of this script, e.g. earlier finishing if some amount of space is already available. I assume that can be a follow-up.

r? marcoieni

@rustbot rustbot added A-CI Area: Our Github Actions CI A-testsuite Area: The testsuite used to check the correctness of rustc S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-infra Relevant to the infrastructure team, which will review and decide on the PR/issue. labels Oct 29, 2026
@ubiratansoares

Copy link
Copy Markdown
Contributor Author

@bors try jobs=test-aarch64-apple-macos-26-*

rust-bors Bot pushed a commit that referenced this pull request Oct 29, 2026
ci: increase free disk space on macos-26 jobs


try-job: test-aarch64-apple-macos-26-*
@rust-bors

This comment has been minimized.

@madsmtm madsmtm left a comment •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think the impl is right, though it'll likely have to be updated once we switch to macOS 27 (since there it's xcrun devicectl IIRC).

(I'm not on t-infra though, so you should get one of them to look over it too).

View changes since this review

Comment thread src/ci/scripts/free-disk-space-mac.sh Outdated
done

if [[ "$remaining" != 0 ]]; then
echo "::warning::Runtime deletion did not finish within the polling period."

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Nit:

Suggested change
echo "::warning::Runtime deletion did not finish within the polling period."
echo "::warning::Simlator runtime deletion did not finish within the polling period."

@ubiratansoares ubiratansoares Oct 29, 2026 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done here

script_dir=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)

# dispatch according to the Github Runner
case "${RUNNER_OS:-}" in

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Nit: Would it make sense to do uname here instead? That isn't GH-specific, so easier to understand IMO.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I think we could use uname, but matching against one of the default GHA env vars does not look terrible.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

we also have

function isLinux {

Comment thread src/ci/scripts/free-disk-space-mac.sh Outdated
# Wait a max of 60 seconds to ensure the clean-up is done before any subsequential build steps
for ((attempt = 0; attempt < 30; attempt++)); do
remaining=$(xcrun simctl runtime list -j | jq 'length')
echo "Remaining runtime iOS simulator images : $remaining"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Nit: It's not just iOS simulator images.

Suggested change
echo "Remaining runtime iOS simulator images : $remaining"
echo "Remaining simulator runtime images : $remaining"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Also goes for the top-level comment.

@ubiratansoares ubiratansoares Oct 29, 2026 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done here

Comment thread src/ci/scripts/free-disk-space.sh Outdated
#!/bin/bash
set -euo pipefail

script_dir=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" && pwd)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Nit: My bash-fu isn't strong... But I see that musl.sh uses:

SCRIPT_DIR=$(cd -- "$(dirname -- "$0")" && pwd)

What's the benefit to either? If you have no preference, then I'd prefer $0 just for consistency with our other shell scripts.

@ubiratansoares ubiratansoares Oct 29, 2026 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I think "${BASH_SOURCE[0]}" works better if for some reason one wants to source this file within a bash environment, but maybe I'm missing something. I did some research and, for the current usage, "$0" and "${BASH_SOURCE[0]}" should be same, hence opted for consistency here

xcrun simctl delete all

# This subcommand runs asynchronously
xcrun simctl runtime delete all

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Remark: I'm a little bit hesitant to do this, since I have vague plans for running CI on the simulators... But I guess it's more important that CI actually runs, and I can probably tweak this script in the future to keep a few runtime images around.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Thanks for sharing your concern! Happy to improve this later!

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

we could also delete other stuff in the future instead of what you need 👍

@rust-bors

rust-bors Bot commented Oct 29, 2026

Copy link
Copy Markdown
Contributor

☀️ Try build successful (CI)
Build commit: e4c3f34 (e4c3f3434fe554c9689b438242a6bf61bc77618c)
Base parent: 96a18bf (96a18bf5ffa2b24f9cf3d1c731a9eb121c1acad9)

@rust-bors

This comment has been minimized.

@ubiratansoares
ubiratansoares force-pushed the u/macos-free-disk-space branch from f35f96e to 2a6ff6c Compare October 29, 2026 23:27
@ubiratansoares

Copy link
Copy Markdown
Contributor Author

@bors try jobs=test-aarch64-apple-macos-26-*

@rust-bors

This comment has been minimized.

rust-bors Bot pushed a commit that referenced this pull request Oct 29, 2026
ci: increase free disk space on macos-26 jobs


try-job: test-aarch64-apple-macos-26-*
@ubiratansoares

Copy link
Copy Markdown
Contributor Author

Note: 2a6ff6c in practice reverts #165123 for the sake of testing with macos-26.

@rust-bors

rust-bors Bot commented Oct 30, 2026

Copy link
Copy Markdown
Contributor

☀️ Try build successful (CI)
Build commit: eb91e94 (eb91e9401c1dcacec25150f2071a662f3e98d799)
Base parent: 92b5b8c (92b5b8c87c61b20adc9001b41baf587634a74734)

Comment thread src/ci/github-actions/jobs.yml Resolved
Comment thread src/ci/scripts/free-disk-space-mac.sh Resolved
Comment thread src/ci/scripts/free-disk-space-mac.sh Resolved
Comment thread src/ci/scripts/free-disk-space-mac.sh Resolved
xcrun simctl delete all

# This subcommand runs asynchronously
xcrun simctl runtime delete all

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

we could also delete other stuff in the future instead of what you need 👍

Comment thread src/ci/scripts/free-disk-space.sh Resolved
Comment thread .github/workflows/ci.yml Resolved
@marcoieni

Copy link
Copy Markdown
Member

Overall looks good, feel free to r=me when you are happy with this 👍

@ubiratansoares
ubiratansoares marked this pull request as ready for review October 30, 2026 08:16
@rustbot

rustbot commented Oct 30, 2026

Copy link
Copy Markdown
Collaborator

Warning

If you are changing how CI LLVM is built or linked, make sure to bump
src/bootstrap/download-ci-llvm-stamp.

cc @jieyouxu

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Oct 30, 2026
@marcoieni

Copy link
Copy Markdown
Member

Feel free to r=me.
Consider if you want to squash your commits. 👍

@ubiratansoares

Copy link
Copy Markdown
Contributor Author

Lets move with this :)

@bors r=marcoieni

@rust-bors

rust-bors Bot commented Oct 30, 2026

Copy link
Copy Markdown
Contributor

📌 Commit d91e6e5 has been tentatively approved by marcoieni

It will be put into the queue for this repository once PR CI succeeds.

@rust-bors rust-bors Bot added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Oct 30, 2026
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Oct 30, 2026
…pace, r=marcoieni

ci: increase free disk space on macos-26 jobs

## AI/LLM disclosure

I wrote changes introduced by this single commit by hand. I used an LLM to ideate about changes, and also to review the code before submitting. I used both gpt6/astra and claude 5.5/opus as assistants.

## What

A potential fix for rust-lang/infra-team#307 and a follow-up for rust-lang#165123.

Here we introduce a dedicated script to free disk space on macOS Github runners. We do minimal changes to invoke this script accordingly from the CI Workflow.

The new script works by deleting iOS simulator instance files and runtimes. I assumed these components are not needed and therefore, safe to delete.

I ran a few related experiments [in this repo](https://github.com/ubiratansoares/macos-runners-disk-space-tests/actions/runs/40911961033). For `macos-26` this script reclaims ~ 120GB of space. That repo also tests most of `free-disk-space-mac.sh` behavior.

I added a waiting logic after `xcrun simctl runtime delete all` (which runs asyncly) because in general this command finishes fast (less than 30 seconds) and the script can correctly calculate how much disk space was freed afterwards.

I did not try to replicate the same funcionality available in the existing Linux couterpart of this script, e.g. earlier finishing if some amount of space is already available. I assume that can be a follow-up.

r? marcoieni
rust-bors Bot pushed a commit that referenced this pull request Oct 30, 2026
…uwer

Rollup of 22 pull requests

Successful merges:

 - #164851 (Add behavior tests for `Arc` and `Rc`)
 - #164989 (rustdoc: Fix performance regression for private documented items)
 - #165079 (Remove GenericArgRef)
 - #161781 (Don't emit InlineAsm terminator if input operand is `!`.)
 - #162754 (optimize large elements for slice rotating)
 - #163252 (Remove windows-targets dependency from the root workspace)
 - #163839 (Fix the floating point clobbers of RISC-V `clobber_abi`)
 - #165104 (Use getrandom instead of /scheme/rand on Redox OS)
 - #165132 (Implement `advance_back_by` on `Fuse`)
 - #165142 (Remove the unused generic Graphviz writer)
 - #165148 (ci: increase free disk space on macos-26 jobs)
 - #163371 (Don't suggest replacing foreign format specifiers in `concat!` output)
 - #163802 (fix RegionEq direction in canonical query responses)
 - #163986 (omit unconditionally invoking crate level limits query)
 - #164920 (Point at prior token on `let` when expression is expected)
 - #164987 (use adt_async_drop_tys for nested ADTs in needs_async_drop)
 - #165061 (Use a fixed-length encoding for hash disambiguators in v0 symbols)
 - #165114 (use native interpreter impl for funnel shifts intrinsics)
 - #165119 (remove unnecessary fast path from borrowck)
 - #165122 (fix MaybeDangling validity logic for ZST at usize::MAX)
 - #165128 (Move `doc(keyword)` and `doc(attribute)` attributes checks from `rustc_passes` to `rustc_attr_parsing`)
 - #165129 (Fix ICE in prelude edition lint)

Failed merges:

 - #164981 (Reflection add TypeId::name)

> [!WARNING]
> This rollup conflicts with pending auto build #165205 and may need to be recreated if the pending build succeeds.
@JonathanBrouwer

Copy link
Copy Markdown
Member

@bors p=1

rust-bors Bot pushed a commit that referenced this pull request Oct 31, 2026
…uwer

Rollup of 22 pull requests

Successful merges:

 - #164851 (Add behavior tests for `Arc` and `Rc`)
 - #164989 (rustdoc: Fix performance regression for private documented items)
 - #165079 (Remove GenericArgRef)
 - #161781 (Don't emit InlineAsm terminator if input operand is `!`.)
 - #162754 (optimize large elements for slice rotating)
 - #163252 (Remove windows-targets dependency from the root workspace)
 - #163839 (Fix the floating point clobbers of RISC-V `clobber_abi`)
 - #165104 (Use getrandom instead of /scheme/rand on Redox OS)
 - #165132 (Implement `advance_back_by` on `Fuse`)
 - #165142 (Remove the unused generic Graphviz writer)
 - #165148 (ci: increase free disk space on macos-26 jobs)
 - #163371 (Don't suggest replacing foreign format specifiers in `concat!` output)
 - #163802 (fix RegionEq direction in canonical query responses)
 - #163986 (omit unconditionally invoking crate level limits query)
 - #164920 (Point at prior token on `let` when expression is expected)
 - #164987 (use adt_async_drop_tys for nested ADTs in needs_async_drop)
 - #165061 (Use a fixed-length encoding for hash disambiguators in v0 symbols)
 - #165114 (use native interpreter impl for funnel shifts intrinsics)
 - #165119 (remove unnecessary fast path from borrowck)
 - #165122 (fix MaybeDangling validity logic for ZST at usize::MAX)
 - #165128 (Move `doc(keyword)` and `doc(attribute)` attributes checks from `rustc_passes` to `rustc_attr_parsing`)
 - #165129 (Fix ICE in prelude edition lint)

Failed merges:

 - #164981 (Reflection add TypeId::name)

> [!WARNING]
> This rollup conflicts with pending auto build #165205 and may need to be recreated if the pending build succeeds.
rust-bors Bot pushed a commit that referenced this pull request Oct 31, 2026
…uwer

Rollup of 22 pull requests

Successful merges:

 - #164851 (Add behavior tests for `Arc` and `Rc`)
 - #164989 (rustdoc: Fix performance regression for private documented items)
 - #165079 (Remove GenericArgRef)
 - #161781 (Don't emit InlineAsm terminator if input operand is `!`.)
 - #162754 (optimize large elements for slice rotating)
 - #163252 (Remove windows-targets dependency from the root workspace)
 - #163839 (Fix the floating point clobbers of RISC-V `clobber_abi`)
 - #165104 (Use getrandom instead of /scheme/rand on Redox OS)
 - #165132 (Implement `advance_back_by` on `Fuse`)
 - #165142 (Remove the unused generic Graphviz writer)
 - #165148 (ci: increase free disk space on macos-26 jobs)
 - #163371 (Don't suggest replacing foreign format specifiers in `concat!` output)
 - #163802 (fix RegionEq direction in canonical query responses)
 - #163986 (omit unconditionally invoking crate level limits query)
 - #164920 (Point at prior token on `let` when expression is expected)
 - #164987 (use adt_async_drop_tys for nested ADTs in needs_async_drop)
 - #165061 (Use a fixed-length encoding for hash disambiguators in v0 symbols)
 - #165114 (use native interpreter impl for funnel shifts intrinsics)
 - #165119 (remove unnecessary fast path from borrowck)
 - #165122 (fix MaybeDangling validity logic for ZST at usize::MAX)
 - #165128 (Move `doc(keyword)` and `doc(attribute)` attributes checks from `rustc_passes` to `rustc_attr_parsing`)
 - #165129 (Fix ICE in prelude edition lint)

Failed merges:

 - #164981 (Reflection add TypeId::name)

> [!WARNING]
> This rollup conflicts with pending auto build #165205 and may need to be recreated if the pending build succeeds.
@JonathanBrouwer

Copy link
Copy Markdown
Member

@bors r-
Does not seem to fix the issue, CI still doesn't work :c
We should still merge this tho, after we undo #165233

@rust-bors rust-bors Bot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Oct 31, 2026
@rust-bors

rust-bors Bot commented Oct 31, 2026

Copy link
Copy Markdown
Contributor

This pull request was unapproved.

This PR was contained in a rollup (#165208), which was unapproved.

View changes since this unapproval

RUST_CONFIGURE_ARGS: >-
--enable-sanitizers
--enable-profiler
--set rust.jemalloc

@jieyouxu jieyouxu Nov 1, 2026 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This should use --set build.allocator=jemalloc, ditto for other instances (rust.jemalloc is the old deprecated version)

View changes since the review

@jieyouxu jieyouxu Nov 1, 2026 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Non-blocking: should the mac equivalent also have an early exit if there's already estimated sufficient disk space?

sufficientSpaceEarlyExit() {
local available_space_kb
available_space_kb=$(df -k . --output=avail | tail -n 1)
if [ "$available_space_kb" -ge "$space_target_kb" ]; then
echo "Sufficient disk space available (${available_space_kb}KB >= ${space_target_kb}KB). Skipping cleanup."
exit 0
fi
}

View changes since the review

@JonathanBrouwer

Copy link
Copy Markdown
Member

These commits were cherry-picked into #165251

@rustbot rustbot removed the S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. label Nov 1, 2026
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Nov 1, 2026
… r=jieyouxu

Restore aarch64-apple-1 jobs with free disk space

The `apple-1` jobs seem to work with the free disk space script that I've copied from rust-lang#165148
Lets re-enable them

The commits are cherry-picked from rust-lang#165148 without changes, plus a few added commits to disable the `-2` jobs again.

r? ghost
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Nov 1, 2026
… r=jieyouxu

Restore aarch64-apple-1 jobs with free disk space

The `apple-1` jobs seem to work with the free disk space script that I've copied from rust-lang#165148
Lets re-enable them

The commits are cherry-picked from rust-lang#165148 without changes, plus a few added commits to disable the `-2` jobs again.

r? ghost
rust-bors Bot pushed a commit that referenced this pull request Nov 1, 2026
Rollup merge of #165251 - JonathanBrouwer:undo-apple-remove, r=jieyouxu

Restore aarch64-apple-1 jobs with free disk space

The `apple-1` jobs seem to work with the free disk space script that I've copied from #165148
Lets re-enable them

The commits are cherry-picked from #165148 without changes, plus a few added commits to disable the `-2` jobs again.

r? ghost
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-CI Area: Our Github Actions CI A-testsuite Area: The testsuite used to check the correctness of rustc T-infra Relevant to the infrastructure team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants