Commit 8e65b6a3 authored by antirez's avatar antirez
Browse files

Applied a few modifications to hiredis to tune it for speed (redis-benchmark)...

Applied a few modifications to hiredis to tune it for speed (redis-benchmark) and ability to read more deeply nested replies (redis-cli).
parent b66e5add
...@@ -447,9 +447,9 @@ static int processMultiBulkItem(redisReader *r) { ...@@ -447,9 +447,9 @@ static int processMultiBulkItem(redisReader *r) {
int root = 0; int root = 0;
/* Set error for nested multi bulks with depth > 2 */ /* Set error for nested multi bulks with depth > 2 */
if (r->ridx == 3) { if (r->ridx == 8) {
__redisReaderSetError(r,REDIS_ERR_PROTOCOL, __redisReaderSetError(r,REDIS_ERR_PROTOCOL,
"No support for nested multi bulk replies with depth > 2"); "No support for nested multi bulk replies with depth > 7");
return REDIS_ERR; return REDIS_ERR;
} }
...@@ -590,6 +590,7 @@ int redisReaderFeed(redisReader *r, const char *buf, size_t len) { ...@@ -590,6 +590,7 @@ int redisReaderFeed(redisReader *r, const char *buf, size_t len) {
/* Copy the provided buffer. */ /* Copy the provided buffer. */
if (buf != NULL && len >= 1) { if (buf != NULL && len >= 1) {
#if 0
/* Destroy internal buffer when it is empty and is quite large. */ /* Destroy internal buffer when it is empty and is quite large. */
if (r->len == 0 && sdsavail(r->buf) > 16*1024) { if (r->len == 0 && sdsavail(r->buf) > 16*1024) {
sdsfree(r->buf); sdsfree(r->buf);
...@@ -599,6 +600,7 @@ int redisReaderFeed(redisReader *r, const char *buf, size_t len) { ...@@ -599,6 +600,7 @@ int redisReaderFeed(redisReader *r, const char *buf, size_t len) {
/* r->buf should not be NULL since we just free'd a larger one. */ /* r->buf should not be NULL since we just free'd a larger one. */
assert(r->buf != NULL); assert(r->buf != NULL);
} }
#endif
newbuf = sdscatlen(r->buf,buf,len); newbuf = sdscatlen(r->buf,buf,len);
if (newbuf == NULL) { if (newbuf == NULL) {
...@@ -1067,7 +1069,7 @@ int redisSetTimeout(redisContext *c, struct timeval tv) { ...@@ -1067,7 +1069,7 @@ int redisSetTimeout(redisContext *c, struct timeval tv) {
* After this function is called, you may use redisContextReadReply to * After this function is called, you may use redisContextReadReply to
* see if there is a reply available. */ * see if there is a reply available. */
int redisBufferRead(redisContext *c) { int redisBufferRead(redisContext *c) {
char buf[2048]; char buf[1024*16];
int nread; int nread;
/* Return early when the context has seen an error. */ /* Return early when the context has seen an error. */
......
...@@ -123,7 +123,7 @@ typedef struct redisReader { ...@@ -123,7 +123,7 @@ typedef struct redisReader {
size_t pos; /* Buffer cursor */ size_t pos; /* Buffer cursor */
size_t len; /* Buffer length */ size_t len; /* Buffer length */
redisReadTask rstack[4]; redisReadTask rstack[9];
int ridx; /* Index of current read task */ int ridx; /* Index of current read task */
void *reply; /* Temporary reply pointer */ void *reply; /* Temporary reply pointer */
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment