From: Brian Aker Date: Sat, 13 Oct 2007 17:26:52 +0000 (-0700) Subject: Created a bigger buffer for write/read. X-Git-Tag: 0_7~39 X-Git-Url: https://git.m6w6.name/?a=commitdiff_plain;h=2c7a6aaf4a69aab11206078afcd3355271ddf128;p=m6w6%2Flibmemcached Created a bigger buffer for write/read. set are now more pipelined then perform (roughly 4X faster according to done in users). --- diff --git a/include/memcached.h b/include/memcached.h index 6797279b..9df45603 100644 --- a/include/memcached.h +++ b/include/memcached.h @@ -39,7 +39,7 @@ typedef struct memcached_server_st memcached_server_st; #define HUGE_STRING_LEN 8196 #define MEMCACHED_MAX_KEY 251 /* We add one to have it null terminated */ //#define MEMCACHED_MAX_BUFFER 8196 -#define MEMCACHED_MAX_BUFFER 8196 +#define MEMCACHED_MAX_BUFFER HUGE_STRING_LEN*4 typedef enum { MEMCACHED_SUCCESS, diff --git a/lib/memcached_io.c b/lib/memcached_io.c index 5e05d2c5..54a4b8dc 100644 --- a/lib/memcached_io.c +++ b/lib/memcached_io.c @@ -154,8 +154,12 @@ ssize_t memcached_io_flush(memcached_st *ptr, unsigned int server_key) } sent_length= 0; +#ifdef orig if ((sent_length= send(ptr->hosts[server_key].fd, write_ptr, write_length, 0)) == -1) +#endif + if ((sent_length= write(ptr->hosts[server_key].fd, write_ptr, + write_length)) == -1) { switch (errno) { diff --git a/lib/memcached_storage.c b/lib/memcached_storage.c index 5a8701fa..9d82b56f 100644 --- a/lib/memcached_storage.c +++ b/lib/memcached_storage.c @@ -26,6 +26,7 @@ static memcached_return memcached_send(memcached_st *ptr, uint16_t flags, memcached_storage_action verb) { + char to_write; size_t write_length; ssize_t sent_length; memcached_return rc; @@ -36,13 +37,11 @@ static memcached_return memcached_send(memcached_st *ptr, assert(value_length); /* Leaving this assert in since only a library fubar could blow this */ - if (ptr->write_buffer_offset != 0) - { - WATCHPOINT_NUMBER(ptr->write_buffer_offset); - } +#ifdef NOT_DONE + if (!(ptr->flags & MEM_NO_BLOCK) && ptr->write_buffer_offset != 0) + assert(0); +#endif - assert(ptr->write_buffer_offset == 0); - server_key= memcached_generate_hash(ptr, key, key_length); rc= memcached_connect(ptr, server_key); @@ -75,7 +74,12 @@ static memcached_return memcached_send(memcached_st *ptr, goto error; } - if ((sent_length= memcached_io_write(ptr, server_key, "\r\n", 2, 1)) == -1) + if ((ptr->flags & MEM_NO_BLOCK) && verb == SET_OP) + to_write= 0; + else + to_write= 1; + + if ((sent_length= memcached_io_write(ptr, server_key, "\r\n", 2, to_write)) == -1) { memcached_quit_server(ptr, server_key); rc= MEMCACHED_WRITE_FAILURE;