summaryrefslogtreecommitdiff
path: root/thread.c
diff options
context:
space:
mode:
authordormando <dormando@rydia.net>2019-10-16 19:23:51 -0700
committerdormando <dormando@rydia.net>2020-02-01 14:36:23 -0800
commit2fb221781508c1c1fd274b709ce446efc5aa1e80 (patch)
tree9d43b3b0d337269a9fcd0a01532888e1fe80bede /thread.c
parent8e59147cba140aa7d592b483806a2a8fadb562a2 (diff)
downloadmemcached-2fb221781508c1c1fd274b709ce446efc5aa1e80.tar.gz
network: transient static read buffer for conns
instead of 2k and then realloc all over every time you set a large item, or do large pipelined fetches, use a static slightly larger buffer. Idle connections no longer hold a buffer, freeing up a ton of memory. To maintain compatibility with unbound ASCII multigets, those fall back to the old malloc/realloc/free routine which it's done since the dark ages.
Diffstat (limited to 'thread.c')
-rw-r--r--thread.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/thread.c b/thread.c
index 31a2a5d..2b91f3e 100644
--- a/thread.c
+++ b/thread.c
@@ -411,6 +411,13 @@ static void setup_thread(LIBEVENT_THREAD *me) {
fprintf(stderr, "Failed to create response cache\n");
exit(EXIT_FAILURE);
}
+
+ me->rbuf_cache = cache_create("rbuf", READ_BUFFER_SIZE, sizeof(char *), NULL, NULL);
+ if (me->rbuf_cache == NULL) {
+ fprintf(stderr, "Failed to create read buffer cache\n");
+ exit(EXIT_FAILURE);
+ }
+
#ifdef EXTSTORE
me->io_cache = cache_create("io", sizeof(io_wrap), sizeof(char*), NULL, NULL);
if (me->io_cache == NULL) {
@@ -805,6 +812,8 @@ void threadlocal_stats_aggregate(struct thread_stats *stats) {
stats->response_obj_bytes += threads[ii].resp_cache->total * sizeof(mc_resp);
stats->response_obj_total += threads[ii].resp_cache->total;
stats->response_obj_free += threads[ii].resp_cache->freecurr;
+ stats->read_buf_bytes += threads[ii].rbuf_cache->total * READ_BUFFER_SIZE;
+ stats->read_buf_bytes_free += threads[ii].rbuf_cache->freecurr * READ_BUFFER_SIZE;
pthread_mutex_unlock(&threads[ii].stats.mutex);
}
}