Skip to content

Commit 33f19f7

Browse files
KapJIfacebook-github-bot
authored andcommitted
buck2: reduce number of parallel jobs for cargo on Windows
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
1 parent 69a8d08 commit 33f19f7

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

test.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,10 @@ def is_macos() -> bool:
4040
return sys.platform == "darwin"
4141

4242

43+
def is_windows() -> bool:
44+
return sys.platform == "win32"
45+
46+
4347
class Colors(Enum):
4448
# Copied from https://stackoverflow.com/questions/287871/how-to-print-colored-text-to-the-terminal
4549
HEADER = "\033[95m"
@@ -366,8 +370,14 @@ def rustdoc(package_args: List[str]) -> None:
366370

367371

368372
def test(package_args: List[str]) -> None:
369-
print_running("cargo test")
370-
run(["cargo", "test", *package_args])
373+
print_running("cargo test --lib")
374+
extra_args = []
375+
# Limit number of parallel jobs to prevent OOMs
376+
if is_windows():
377+
extra_args = ["--jobs", str(os.cpu_count() // 2)]
378+
run(["cargo", "test", "--lib", *extra_args, *package_args])
379+
print_running("cargo test --doc")
380+
run(["cargo", "test", "--doc", *extra_args, *package_args])
371381

372382

373383
def main() -> None:

0 commit comments

Comments
 (0)