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

Use -Z threads=0 option in config_fast_builds.toml #11541

Merged
merged 2 commits into from
Jan 29, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions .cargo/config_fast_builds.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ linker = "clang"
rustflags = [
"-Clink-arg=-fuse-ld=lld", # Use LLD Linker
"-Zshare-generics=y", # (Nightly) Make the current crate share its generic instantiations
"-Zthreads=8", # (Nightly) Use improved multithreading with 8 threads.
]

# NOTE: you must install [Mach-O LLD Port](https://lld.llvm.org/MachO/index.html) on mac. you can easily do this by installing llvm which includes lld with the "brew" package manager:
Expand All @@ -16,6 +17,7 @@ rustflags = [
rustflags = [
"-Clink-arg=-fuse-ld=/usr/local/opt/llvm/bin/ld64.lld", # Use LLD Linker
"-Zshare-generics=y", # (Nightly) Make the current crate share its generic instantiations
"-Zthreads=8", # (Nightly) Use improved multithreading with 8 threads.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Can any MacOS users test if this works well? It might reduce performance on MacOS or even not work at all.

Copy link
Member

@BD103 BD103 Jan 29, 2024

Choose a reason for hiding this comment

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

After testing it on my M1 Mac, this option actually seems to slow down the compilation process. I built with the --timings option to generate the following charts. The time increases from 58.4 seconds to 63.6 seconds.

Before:

image image

After:

image image

Edit: Redid timings so the only difference between "Before" and "After" was commenting out -Zthreads=0.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Is this an average or just one test?

Copy link
Member

Choose a reason for hiding this comment

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

That was just one test. Here's my results running cargo clean && cargo +nightly build with and without -Zthreads=0 commented out.

Before

  • 1:03s
  • 1:06s
  • 1:11s
  • 1:12s
  • 1:08s
  • 0:59.4s
  • 1:03s

Average: 1:06.05s

After

  • 1:05s
  • 1:11s
  • 1:13s
  • 1:20s
  • 1:07s
  • 1:11s
  • 1:12s

Average: 1:11.29s

]

[target.aarch64-apple-darwin]
Expand All @@ -25,8 +27,11 @@ rustflags = [
]

[target.x86_64-pc-windows-msvc]
linker = "rust-lld.exe" # Use LLD Linker
rustflags = ["-Zshare-generics=n"]
linker = "rust-lld.exe" # Use LLD Linker
rustflags = [
"-Zshare-generics=n",
"-Zthreads=8", # (Nightly) Use improved multithreading with 8 threads.
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Windows users should also test this out

]

# Optional: Uncommenting the following improves compile times, but reduces the amount of debug info to 'line number tables only'
# In most cases the gains are negligible, but if you are on macos and have slow compile times you should see significant gains.
Expand Down
Loading