diff options
author | 2022-01-03 01:42:40 -0800 | |
---|---|---|
committer | 2022-01-03 01:42:40 -0800 | |
commit | be0c4b545139fb0d2b11e373e18dc8cba88703d9 (patch) | |
tree | 3c5ddde1d116d2787c5249e818f6c08bf57818e0 /src/thread_pool.zig | |
parent | 168c6138d8ec5cdd15c7e9c178c8a4fdd3aac75e (diff) | |
download | bun-be0c4b545139fb0d2b11e373e18dc8cba88703d9.tar.gz bun-be0c4b545139fb0d2b11e373e18dc8cba88703d9.tar.zst bun-be0c4b545139fb0d2b11e373e18dc8cba88703d9.zip |
[bun install] Reduce number of context switches
Diffstat (limited to 'src/thread_pool.zig')
-rw-r--r-- | src/thread_pool.zig | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/src/thread_pool.zig b/src/thread_pool.zig index 92443e9f1..34bc45fc0 100644 --- a/src/thread_pool.zig +++ b/src/thread_pool.zig @@ -260,9 +260,9 @@ fn _wait(self: *ThreadPool, _is_waking: bool, comptime sleep_on_idle: bool) erro } else { if (self.io) |io| { const HTTP = @import("http"); - io.run_for_ns(std.time.ns_per_us * 10) catch {}; + io.run_for_ns(std.time.ns_per_us * 100) catch {}; while (HTTP.AsyncHTTP.active_requests_count.load(.Monotonic) > HTTP.AsyncHTTP.max_simultaneous_requests) { - io.tick() catch {}; + io.run_for_ns(std.time.ns_per_us * 10) catch {}; } if (sleep_on_idle) { @@ -271,7 +271,7 @@ fn _wait(self: *ThreadPool, _is_waking: bool, comptime sleep_on_idle: bool) erro // If it's been roughly 2ms since the last network request, go to sleep! // this is 4ms because run_for_ns runs for 10 microseconds // 10 microseconds * 400 == 4ms - if (idle_network_ticks > 400) { + if (idle_network_ticks > 40) { self.idle_event.wait(); idle_network_ticks = 0; } |