Updated C client, performance, etc...

Evan Martin martine at danga.com
Fri Nov 12 10:08:55 PST 2004

On Thu, Nov 11, 2004 at 05:48:18PM -0800, Sean Chittenden wrote:
> *) Using kqueue(2) instead of select(2) would probably be a nice 
> winner, but I don't want to deal with interface portability quite yet 
> (besides, one file descriptor on a select(2) call isn't too terrible).

Note that anyone using memcached has already figured out wrangling
libevent.  But why are you using select at all?  Looking through the
code, it looks like you're using non-blocking sockets?  Why?
All of the comments by mc_server_block just say "Switch to non-blocking

This, in particular, is worrisome:

      rb = read(ms->fd, mc->read_cur, mc->size - (size_t)(mc->cur - mc->buf));
      switch(rb) {
      case -1:
	/* We're in non-blocking mode, don't abort because of EAGAIN or
	 * EINTR */
	if (errno == EAGAIN || errno == EINTR)
	  goto try_read;

Won't that just spin if HAVE_SELECT is not defined?

> *) Using mmap(2) for buffers instead of malloc(3)'ed memory (not having 
> to copy data from kernel to user and visa versa is always good).
> *) A binary protocol.  The current protocol requires a tad bit of 
> searching, but it's not bad.  I don't imagine there would be much of a 
> speedup to be had here, but it's an option.
> ...but I doubt it'll buy much to go down those routes... no app is 
> going to be limited by libmemcache's performance (that I'm aware of).

(Certainly, profiling would be in order first.)

Random other comment:  in your "license", you write: "Use of this software in
programs released under the GPL programs is expressly prohibited by the author
(ie, BSD, closed source, or artistic license is okay, but GPL is not)."

Without initiating a license flamewar, I would like to point out that
weird licences such as this prevent this from being used by software
such as LiveJournal itself, which is what memcached was written for in
the first place.

Evan Martin
martine at danga.com

More information about the memcached mailing list