Compare commits

...

6 commits

Author SHA1 Message Date
Alex Rønne Petersen
9e56be97c6
build: add some missing darwin tags
Some checks are pending
ci / aarch64-linux-debug (push) Waiting to run
ci / aarch64-linux-release (push) Waiting to run
ci / aarch64-macos-debug (push) Waiting to run
ci / aarch64-macos-release (push) Waiting to run
ci / loongarch64-linux-debug (push) Waiting to run
ci / loongarch64-linux-release (push) Waiting to run
ci / riscv64-linux-debug (push) Waiting to run
ci / riscv64-linux-release (push) Waiting to run
ci / s390x-linux-debug (push) Waiting to run
ci / s390x-linux-release (push) Waiting to run
ci / x86_64-freebsd-debug (push) Waiting to run
ci / x86_64-freebsd-release (push) Waiting to run
ci / x86_64-linux-debug (push) Waiting to run
ci / x86_64-linux-debug-llvm (push) Waiting to run
ci / x86_64-linux-release (push) Waiting to run
ci / x86_64-windows-debug (push) Waiting to run
ci / x86_64-windows-release (push) Waiting to run
2025-12-03 07:32:37 +01:00
Alex Rønne Petersen
edb1801152
set max_rss=1 on some tests to find out the actual values 2025-12-03 07:32:37 +01:00
Alex Rønne Petersen
fa0b57202c
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.
2025-12-03 07:32:37 +01:00
Alex Rønne Petersen
e2e64fd9c4
std.process.Child: enable rusage collection for dragonfly, netbsd, openbsd 2025-12-03 07:32:35 +01:00
Alex Rønne Petersen
2ca48d323b
std.c: add rusage for dragonfly, netbsd, openbsd 2025-12-03 07:31:50 +01:00
Alex Rønne Petersen
e268840076
std.process.Child: enable rusage collection for freebsd, illumos, serenity 2025-12-03 07:31:47 +01:00
5 changed files with 172 additions and 10 deletions

View file

@ -5,6 +5,7 @@ on:
push: push:
branches: branches:
- master - master
- max-rss-tuning
workflow_dispatch: workflow_dispatch:
concurrency: concurrency:

123
build.zig
View file

@ -459,8 +459,29 @@ pub fn build(b: *std.Build) !void {
.skip_linux = skip_linux, .skip_linux = skip_linux,
.skip_llvm = skip_llvm, .skip_llvm = skip_llvm,
.skip_libc = skip_libc, .skip_libc = skip_libc,
// 3888779264 was observed on an x86_64-linux-gnu host. .max_rss = switch (b.graph.host.result.os.tag) {
.max_rss = 4000000000, .freebsd => switch (b.graph.host.result.cpu.arch) {
.x86_64 => 1, // TODO
else => 0,
},
.linux => switch (b.graph.host.result.cpu.arch) {
.aarch64 => 659809075,
.loongarch64 => 598902374,
.riscv64 => 1, // TODO
.s390x => 580596121,
.x86_64 => 3290894745,
else => 0,
},
.macos => switch (b.graph.host.result.cpu.arch) {
.aarch64 => 767736217,
else => 0,
},
.windows => switch (b.graph.host.result.cpu.arch) {
.x86_64 => 603070054,
else => 0,
},
else => 0,
},
})); }));
test_modules_step.dependOn(tests.addModuleTests(b, .{ test_modules_step.dependOn(tests.addModuleTests(b, .{
@ -483,6 +504,29 @@ pub fn build(b: *std.Build) !void {
.skip_llvm = skip_llvm, .skip_llvm = skip_llvm,
.skip_libc = true, .skip_libc = true,
.no_builtin = true, .no_builtin = true,
.max_rss = switch (b.graph.host.result.os.tag) {
.freebsd => switch (b.graph.host.result.cpu.arch) {
.x86_64 => 1, // TODO
else => 0,
},
.linux => switch (b.graph.host.result.cpu.arch) {
.aarch64 => 639565414,
.loongarch64 => 598884352,
.riscv64 => 1, // TODO
.s390x => 574166630,
.x86_64 => 764861644,
else => 0,
},
.macos => switch (b.graph.host.result.cpu.arch) {
.aarch64 => 701413785,
else => 0,
},
.windows => switch (b.graph.host.result.cpu.arch) {
.x86_64 => 536414208,
else => 0,
},
else => 0,
},
})); }));
test_modules_step.dependOn(tests.addModuleTests(b, .{ test_modules_step.dependOn(tests.addModuleTests(b, .{
@ -505,6 +549,29 @@ pub fn build(b: *std.Build) !void {
.skip_llvm = skip_llvm, .skip_llvm = skip_llvm,
.skip_libc = true, .skip_libc = true,
.no_builtin = true, .no_builtin = true,
.max_rss = switch (b.graph.host.result.os.tag) {
.freebsd => switch (b.graph.host.result.cpu.arch) {
.x86_64 => 1, // TODO
else => 0,
},
.linux => switch (b.graph.host.result.cpu.arch) {
.aarch64 => 615302758,
.loongarch64 => 598974464,
.riscv64 => 1, // TODO
.s390x => 395555635,
.x86_64 => 528128409,
else => 0,
},
.macos => switch (b.graph.host.result.cpu.arch) {
.aarch64 => 451389030,
else => 0,
},
.windows => switch (b.graph.host.result.cpu.arch) {
.x86_64 => 317852057,
else => 0,
},
else => 0,
},
})); }));
test_modules_step.dependOn(tests.addModuleTests(b, .{ test_modules_step.dependOn(tests.addModuleTests(b, .{
@ -526,8 +593,29 @@ pub fn build(b: *std.Build) !void {
.skip_linux = skip_linux, .skip_linux = skip_linux,
.skip_llvm = skip_llvm, .skip_llvm = skip_llvm,
.skip_libc = skip_libc, .skip_libc = skip_libc,
// I observed a value of 5605064704 on the M2 CI. .max_rss = switch (b.graph.host.result.os.tag) {
.max_rss = 6165571174, .freebsd => switch (b.graph.host.result.cpu.arch) {
.x86_64 => 1, // TODO
else => 0,
},
.linux => switch (b.graph.host.result.cpu.arch) {
.aarch64 => 6732817203,
.loongarch64 => 3216349593,
.riscv64 => 1, // TODO
.s390x => 3652514201,
.x86_64 => 5554053120,
else => 0,
},
.macos => switch (b.graph.host.result.cpu.arch) {
.aarch64 => 8273795481,
else => 0,
},
.windows => switch (b.graph.host.result.cpu.arch) {
.x86_64 => 3750236160,
else => 0,
},
else => 0,
},
})); }));
const unit_tests_step = b.step("test-unit", "Run the compiler source unit tests"); const unit_tests_step = b.step("test-unit", "Run the compiler source unit tests");
@ -543,6 +631,7 @@ pub fn build(b: *std.Build) !void {
.use_llvm = use_llvm, .use_llvm = use_llvm,
.use_lld = use_llvm, .use_lld = use_llvm,
.zig_lib_dir = b.path("lib"), .zig_lib_dir = b.path("lib"),
.max_rss = 1,
}); });
if (link_libc) { if (link_libc) {
unit_tests.root_module.link_libc = true; unit_tests.root_module.link_libc = true;
@ -721,7 +810,29 @@ fn addCompilerMod(b: *std.Build, options: AddCompilerModOptions) *std.Build.Modu
fn addCompilerStep(b: *std.Build, options: AddCompilerModOptions) *std.Build.Step.Compile { fn addCompilerStep(b: *std.Build, options: AddCompilerModOptions) *std.Build.Step.Compile {
const exe = b.addExecutable(.{ const exe = b.addExecutable(.{
.name = "zig", .name = "zig",
.max_rss = 7_800_000_000, .max_rss = switch (b.graph.host.result.os.tag) {
.freebsd => switch (b.graph.host.result.cpu.arch) {
.x86_64 => 1, // TODO
else => 0,
},
.linux => switch (b.graph.host.result.cpu.arch) {
.aarch64 => 6240805683,
.loongarch64 => 5024158515,
.riscv64 => 1, // TODO
.s390x => 4997174476,
.x86_64 => 5486090649,
else => 0,
},
.macos => switch (b.graph.host.result.cpu.arch) {
.aarch64 => 6639145779,
else => 0,
},
.windows => switch (b.graph.host.result.cpu.arch) {
.x86_64 => 5770394009,
else => 0,
},
else => 0,
},
.root_module = addCompilerMod(b, options), .root_module = addCompilerMod(b, options),
}); });
exe.stack_size = stack_size; exe.stack_size = stack_size;
@ -798,7 +909,7 @@ fn addCmakeCfgOptionsToExe(
}; };
mod.linkSystemLibrary("unwind", .{}); mod.linkSystemLibrary("unwind", .{});
}, },
.ios, .macos, .watchos, .tvos, .visionos => { .driverkit, .ios, .maccatalyst, .macos, .tvos, .visionos, .watchos => {
mod.link_libcpp = true; mod.link_libcpp = true;
}, },
.windows => { .windows => {

View file

@ -4471,7 +4471,7 @@ pub const rusage = switch (native_os) {
pub const SELF = 1; pub const SELF = 1;
pub const CHILDREN = 2; pub const CHILDREN = 2;
}, },
.freebsd => extern struct { .freebsd, .openbsd => extern struct {
utime: timeval, utime: timeval,
stime: timeval, stime: timeval,
maxrss: c_long, maxrss: c_long,
@ -4493,6 +4493,27 @@ pub const rusage = switch (native_os) {
pub const CHILDREN = -1; pub const CHILDREN = -1;
pub const THREAD = 1; pub const THREAD = 1;
}, },
.dragonfly, .netbsd => extern struct {
utime: timeval,
stime: timeval,
maxrss: c_long,
ixrss: c_long,
idrss: c_long,
isrss: c_long,
minflt: c_long,
majflt: c_long,
nswap: c_long,
inblock: c_long,
oublock: c_long,
msgsnd: c_long,
msgrcv: c_long,
nsignals: c_long,
nvcsw: c_long,
nivcsw: c_long,
pub const SELF = 0;
pub const CHILDREN = -1;
},
else => void, else => void,
}; };

View file

@ -122,7 +122,7 @@ pub const ResourceUsageStatistics = struct {
/// if available. /// if available.
pub inline fn getMaxRss(rus: ResourceUsageStatistics) ?usize { pub inline fn getMaxRss(rus: ResourceUsageStatistics) ?usize {
switch (native_os) { switch (native_os) {
.linux => { .dragonfly, .freebsd, .netbsd, .openbsd, .illumos, .linux, .serenity => {
if (rus.rusage) |ru| { if (rus.rusage) |ru| {
return @as(usize, @intCast(ru.maxrss)) * 1024; return @as(usize, @intCast(ru.maxrss)) * 1024;
} else { } else {
@ -149,7 +149,21 @@ pub const ResourceUsageStatistics = struct {
} }
const rusage_init = switch (native_os) { const rusage_init = switch (native_os) {
.linux, .driverkit, .ios, .maccatalyst, .macos, .tvos, .visionos, .watchos => @as(?posix.rusage, null), .dragonfly,
.freebsd,
.netbsd,
.openbsd,
.illumos,
.linux,
.serenity,
.driverkit,
.ios,
.maccatalyst,
.macos,
.tvos,
.visionos,
.watchos,
=> @as(?posix.rusage, null),
.windows => @as(?windows.VM_COUNTERS, null), .windows => @as(?windows.VM_COUNTERS, null),
else => {}, else => {},
}; };
@ -486,7 +500,21 @@ fn waitUnwrappedPosix(self: *ChildProcess) void {
const res: posix.WaitPidResult = res: { const res: posix.WaitPidResult = res: {
if (self.request_resource_usage_statistics) { if (self.request_resource_usage_statistics) {
switch (native_os) { switch (native_os) {
.linux, .driverkit, .ios, .maccatalyst, .macos, .tvos, .visionos, .watchos => { .dragonfly,
.freebsd,
.netbsd,
.openbsd,
.illumos,
.linux,
.serenity,
.driverkit,
.ios,
.maccatalyst,
.macos,
.tvos,
.visionos,
.watchos,
=> {
var ru: posix.rusage = undefined; var ru: posix.rusage = undefined;
const res = posix.wait4(self.id, 0, &ru); const res = posix.wait4(self.id, 0, &ru);
self.resource_usage_statistics.rusage = ru; self.resource_usage_statistics.rusage = ru;

View file

@ -2595,6 +2595,7 @@ pub fn addCAbiTests(b: *std.Build, options: CAbiTestOptions) *Step {
.root_module = test_mod, .root_module = test_mod,
.use_llvm = c_abi_target.use_llvm, .use_llvm = c_abi_target.use_llvm,
.use_lld = c_abi_target.use_lld, .use_lld = c_abi_target.use_lld,
.max_rss = 1,
}); });
// This test is intentionally trying to check if the external ABI is // This test is intentionally trying to check if the external ABI is