cap debug builds to 4 server threads

This commit is contained in:
Emil Lerch 2023-06-03 13:56:45 -07:00
parent 626a2e618c
commit b335108f0d
Signed by: lobo
GPG Key ID: A7B62D657EF764F8

View File

@ -371,9 +371,14 @@ pub fn main() !void {
try installSignalHandler(); try installSignalHandler();
var server_thread_count = if (std.os.getenv("SERVER_THREAD_COUNT")) |count| var server_thread_count = if (std.os.getenv("SERVER_THREAD_COUNT")) |count|
try std.fmt.parseInt(usize, count, 10) try std.fmt.parseInt(usize, count, 10)
else else switch (builtin.mode) {
try std.Thread.getCpuCount(); .Debug => std.math.min(4, try std.Thread.getCpuCount()),
log.info("serving using {d} threads", .{server_thread_count}); else => try std.Thread.getCpuCount(),
};
switch (builtin.mode) {
.Debug => log.info("serving using {d} threads (debug build: capped at 4)", .{server_thread_count}),
else => log.info("serving using {d} threads", .{server_thread_count}),
}
var server_threads = try std.ArrayList(std.Thread).initCapacity(allocator, server_thread_count); var server_threads = try std.ArrayList(std.Thread).initCapacity(allocator, server_thread_count);
defer server_threads.deinit(); defer server_threads.deinit();
// Set up thread pool // Set up thread pool