summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--doc/protocol.txt11
-rw-r--r--memcached.c29
-rw-r--r--memcached.h8
-rwxr-xr-xt/stats.t4
-rw-r--r--thread.c23
5 files changed, 19 insertions, 56 deletions
diff --git a/doc/protocol.txt b/doc/protocol.txt
index 72c3371..36fce44 100644
--- a/doc/protocol.txt
+++ b/doc/protocol.txt
@@ -1202,12 +1202,10 @@ integers separated by a colon (treat this as a floating point number).
| rejected_connections | 64u | Conns rejected in maxconns_fast mode |
| connection_structures | 32u | Number of connection structures allocated |
| | | by the server |
-| response_obj_bytes | 64u | Number of bytes used for response objects |
-| response_obj_total | 64u | Total nummber of response objects |
-| response_obj_free | 64u | Current free cached response objects |
| response_obj_oom | 64u | Connections closed by lack of memory |
-| read_buf_bytes | 64u | Total read buffer bytes allocated |
-| read_buf_bytes_free | 64u | Total read buffer bytes cached for reuse |
+| read_buf_count | 64u | Total read/resp buffers allocated |
+| read_buf_bytes | 64u | Total read/resp buffer bytes allocated |
+| read_buf_bytes_free | 64u | Total read/resp buffer bytes cached |
| read_buf_oom | 64u | Connections closed by lack of memory |
| reserved_fds | 32u | Number of misc fds used internally |
| cmd_get | 64u | Cumulative number of retrieval reqs |
@@ -1376,8 +1374,7 @@ other stats command.
| | | per active watcher connected. |
| worker_logbuf_size| 32u | Size of internal per-worker-thread buffer |
| | | which the background thread reads from. |
-| resp_obj_mem_limit| 32u | Megabyte limit for conn. response objects. |
-| read_obj_mem_limit| 32u | Megabyte limit for conn. read buffers. |
+| read_obj_mem_limit| 32u | Megabyte limit for conn. read/resp buffers. |
| track_sizes | bool | If yes, a "stats sizes" histogram is being |
| | | dynamically tracked. |
| inline_ascii_response |
diff --git a/memcached.c b/memcached.c
index adb323c..d796abb 100644
--- a/memcached.c
+++ b/memcached.c
@@ -321,7 +321,6 @@ static void settings_init(void) {
settings.logger_buf_size = LOGGER_BUF_SIZE;
settings.drop_privileges = false;
settings.watch_enabled = true;
- settings.resp_obj_mem_limit = 0;
settings.read_buf_mem_limit = 0;
#ifdef MEMCACHED_DEBUG
settings.relaxed_privileges = false;
@@ -1146,6 +1145,9 @@ static bool resp_start(conn *c) {
return false;
}
// Skip zeroing the bundle pointer at the start.
+ // TODO: this line is here temporarily to make the code easy to disable.
+ // when it's more mature, move the memset into resp_allocate() and have it
+ // set the bundle pointer on allocate so this line isn't as complex.
memset((char *)resp + sizeof(mc_resp_bundle*), 0, sizeof(*resp) - sizeof(mc_resp_bundle*));
// TODO: this next line works. memset _does_ show up significantly under
// perf reports due to zeroing out the entire resp->wbuf. before swapping
@@ -3232,10 +3234,8 @@ static void server_stats(ADD_STAT add_stats, conn *c) {
APPEND_STAT("rejected_connections", "%llu", (unsigned long long)stats.rejected_conns);
}
APPEND_STAT("connection_structures", "%u", stats_state.conn_structs);
- APPEND_STAT("response_obj_bytes", "%llu", (unsigned long long)thread_stats.response_obj_bytes);
- APPEND_STAT("response_obj_total", "%llu", (unsigned long long)thread_stats.response_obj_total);
- APPEND_STAT("response_obj_free", "%llu", (unsigned long long)thread_stats.response_obj_free);
APPEND_STAT("response_obj_oom", "%llu", (unsigned long long)thread_stats.response_obj_oom);
+ APPEND_STAT("read_buf_count", "%llu", (unsigned long long)thread_stats.read_buf_count);
APPEND_STAT("read_buf_bytes", "%llu", (unsigned long long)thread_stats.read_buf_bytes);
APPEND_STAT("read_buf_bytes_free", "%llu", (unsigned long long)thread_stats.read_buf_bytes_free);
APPEND_STAT("read_buf_oom", "%llu", (unsigned long long)thread_stats.read_buf_oom);
@@ -3400,7 +3400,6 @@ static void process_stat_settings(ADD_STAT add_stats, void *c) {
APPEND_STAT("idle_timeout", "%d", settings.idle_timeout);
APPEND_STAT("watcher_logbuf_size", "%u", settings.logger_watcher_buf_size);
APPEND_STAT("worker_logbuf_size", "%u", settings.logger_buf_size);
- APPEND_STAT("resp_obj_mem_limit", "%u", settings.resp_obj_mem_limit);
APPEND_STAT("read_buf_mem_limit", "%u", settings.read_buf_mem_limit);
APPEND_STAT("track_sizes", "%s", item_stats_sizes_status() ? "yes" : "no");
APPEND_STAT("inline_ascii_response", "%s", "no"); // setting is dead, cannot be yes.
@@ -8181,15 +8180,10 @@ static void usage(void) {
" default is %u (unlimited)\n",
flag_enabled_disabled(settings.maxconns_fast), settings.hashpower_init,
settings.lru_crawler_sleep, settings.lru_crawler_tocrawl);
- printf(" - resp_obj_mem_limit: limit in megabytes for connection response objects.\n"
- " do not adjust unless you have high (100k+) conn. limits.\n"
- " 0 means unlimited (default: %u)\n"
- " - read_buf_mem_limit: limit in megabytes for connection read buffers.\n"
- " do not adjust unless you have high (100k+) conn. limits.\n"
+ printf(" - read_buf_mem_limit: limit in megabytes for connection read/response buffers.\n"
+ " do not adjust unless you have high (20k+) conn. limits.\n"
" 0 means unlimited (default: %u)\n",
- settings.resp_obj_mem_limit,
settings.read_buf_mem_limit);
- verify_default("resp_obj_mem_limit", settings.resp_obj_mem_limit == 0);
verify_default("read_buf_mem_limit", settings.read_buf_mem_limit == 0);
printf(" - no_lru_maintainer: disable new LRU system + background thread.\n"
" - hot_lru_pct: pct of slab memory to reserve for hot lru.\n"
@@ -9842,15 +9836,8 @@ int main (int argc, char **argv) {
settings.drop_privileges = true;
break;
case RESP_OBJ_MEM_LIMIT:
- if (subopts_value == NULL) {
- fprintf(stderr, "Missing resp_obj_mem_limit argument\n");
- return 1;
- }
- if (!safe_strtoul(subopts_value, &settings.resp_obj_mem_limit)) {
- fprintf(stderr, "could not parse argument to resp_obj_mem_limit\n");
- return 1;
- }
- settings.resp_obj_mem_limit *= 1024 * 1024; /* megabytes */
+ // TODO: Remove at some point in the future.
+ fprintf(stderr, "DEPRECATED: resp_obj_mem_limit no longer used. See read_buf_mem_limit,\n");
break;
case READ_BUF_MEM_LIMIT:
if (subopts_value == NULL) {
diff --git a/memcached.h b/memcached.h
index ba944ef..2cafed9 100644
--- a/memcached.h
+++ b/memcached.h
@@ -327,9 +327,7 @@ struct thread_stats {
#undef X
struct slab_stats slab_stats[MAX_NUMBER_OF_SLAB_CLASSES];
uint64_t lru_hits[POWER_LARGEST];
- uint64_t response_obj_bytes;
- uint64_t response_obj_total;
- uint64_t response_obj_free;
+ uint64_t read_buf_count;
uint64_t read_buf_bytes;
uint64_t read_buf_bytes_free;
};
@@ -448,8 +446,7 @@ struct settings {
int idle_timeout; /* Number of seconds to let connections idle */
unsigned int logger_watcher_buf_size; /* size of logger's per-watcher buffer */
unsigned int logger_buf_size; /* size of per-thread logger buffer */
- unsigned int resp_obj_mem_limit; /* total megabytes allowable for resp objects */
- unsigned int read_buf_mem_limit; /* total megabytes allowable for read buffers */
+ unsigned int read_buf_mem_limit; /* total megabytes allowable for net buffers */
bool drop_privileges; /* Whether or not to drop unnecessary process privileges */
bool watch_enabled; /* allows watch commands to be dropped */
bool relaxed_privileges; /* Relax process restrictions when running testapp */
@@ -611,7 +608,6 @@ typedef struct {
int notify_send_fd; /* sending end of notify pipe */
struct thread_stats stats; /* Stats generated by this thread */
struct conn_queue *new_conn_queue; /* queue of new connections to handle */
- cache_t *resp_cache; /* response objects */
cache_t *rbuf_cache; /* static-sized read buffers */
mc_resp_bundle *open_bundle;
#ifdef EXTSTORE
diff --git a/t/stats.t b/t/stats.t
index a84dc05..ad51e5f 100755
--- a/t/stats.t
+++ b/t/stats.t
@@ -28,9 +28,9 @@ if (MemcachedTest::enabled_tls_testing()) {
# when TLS is enabled, stats contains additional keys:
# - ssl_handshake_errors
# - time_since_server_cert_refresh
- is(scalar(keys(%$stats)), 80, "expected count of stats values");
-} else {
is(scalar(keys(%$stats)), 78, "expected count of stats values");
+} else {
+ is(scalar(keys(%$stats)), 76, "expected count of stats values");
}
# Test initial state
diff --git a/thread.c b/thread.c
index abbfca1..15ce7a1 100644
--- a/thread.c
+++ b/thread.c
@@ -424,28 +424,13 @@ static void setup_thread(LIBEVENT_THREAD *me) {
exit(EXIT_FAILURE);
}
- me->resp_cache = cache_create("resp", sizeof(mc_resp), sizeof(char *), NULL, NULL);
- if (me->resp_cache == NULL) {
- fprintf(stderr, "Failed to create response cache\n");
- exit(EXIT_FAILURE);
- }
- // Note: we were cleanly passing in num_threads before, but this now
- // relies on settings globals too much.
- if (settings.resp_obj_mem_limit) {
- int limit = settings.resp_obj_mem_limit / settings.num_threads;
- if (limit < sizeof(mc_resp)) {
- limit = 1;
- } else {
- limit = limit / sizeof(mc_resp);
- }
- cache_set_limit(me->resp_cache, limit);
- }
-
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);
}
+ // Note: we were cleanly passing in num_threads before, but this now
+ // relies on settings globals too much.
if (settings.read_buf_mem_limit) {
int limit = settings.read_buf_mem_limit / settings.num_threads;
if (limit < READ_BUFFER_SIZE) {
@@ -847,9 +832,7 @@ void threadlocal_stats_aggregate(struct thread_stats *stats) {
threads[ii].stats.lru_hits[sid];
}
- 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_count += threads[ii].rbuf_cache->total;
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);