Skip to content

Commit

Permalink
LibIPC: Increase the local socket buffer size to 128 KiB if possible
Browse files Browse the repository at this point in the history
This makes a big difference on macOS, where the default buffer size
for local sockets is 8 KiB. With bigger buffers, we don't have to
block on IPC nearly as often.
  • Loading branch information
awesomekling committed Sep 16, 2024
1 parent 275fd46 commit 9b9023d
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions Userland/Libraries/LibIPC/Connection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@ ConnectionBase::ConnectionBase(IPC::Stub& local_stub, NonnullOwnPtr<Core::LocalS
, m_socket(move(socket))
, m_local_endpoint_magic(local_endpoint_magic)
{
socklen_t socket_buffer_size = 128 * KiB;
(void)Core::System::setsockopt(m_socket->fd().value(), SOL_SOCKET, SO_SNDBUF, &socket_buffer_size, sizeof(socket_buffer_size));
(void)Core::System::setsockopt(m_socket->fd().value(), SOL_SOCKET, SO_RCVBUF, &socket_buffer_size, sizeof(socket_buffer_size));

m_responsiveness_timer = Core::Timer::create_single_shot(3000, [this] { may_have_become_unresponsive(); });
m_socket->on_ready_to_read = [this] {
NonnullRefPtr protect = *this;
Expand Down

0 comments on commit 9b9023d

Please sign in to comment.