(no title)
graham_king_3 | 14 years ago
Reducing the number of send calls, in both the C and Python versions, makes them enormously faster. Go is already batching up the writes, hence the apparent speed advantage.
If you strace the client, you see that the "get" case was replying with two send calls, one for the "VALUE" line, another with the value and "END". All the time is consumed with the client waiting to receive that second message. Depending on the client, and I tried a bunch of ways, it's either in 'poll' (pylibmc), 'futex' (Go), or 'recv' (basic python socket). That second receive is about two orders of magnitude slower than the previous recv.
Why does reading that second line take so much longer?
There's more detail here: https://github.com/grahamking/Key-Value-Polyglot/pull/5#issu...
caf|14 years ago
graham_king_3|14 years ago
sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1)
It's an interaction between delayed ACKS and the Nagle algorithm, mentioned on the Nagle algorithm wikipedia page.
I'm learning a lot this week. Thanks again.