[sheepdog] [PATCH 1/7] net: remove request throttling

Liu Yuan namei.unix at gmail.com
Wed Jul 18 11:35:34 CEST 2012


From: Liu Yuan <tailai.ly at taobao.com>

Request throttling is introduced to tackle OOM prolems when requests were very
easily accumulated because of very limited worker threads. Now with short
threads construct, we will process any request ASAP and requests won't occupy
as many memory as before in a short period. So it's time to remove this
throttling because they are never reached in reality.

Signed-off-by: Liu Yuan <tailai.ly at taobao.com>
---
 include/net.h      |    2 --
 sheep/group.c      |    2 --
 sheep/sdnet.c      |   26 ++------------------------
 sheep/sheep_priv.h |    5 -----
 4 files changed, 2 insertions(+), 33 deletions(-)

diff --git a/include/net.h b/include/net.h
index 581da66..4ee0eb6 100644
--- a/include/net.h
+++ b/include/net.h
@@ -30,8 +30,6 @@ struct connection {
 	int tx_length;
 	void *tx_buf;
 	struct sd_rsp tx_hdr;
-
-	struct list_head blocking_siblings;
 };
 
 int conn_tx_off(struct connection *conn);
diff --git a/sheep/group.c b/sheep/group.c
index 059656e..76cf501 100644
--- a/sheep/group.c
+++ b/sheep/group.c
@@ -1131,8 +1131,6 @@ int create_cluster(int port, int64_t zone, int nr_vnodes,
 	INIT_LIST_HEAD(&sys->failed_nodes);
 	INIT_LIST_HEAD(&sys->delayed_nodes);
 
-	INIT_LIST_HEAD(&sys->blocking_conn_list);
-
 	INIT_LIST_HEAD(&sys->wait_req_queue);
 	INIT_LIST_HEAD(&sys->wait_rw_queue);
 	INIT_LIST_HEAD(&sys->wait_obj_queue);
diff --git a/sheep/sdnet.c b/sheep/sdnet.c
index b875de2..00ec065 100644
--- a/sheep/sdnet.c
+++ b/sheep/sdnet.c
@@ -464,16 +464,14 @@ static struct request *alloc_request(struct client_info *ci, int data_length)
 	INIT_LIST_HEAD(&req->request_list);
 	uatomic_set(&req->refcnt, 1);
 
-	sys->nr_outstanding_reqs++;
-	sys->outstanding_data_size += data_length;
+	uatomic_inc(&sys->nr_outstanding_reqs);
 
 	return req;
 }
 
 static void free_request(struct request *req)
 {
-	sys->nr_outstanding_reqs--;
-	sys->outstanding_data_size -= req->data_length;
+	uatomic_dec(&sys->nr_outstanding_reqs);
 
 	req->ci->refcnt--;
 	put_vnode_info(req->vnodes);
@@ -519,13 +517,6 @@ static void client_rx_handler(struct client_info *ci)
 	struct sd_req *hdr = &conn->rx_hdr;
 	struct request *req;
 
-	if (!ci->rx_req && sys->outstanding_data_size > MAX_OUTSTANDING_DATA_SIZE) {
-		dprintf("too many requests (%p)\n", &ci->conn);
-		conn_rx_off(&ci->conn);
-		list_add(&ci->conn.blocking_siblings, &sys->blocking_conn_list);
-		return;
-	}
-
 	switch (conn->c_rx_state) {
 	case C_IO_HEADER:
 		ret = rx(conn, C_IO_DATA_INIT);
@@ -614,19 +605,10 @@ static void client_tx_handler(struct client_info *ci)
 {
 	int ret, opt;
 	struct sd_rsp *rsp = (struct sd_rsp *)&ci->conn.tx_hdr;
-	struct connection *conn, *n;
 again:
 	init_tx_hdr(ci);
 	if (!ci->tx_req) {
 		conn_tx_off(&ci->conn);
-		if (sys->outstanding_data_size < MAX_OUTSTANDING_DATA_SIZE) {
-			list_for_each_entry_safe(conn, n, &sys->blocking_conn_list,
-						 blocking_siblings) {
-				dprintf("rx on %p\n", conn);
-				list_del_init(&conn->blocking_siblings);
-				conn_rx_on(conn);
-			}
-		}
 		return;
 	}
 
@@ -699,9 +681,6 @@ static void clear_client(struct client_info *ci)
 		free_request(req);
 	}
 
-	if (!list_empty(&ci->conn.blocking_siblings))
-		list_del_init(&ci->conn.blocking_siblings);
-
 	unregister_event(ci->conn.fd);
 
 	dprintf("refcnt:%d, fd:%d, %s:%d\n",
@@ -745,7 +724,6 @@ static struct client_info *create_client(int fd, struct cluster_info *cluster)
 	ci->refcnt = 0;
 
 	INIT_LIST_HEAD(&ci->done_reqs);
-	INIT_LIST_HEAD(&ci->conn.blocking_siblings);
 
 	init_rx_hdr(ci);
 
diff --git a/sheep/sheep_priv.h b/sheep/sheep_priv.h
index 7d5700c..e1f41e0 100644
--- a/sheep/sheep_priv.h
+++ b/sheep/sheep_priv.h
@@ -73,8 +73,6 @@ struct request {
 	struct work work;
 };
 
-#define MAX_OUTSTANDING_DATA_SIZE (256 * 1024 * 1024)
-
 struct cluster_info {
 	struct cluster_driver *cdrv;
 	const char *cdrv_option;
@@ -105,8 +103,6 @@ struct cluster_info {
 
 	DECLARE_BITMAP(vdi_inuse, SD_NR_VDIS);
 
-	struct list_head blocking_conn_list;
-
 	int nr_copies;
 	int req_efd;
 
@@ -115,7 +111,6 @@ struct cluster_info {
 	struct list_head wait_rw_queue;
 	struct list_head wait_obj_queue;
 	int nr_outstanding_reqs;
-	unsigned int outstanding_data_size;
 
 	uint32_t recovered_epoch;
 
-- 
1.7.10.2




More information about the sheepdog mailing list