Skip to content

Socket connection slow on Linux #36

@stanley90

Description

@stanley90

Hi,
I was debugging why my evals are slightly slow on a Linux server, but fast on local Mac:

Benchmark.measure { 100.times { r.eval('NULL') } }.real.to_f
=> 0.03s # on Mac
=> 4.1s # on Ubuntu (0.04s for each call)

I discovered that this can be fixed by setting this socket option in Connection#connect:

@s = TCPSocket::new(@hostname, @port_number)
@s.setsockopt(Socket::IPPROTO_TCP, Socket::TCP_NODELAY, 1)

Or in Talk#initialize, or as an optional argument to Connection (I don't know if it's safe to set globally).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions