Hello:

On Wed, Mar 5, 2008 at 10:29 AM, Maxim Dounin <[EMAIL PROTECTED]> wrote:

> Hello!
>
> On Wed, Mar 05, 2008 at 12:54:44PM +1100, Dean Harding wrote:
>
> > Maxim Dounin wrote:
> >> You may note that first packet was ack'ed after 100ms - default delayed
> >> ack timeout in FreeBSD.  Since your next packet is small - OS waits
> before
> >> sending it, and sends only after previous packet was ack'ed.  And since
> >> memcached don't get the whole request, it has nothing to answer - so
> ack
> >> was sent only after timeout.
> >>
> >> Setting net.inet.tcp.delayed_ack to 0 makes times much more real:
> >
> > I would suggest that you simply send the packet in one write() call,
> rather
> > than setting TCP_NODELAY. Since memcache has a maximum size of 1MB
> anyway,
> > you're not going to be creating impossibly big memory buffers
> (hopefully).
>
> Really, single write() call is wrong way to go. In addition to the
> unneeded buffer allocations this will kill performance due to
> memcpy() involved for whole data chunk.
>
> Writev() is better, but depending on task you may not be able to
> use it. E.g. for 'noreply' commands recently introduced you have
> to use TCP_NODELAY anyway.
>
> Maxim Dounin
>

Thanks all you guys very much.
Writev() seemed like a good choice.
And I want to ask is it necessary to buffer the write data, because
occasionally several small data set operations happen consequently, does
buffer them all and issue a single write will reduce the whole set time.
Although I think that has little impact on performance.

-- 
Yin Chen
School of EE & CS, Peking University

Reply via email to