From 78c5a994cf98dedf38c2443305ab840fce6a4b4f Mon Sep 17 00:00:00 2001 From: Dylan Conway Date: Tue, 5 Dec 2023 13:45:22 -0800 Subject: [PATCH] increase --- src/bun.js/web_worker.zig | 2 +- src/bun.zig | 2 +- src/http.zig | 2 +- src/network_thread.zig | 2 +- src/thread_pool.zig | 12 ++++++------ src/work_pool.zig | 2 +- 6 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/bun.js/web_worker.zig b/src/bun.js/web_worker.zig index 0d092fcab85ae2..99f336a72504b0 100644 --- a/src/bun.js/web_worker.zig +++ b/src/bun.js/web_worker.zig @@ -51,7 +51,7 @@ pub const WebWorker = struct { worker.cpp_worker = ptr; var thread = std.Thread.spawn( - .{ .stack_size = bun.default_stack_size }, + .{ .stack_size = bun.default_thread_stack_size }, startWithErrorHandling, .{worker}, ) catch { diff --git a/src/bun.zig b/src/bun.zig index e92ee09928cf30..2ba4014713cd46 100644 --- a/src/bun.zig +++ b/src/bun.zig @@ -1198,7 +1198,7 @@ pub const AsyncIO = @import("async_io"); pub const logger = @import("./logger.zig"); pub const ThreadPool = @import("./thread_pool.zig"); -pub const default_stack_size = ThreadPool.default_stack_size; +pub const default_thread_stack_size = ThreadPool.default_thread_stack_size; pub const picohttp = @import("./deps/picohttp.zig"); pub const uws = @import("./deps/uws.zig"); pub const BoringSSL = @import("./boringssl.zig"); diff --git a/src/http.zig b/src/http.zig index a7d8960c4d0cf0..431aebcef7f787 100644 --- a/src/http.zig +++ b/src/http.zig @@ -710,7 +710,7 @@ pub const HTTPThread = struct { const thread = try std.Thread.spawn( .{ - .stack_size = bun.default_stack_size, + .stack_size = bun.default_thread_stack_size, }, comptime onStart, .{ diff --git a/src/network_thread.zig b/src/network_thread.zig index 562f86ad052b5e..066aba365b1ae2 100644 --- a/src/network_thread.zig +++ b/src/network_thread.zig @@ -191,7 +191,7 @@ pub fn init() !void { global.waker = try AsyncIO.Waker.init(@import("root").bun.default_allocator); } - global.thread = try std.Thread.spawn(.{ .stack_size = bun.default_stack_size }, onStartIOThread, .{ + global.thread = try std.Thread.spawn(.{ .stack_size = bun.default_thread_stack_size }, onStartIOThread, .{ global.waker, }); global.thread.detach(); diff --git a/src/thread_pool.zig b/src/thread_pool.zig index 1cdd1fd4de9559..2fa56bdb92473f 100644 --- a/src/thread_pool.zig +++ b/src/thread_pool.zig @@ -52,7 +52,7 @@ const Sync = packed struct { /// Configuration options for the thread pool. /// TODO: add CPU core affinity? pub const Config = struct { - stack_size: u32 = default_stack_size, + stack_size: u32 = default_thread_stack_size, max_threads: u32, }; @@ -440,9 +440,9 @@ inline fn notify(self: *ThreadPool, is_waking: bool) void { return self.notifySlow(is_waking); } -pub const default_stack_size = brk: { - // 2mb - const default = 2 * 1024 * 1024; +pub const default_thread_stack_size = brk: { + // 4mb + const default = 4 * 1024 * 1024; if (!Environment.isMac) break :brk default; @@ -473,7 +473,7 @@ pub fn warm(self: *ThreadPool, count: u14) void { .Release, .Monotonic, ) orelse break)); - const spawn_config = std.Thread.SpawnConfig{ .stack_size = default_stack_size }; + const spawn_config = std.Thread.SpawnConfig{ .stack_size = default_thread_stack_size }; const thread = std.Thread.spawn(spawn_config, Thread.run, .{self}) catch return self.unregister(null); thread.detach(); } @@ -515,7 +515,7 @@ noinline fn notifySlow(self: *ThreadPool, is_waking: bool) void { // We signaled to spawn a new thread if (can_wake and sync.spawned < self.max_threads) { - const spawn_config = std.Thread.SpawnConfig{ .stack_size = default_stack_size }; + const spawn_config = std.Thread.SpawnConfig{ .stack_size = default_thread_stack_size }; const thread = std.Thread.spawn(spawn_config, Thread.run, .{self}) catch return self.unregister(null); // if (self.name.len > 0) thread.setName(self.name) catch {}; return thread.detach(); diff --git a/src/work_pool.zig b/src/work_pool.zig index eb74fd4647699f..c0c5649d445822 100644 --- a/src/work_pool.zig +++ b/src/work_pool.zig @@ -14,7 +14,7 @@ pub fn NewWorkPool(comptime max_threads: ?usize) type { pool = ThreadPool.init(.{ .max_threads = max_threads orelse @max(@as(u32, @truncate(std.Thread.getCpuCount() catch 0)), 2), - .stack_size = ThreadPool.default_stack_size, + .stack_size = ThreadPool.default_thread_stack_size, }); return &pool; }