From 8a58cc5742f14db0cedb00dde1ca5c260b1ba933 Mon Sep 17 00:00:00 2001 From: Muki Kiboigo Date: Tue, 10 Sep 2024 16:03:47 -0700 Subject: [PATCH] change thread count calculation --- src/core/server.zig | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/core/server.zig b/src/core/server.zig index 9d1a2b8..c01c313 100644 --- a/src/core/server.zig +++ b/src/core/server.zig @@ -657,14 +657,15 @@ pub fn Server( const thread_count = blk: { switch (count) { - .auto => break :blk @max(try std.Thread.getCpuCount() / 2 - 1, 1), + .auto => break :blk @max((std.Thread.getCpuCount() catch break :blk 2) / 2 - 1, 2), .count => |inner| break :blk inner, } }; - log.info("spawning {d} thread[s] + 1 root thread", .{thread_count}); + log.info("spawning {d} thread[s]", .{thread_count}); - for (0..thread_count) |i| { + // spawn (count-1) new threads. + for (0..thread_count - 1) |i| { try threads.append(try std.Thread.spawn(.{ .allocator = allocator }, struct { fn handler_fn( p_config: ProtocolConfig,