[Mongrel] recv vs. read in HTTPRequest#read_socket

Zed A. Shaw zedshaw at zedshaw.com
Wed Feb 28 23:34:56 EST 2007

On Wed, 28 Feb 2007 14:47:49 -0800
Erik Hetzner <erik.hetzner at ucop.edu> wrote:

> At Mon, 05 Feb 2007 14:16:44 -0800,
> Erik Hetzner wrote:
> > Hello all,
> >
> > The following change to Mongrel::HttpRequest:
> […]
> > seems to work for me, and vastly improves the speed of the body
> > processing (quick tests reveal that using IO#read takes about 1 min 40
> > secs. and using Socket#recv takes about 9 secs on an 8.5 mb file). I
> > have been having trouble discovering the difference between read &
> > recv (I am not a socket developer by any means). Can anybody tell me
> > what sort of safety one loses by doing this with recv instead of read?
> > Thanks.
> As a followup, in case it wasn’t obvious, I was far off base here. I
> should have realized that something was wrong with such horrible
> transfer speeds. While it still seems using recv instead of read, and,
> conversely, send instead of write gives you a very slight speedup,
> most of my problem here was a runaway while loop in another thread
> (while true do; end seems to take up a lot of time).

It is interesting, but I believe that I originally used recv and it had
some problems when it came time to actually cooperate with other
threads doing read.  Could be totally bogus fantasy memory though, but
I also know there's only a few places where recv is faster, as you

Zed A. Shaw, MUDCRAP-CE Master Black Belt Sifu
http://www.awprofessional.com/title/0321483502 -- The Mongrel Book
http://www.lingr.com/room/3yXhqKbfPy8 -- Come get help.

More information about the Mongrel-users mailing list