new server snapshot

Brad Fitzpatrick brad@danga.com
Wed, 13 Aug 2003 11:39:37 -0700 (PDT)


I wanted to uncork as early as possible, right after the write, not when
we get back into the state machine.  Because how do we get back into the
drive_machine?  When some event occurs on our socket.  What event?
Finishing writing?  We don't want that delay.

If anything, why don't we move the c->wbytes == 0 down below after the
real write?

I don't like doing half the work in one cycle of the state machine and
doing the rest later.

It was bugging me, so I asked Evan if I was misunderstanding non-blocking
writes, like whether the buffer in use until it's fully written, but Evan
said it's still copied into a buffer, so we could do the free() after the
successful write().

- Brad


On Wed, 13 Aug 2003, Anatoly Vorobey wrote:

> On Tue, Aug 12, 2003 at 05:38:10PM -0700, Brad Fitzpatrick wrote:
> > * It's much faster, using TCP_CORK on Linux, TCP_NOPUSH on BSD, and
> >   TCP_NODELAY everywhere else.
>
> So what do you want to do with the write-combining code I sent the
> other day? I can make it refrain from combining writes if TCP_CORK
> is on, but do it if TCP_NODELAY is used... seems to be the best option,
> no?
>
> > * autoconf needs to --disable-static on OS X, because Darwin doesn't
> >   support static binaries.
>
> What, no static binaries at all? Amazing.
>
> Also, this little patch is almost cosmetic, but it moves the uncorking
> to the right place, from the code design point of view.
>
> main <- wcmtools          src/memcached/memcached.c
> --- src/memcached/memcached.c	2003-08-13 12:36:23.000000000 +0300
> +++ cvs/wcmtools/memcached/memcached.c	2003-08-13 12:39:35.000000000 +0300
> @@ -933,6 +933,8 @@
>                      c->write_and_free = 0;
>                  }
>                  c->state = c->write_and_go;
> +                if (c->state == conn_read)
> +                    set_cork(c, 0);
>                  break;
>              }
>              res = write(c->sfd, c->wcurr, c->wbytes);
> @@ -940,8 +942,6 @@
>                  stats.bytes_written += res;
>                  c->wcurr  += res;
>                  c->wbytes -= res;
> -                if (c->wbytes == 0 && c->write_and_go == conn_read)
> -                    set_cork(c, 0);
>                  break;
>              }
>              if (res == -1 && (errno == EAGAIN || errno == EWOULDBLOCK)) {
>
>