Skip to content

Managed client: fixed socket buffers cap fetch speed on high-latency links #1312

Open

Description

@vmzubov

The managed client sets the socket receive and send buffers to PacketSize in GdsConnection.Connect and ConnectAsync (master):

socket.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReceiveBuffer, PacketSize);
socket.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.SendBuffer, PacketSize);

A receive buffer set by hand turns off receive window auto-tuning for that socket, so throughput is capped at roughly PacketSize / round-trip time. With the default 8192 and a 75 ms round trip that is about 100 KB/s, whatever the bandwidth. Measurements are in my comment on #1197: the same query took 163 s with the default PacketSize, 54 s with 32767, and 20-23 s with the two lines removed, the same as fbclient on that link.

I am opening this separately because #1264 decouples the blob segment size from PacketSize, and once it is merged #1197 will be closed. In #1264 PacketSize stays as the socket buffer setting, which makes sense to me, so here is a proposal that keeps it:

  • if Packet Size is not in the connection string, do not set ReceiveBuffer and SendBuffer and leave them to the OS, as fbclient does (src/remote/inet.cpp sets only TCP_NODELAY and SO_KEEPALIVE);
  • if it is set explicitly, apply it as today.

Nothing changes for anyone who sets Packet Size on purpose; the default gets the OS behaviour. On a LAN there is no visible difference either way.

If this direction works for you, I can open a pull request with the change and a test.

The analysis was done with the help of an AI assistant (Claude).

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions