[Mongrel] speed curiosity

Markus Schirp mbj at seonic.net
Sat Sep 6 14:04:57 EDT 2008


> Yeah I guess the best thing'd be to fix IO#write in the core, instead
> of a hack to work around it :)  I have no idea what  #write does but
> it appears that it is suboptimal, at least for this one distro on
> this one machine.

I do not think so, IO#write writes "exactly" n bytes even if the
operating systems socket buffer infrastructure (and ruby's one) cannot
handle "exactly" n bytes with optimal efficiency. It maybe force
sending fragmented packages, do costly buffer expansion or other time
consuming operations.

IO#writepartial let the os (and ruby?) write the "optimal" amount
of data in the current buffer and socket environment.

Maybe the usage of the select (ruby) system call Kernel#select can be
used to write to the socket "only if it would not block and or do
other costly operations" - see above.

Ruby 1.8 (maybe 1.9 too?) internally useing the select system call, to
manage threading. 

Year's ago i tried to improve the throughput using select,
unfortunately ruby 1.8 did not merge "my select call" in it's
internal select calls.

strace showed various "internal selects" and "my io selects" in
unpredictable order, interrupting each other (ruby's thread scheduler
timer?)...

It was not he perfect solution ;)
Maybe situation has changed? 

Mfg

Markus


More information about the Mongrel-users mailing list