Skip to content

Commit

Permalink
change thread count calculation
Browse files Browse the repository at this point in the history
  • Loading branch information
mookums committed Sep 10, 2024
1 parent d266b19 commit 8a58cc5
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/core/server.zig
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 8a58cc5

Please sign in to comment.