mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-04-25 17:25:08 +02:00
RequestServer: Increase RequestPipe socket buffer sizes
The RequestPipe uses a socketpair for streaming response body data from RequestServer to WebContent. On macOS, the default socket buffer size for AF_LOCAL sockets is only ~8KB, which meant every read/write syscall could only transfer ~8KB at a time. For large responses, this resulted in thousands of tiny reads with significant per-read overhead. Increase the send and receive buffer sizes to 512KB, matching the approach already used by IPC::TransportSocket. This dramatically improves throughput for large response bodies -- for example, fetching a 25MB file from localhost went from ~850ms to ~25ms in testing.
This commit is contained in:
Notes:
github-actions[bot]
2026-03-15 13:07:07 +00:00
Author: https://github.com/awesomekling Commit: https://github.com/LadybirdBrowser/ladybird/commit/669bc04295b Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/8430 Reviewed-by: https://github.com/Hendiadyoin1 Reviewed-by: https://github.com/trflynn89 ✅
@@ -48,6 +48,14 @@ ErrorOr<RequestPipe> RequestPipe::create()
|
||||
int option = 1;
|
||||
TRY(Core::System::ioctl(socket_fds[0], FIONBIO, &option));
|
||||
TRY(Core::System::ioctl(socket_fds[1], FIONBIO, &option));
|
||||
|
||||
// Increase socket buffer sizes from OS default (~8KB on macOS) to allow
|
||||
// larger writes/reads per syscall, significantly improving throughput for
|
||||
// large response bodies.
|
||||
static constexpr int buffer_size = 512 * KiB;
|
||||
(void)Core::System::setsockopt(socket_fds[0], SOL_SOCKET, SO_RCVBUF, &buffer_size, sizeof(buffer_size));
|
||||
(void)Core::System::setsockopt(socket_fds[1], SOL_SOCKET, SO_SNDBUF, &buffer_size, sizeof(buffer_size));
|
||||
|
||||
return RequestPipe(socket_fds[0], socket_fds[1]);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user