On Fri, 4 Apr 2003 06:52:58 +0900 Brian Candler <B.Candler / pobox.com> wrote: <snip> > How slow are you getting? I haven't benchmarked it yet, but using the setsockopt you mention below speeds things up, probably by about 2x. It's still way slower than it could/should be. > Using DRb (druby) you can typically get around 50 round-trips per second. I > guess you're getting rather less than that. I'll run a test to see, now, but still, 50/s over localhost is really unacceptably slow... it should easily get a thousand or two a second, and this is with plain ruby code. Perhaps I'll try rewriting the IO as a C extension, but this seems a bit extreme given the circumstances. > If you don't have druby installed, you might want to get it and have a look > at drb/drb.rb which does exactly what you're doing - i.e. sends a bunch of > values which are 4-byte length followed by a marshalled object. > > Also, I suggest you try setting > <sockobj>.setsockopt(Socket::IPPROTO_TCP, Socket::TCP_NODELAY, 1) > at both ends to turn off the Nagle algorithm. Nagling makes the TCP stack > wait for a short period (typically 0.1s) before sending, in case any other > data comes along which can be accumulated in the same packet. If you don't > have that set, then that will limit you to around 5 round-trips per second. Interesting, and thanks for the tip, it did noticeably improve things. I won't be happy til I'm getting an order of magnitude or two more though. :-) Maybe an OS thread that sits and adds to a buffer, or something. Actually at this time, I've optimized the frontend so that it only does 1 or 2 messages, which is decent, but eventually this will be used more interactively with more on the front end, so I'd like to see the bottleneck removed. > Regards, > > Brian. > -- Ryan Pavlik <rpav / users.sf.net> "I've got a crude stabbing implement right here with your name all over it." - 8BT