Skip to content

Commit

Permalink
buck2: reduce number of parallel jobs for cargo on Windows
Browse files Browse the repository at this point in the history
Summary:
Cargo doesn't have good mechanism to limit parallerism to avoid OOMs: rust-lang/cargo#12912

Reduce number of parallel jobs to save some memory. Default is number of logical processors, so this will run twice less jobs.

If it keeps failing, we may need to reduce it further as it's still using over 25 GB .

Reviewed By: blackm00n

Differential Revision: D59054227

fbshipit-source-id: 708265891d69c0264392d0b24e29ac1f6b9818dd
  • Loading branch information
KapJI authored and facebook-github-bot committed Jun 26, 2024
1 parent 69a8d08 commit 33f19f7
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions test.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ def is_macos() -> bool:
return sys.platform == "darwin"


def is_windows() -> bool:
return sys.platform == "win32"


class Colors(Enum):
# Copied from https://stackoverflow.com/questions/287871/how-to-print-colored-text-to-the-terminal
HEADER = "\033[95m"
Expand Down Expand Up @@ -366,8 +370,14 @@ def rustdoc(package_args: List[str]) -> None:


def test(package_args: List[str]) -> None:
print_running("cargo test")
run(["cargo", "test", *package_args])
print_running("cargo test --lib")
extra_args = []
# Limit number of parallel jobs to prevent OOMs
if is_windows():
extra_args = ["--jobs", str(os.cpu_count() // 2)]
run(["cargo", "test", "--lib", *extra_args, *package_args])
print_running("cargo test --doc")
run(["cargo", "test", "--doc", *extra_args, *package_args])


def main() -> None:
Expand Down

0 comments on commit 33f19f7

Please sign in to comment.