diff options
author | 2022-03-02 21:17:50 -0800 | |
---|---|---|
committer | 2022-03-02 21:17:50 -0800 | |
commit | 871780fd287eef1d8784b90d5d0c36d009085beb (patch) | |
tree | 506d71fa668f142f10da780d44d1d731a77e7217 | |
parent | 4c5eb4b4db851e478b9eb45af0be9b650ee1e3ff (diff) | |
download | bun-871780fd287eef1d8784b90d5d0c36d009085beb.tar.gz bun-871780fd287eef1d8784b90d5d0c36d009085beb.tar.zst bun-871780fd287eef1d8784b90d5d0c36d009085beb.zip |
Make http requests a little faster
-rw-r--r-- | src/http/async_socket.zig | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/src/http/async_socket.zig b/src/http/async_socket.zig index dcdeb8b62..7c61d994d 100644 --- a/src/http/async_socket.zig +++ b/src/http/async_socket.zig @@ -121,10 +121,15 @@ fn doConnect(this: *AsyncSocket, name: []const u8, port: u16) ConnectError!void this.was_keepalive = false; outer: while (true) { + // getAddrList allocates, but it really shouldn't + // it allocates about 1024 bytes, so we can just make it a stack allocation + var stack_fallback_allocator = std.heap.stackFallback(4096, getAllocator()); + var allocator = stack_fallback_allocator.get(); + // on macOS, getaddrinfo() is very slow // If you send ~200 network requests, about 1.5s is spent on getaddrinfo() // So, we cache this. - var list = NetworkThread.getAddressList(getAllocator(), name, port) catch |err| { + var list = NetworkThread.getAddressList(allocator, name, port) catch |err| { return @errSetCast(ConnectError, err); }; |