authorgravatar for alex@alexrp.comAlex Rønne Petersen <alex@alexrp.com> 2025-12-03 01:06:31+01:00
committergravatar for alex@alexrp.comAlex Rønne Petersen <alex@alexrp.com> 2025-12-04 20:06:12+01:00
log2728eb5d5ed0a7cdf33140b31ffa364eaffd7afd
tree7d33eba7fc15f31c2941e0152d7d3a7e8003e32a
parent44543800a59968a4c7a2cdcf10837bc17b52553d
signaturebadge-check Signed by SSH key SHA256:7B/LJ7bpR1eX8aCXSr4mtd5M45VMPKcx9zY8e95b5QM

build: adjust max_rss on a per-CI-host basis

This avoids pessimizing concurrency on all machines due to e.g. the macOS machine having high memory usage across the board due to 16K page size. This also adds max_rss to test-unit and test-c-abi since those tend to eat a decent chunk of memory too.

2 files changed, 168 insertions(+), 7 deletions(-)

build.zig+161-5
......@@ -465,8 +465,29 @@ pub fn build(b: *std.Build) !void {
465465 .skip_linux = skip_linux,
466466 .skip_llvm = skip_llvm,
467467 .skip_libc = skip_libc,
468 // 3888779264 was observed on an x86_64-linux-gnu host.
469 .max_rss = 4000000000,
468 .max_rss = switch (b.graph.host.result.os.tag) {
469 .freebsd => switch (b.graph.host.result.cpu.arch) {
470 .x86_64 => 1_060_217_241,
471 else => 1_100_000_000,
472 },
473 .linux => switch (b.graph.host.result.cpu.arch) {
474 .aarch64 => 659_809_075,
475 .loongarch64 => 598_902_374,
476 .riscv64 => 731_258_880,
477 .s390x => 580_596_121,
478 .x86_64 => 3_290_894_745,
479 else => 3_300_000_000,
480 },
481 .macos => switch (b.graph.host.result.cpu.arch) {
482 .aarch64 => 767_736_217,
483 else => 800_000_000,
484 },
485 .windows => switch (b.graph.host.result.cpu.arch) {
486 .x86_64 => 603_070_054,
487 else => 700_000_000,
488 },
489 else => 3_300_000_000,
490 },
470491 }));
471492
472493 test_modules_step.dependOn(tests.addModuleTests(b, .{
......@@ -491,6 +512,29 @@ pub fn build(b: *std.Build) !void {
491512 .skip_llvm = skip_llvm,
492513 .skip_libc = true,
493514 .no_builtin = true,
515 .max_rss = switch (b.graph.host.result.os.tag) {
516 .freebsd => switch (b.graph.host.result.cpu.arch) {
517 .x86_64 => 743_802_470,
518 else => 800_000_000,
519 },
520 .linux => switch (b.graph.host.result.cpu.arch) {
521 .aarch64 => 639_565_414,
522 .loongarch64 => 598_884_352,
523 .riscv64 => 636_429_516,
524 .s390x => 574_166_630,
525 .x86_64 => 764_861_644,
526 else => 800_000_000,
527 },
528 .macos => switch (b.graph.host.result.cpu.arch) {
529 .aarch64 => 701_413_785,
530 else => 800_000_000,
531 },
532 .windows => switch (b.graph.host.result.cpu.arch) {
533 .x86_64 => 536_414_208,
534 else => 600_000_000,
535 },
536 else => 800_000_000,
537 },
494538 }));
495539
496540 test_modules_step.dependOn(tests.addModuleTests(b, .{
......@@ -515,6 +559,29 @@ pub fn build(b: *std.Build) !void {
515559 .skip_llvm = skip_llvm,
516560 .skip_libc = true,
517561 .no_builtin = true,
562 .max_rss = switch (b.graph.host.result.os.tag) {
563 .freebsd => switch (b.graph.host.result.cpu.arch) {
564 .x86_64 => 557_892_403,
565 else => 600_000_000,
566 },
567 .linux => switch (b.graph.host.result.cpu.arch) {
568 .aarch64 => 615_302_758,
569 .loongarch64 => 598_974_464,
570 .riscv64 => 382_786_764,
571 .s390x => 395_555_635,
572 .x86_64 => 692_348_518,
573 else => 700_000_000,
574 },
575 .macos => switch (b.graph.host.result.cpu.arch) {
576 .aarch64 => 451_389_030,
577 else => 500_000_000,
578 },
579 .windows => switch (b.graph.host.result.cpu.arch) {
580 .x86_64 => 367_747_072,
581 else => 400_000_000,
582 },
583 else => 700_000_000,
584 },
518585 }));
519586
520587 test_modules_step.dependOn(tests.addModuleTests(b, .{
......@@ -538,8 +605,29 @@ pub fn build(b: *std.Build) !void {
538605 .skip_linux = skip_linux,
539606 .skip_llvm = skip_llvm,
540607 .skip_libc = skip_libc,
541 // I observed a value of 5605064704 on the M2 CI.
542 .max_rss = 6165571174,
608 .max_rss = switch (b.graph.host.result.os.tag) {
609 .freebsd => switch (b.graph.host.result.cpu.arch) {
610 .x86_64 => 3_756_422_348,
611 else => 3_800_000_000,
612 },
613 .linux => switch (b.graph.host.result.cpu.arch) {
614 .aarch64 => 6_732_817_203,
615 .loongarch64 => 3_216_349_593,
616 .riscv64 => 3_570_899_763,
617 .s390x => 3_652_514_201,
618 .x86_64 => 3_249_546_854,
619 else => 6_800_000_000,
620 },
621 .macos => switch (b.graph.host.result.cpu.arch) {
622 .aarch64 => 8_273_795_481,
623 else => 8_300_000_000,
624 },
625 .windows => switch (b.graph.host.result.cpu.arch) {
626 .x86_64 => 3_750_236_160,
627 else => 3_800_000_000,
628 },
629 else => 8_300_000_000,
630 },
543631 }));
544632
545633 const unit_tests_step = b.step("test-unit", "Run the compiler source unit tests");
......@@ -555,6 +643,29 @@ pub fn build(b: *std.Build) !void {
555643 .use_llvm = use_llvm,
556644 .use_lld = use_llvm,
557645 .zig_lib_dir = b.path("lib"),
646 .max_rss = switch (b.graph.host.result.os.tag) {
647 .freebsd => switch (b.graph.host.result.cpu.arch) {
648 .x86_64 => 2_188_099_584,
649 else => 2_200_000_000,
650 },
651 .linux => switch (b.graph.host.result.cpu.arch) {
652 .aarch64 => 1_991_934_771,
653 .loongarch64 => 1_844_538_572,
654 .riscv64 => 2_459_003_289,
655 .s390x => 1_781_248_409,
656 .x86_64 => 977_192_550,
657 else => 2_500_000_000,
658 },
659 .macos => switch (b.graph.host.result.cpu.arch) {
660 .aarch64 => 2_062_393_344,
661 else => 2_100_000_000,
662 },
663 .windows => switch (b.graph.host.result.cpu.arch) {
664 .x86_64 => 1_953_087_488,
665 else => 2_000_000_000,
666 },
667 else => 2_500_000_000,
668 },
558669 });
559670 if (link_libc) {
560671 unit_tests.root_module.link_libc = true;
......@@ -580,6 +691,29 @@ pub fn build(b: *std.Build) !void {
580691 .skip_linux = skip_linux,
581692 .skip_llvm = skip_llvm,
582693 .skip_release = skip_release,
694 .max_rss = switch (b.graph.host.result.os.tag) {
695 .freebsd => switch (b.graph.host.result.cpu.arch) {
696 .x86_64 => 727_221_862,
697 else => 800_000_000,
698 },
699 .linux => switch (b.graph.host.result.cpu.arch) {
700 .aarch64 => 1_318_185_369,
701 .loongarch64 => 1_422_904_524,
702 .riscv64 => 449_924_710,
703 .s390x => 1_946_743_603,
704 .x86_64 => 2_139_993_292,
705 else => 2_200_000_000,
706 },
707 .macos => switch (b.graph.host.result.cpu.arch) {
708 .aarch64 => 1_813_612_134,
709 else => 1_900_000_000,
710 },
711 .windows => switch (b.graph.host.result.cpu.arch) {
712 .x86_64 => 386_287_616,
713 else => 400_000_000,
714 },
715 else => 2_200_000_000,
716 },
583717 }));
584718 test_step.dependOn(tests.addLinkTests(b, enable_macos_sdk, enable_ios_sdk, enable_symlinks_windows));
585719 test_step.dependOn(tests.addStackTraceTests(b, test_filters, skip_non_native));
......@@ -735,7 +869,29 @@ fn addCompilerMod(b: *std.Build, options: AddCompilerModOptions) *std.Build.Modu
735869fn addCompilerStep(b: *std.Build, options: AddCompilerModOptions) *std.Build.Step.Compile {
736870 const exe = b.addExecutable(.{
737871 .name = "zig",
738 .max_rss = 7_800_000_000,
872 .max_rss = switch (b.graph.host.result.os.tag) {
873 .freebsd => switch (b.graph.host.result.cpu.arch) {
874 .x86_64 => 6_044_158_771,
875 else => 6_100_000_000,
876 },
877 .linux => switch (b.graph.host.result.cpu.arch) {
878 .aarch64 => 6_240_805_683,
879 .loongarch64 => 5_024_158_515,
880 .riscv64 => 6_996_309_196,
881 .s390x => 4_997_174_476,
882 .x86_64 => 5_486_090_649,
883 else => 7_000_000_000,
884 },
885 .macos => switch (b.graph.host.result.cpu.arch) {
886 .aarch64 => 6_639_145_779,
887 else => 6_700_000_000,
888 },
889 .windows => switch (b.graph.host.result.cpu.arch) {
890 .x86_64 => 5_770_394_009,
891 else => 5_800_000_000,
892 },
893 else => 7_000_000_000,
894 },
739895 .root_module = addCompilerMod(b, options),
740896 });
741897 exe.stack_size = stack_size;
test/tests.zig+7-2
......@@ -2344,8 +2344,11 @@ fn addOneModuleTest(
23442344 const libc_suffix = if (test_target.link_libc == true) "-libc" else "";
23452345 const model_txt = target.cpu.model.name;
23462346
2347 // wasm32-wasi builds need more RAM, idk why
2348 const max_rss = if (target.os.tag == .wasi)
2347 // These emulated targets need a lot more RAM for unknown reasons.
2348 const max_rss = if (mem.eql(u8, options.name, "std") and
2349 (target.cpu.arch == .hexagon or
2350 (target.cpu.arch.isRISCV() and !resolved_target.query.isNative()) or
2351 target.cpu.arch.isWasm()))
23492352 options.max_rss * 2
23502353 else
23512354 options.max_rss;
......@@ -2532,6 +2535,7 @@ const CAbiTestOptions = struct {
25322535 skip_linux: bool,
25332536 skip_llvm: bool,
25342537 skip_release: bool,
2538 max_rss: usize = 0,
25352539};
25362540
25372541pub fn addCAbiTests(b: *std.Build, options: CAbiTestOptions) *Step {
......@@ -2604,6 +2608,7 @@ pub fn addCAbiTests(b: *std.Build, options: CAbiTestOptions) *Step {
26042608 .root_module = test_mod,
26052609 .use_llvm = c_abi_target.use_llvm,
26062610 .use_lld = c_abi_target.use_lld,
2611 .max_rss = options.max_rss,
26072612 });
26082613
26092614 // This test is intentionally trying to check if the external ABI is